mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-25 03:11:10 +01:00
Mark sent gift viewed when opened.
This commit is contained in:
committed by
Cody Henthorne
parent
15af1d3bd1
commit
425a13e68c
@@ -1977,6 +1977,13 @@ public class ConversationFragment extends LoggingFragment implements Multiselect
|
||||
ViewReceivedGiftBottomSheet.show(getChildFragmentManager(), (MmsMessageRecord) messageRecord);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onGiftBadgeRevealed(@NonNull MessageRecord messageRecord) {
|
||||
if (messageRecord.isOutgoing() && MessageRecordUtil.hasGiftBadge(messageRecord)) {
|
||||
conversationViewModel.markGiftBadgeRevealed(messageRecord.getId());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void refreshList() {
|
||||
|
||||
@@ -2041,9 +2041,8 @@ public final class ConversationItem extends RelativeLayout implements BindableCo
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable Projection getOpenableGiftProjection() {
|
||||
boolean isViewedAndIncoming = !messageRecord.isOutgoing() && messageRecord.getViewedReceiptCount() > 0;
|
||||
if (!isGiftMessage(messageRecord) || messageRecord.isRemoteDelete() || isViewedAndIncoming) {
|
||||
public @Nullable Projection getOpenableGiftProjection(boolean isAnimating) {
|
||||
if (!isGiftMessage(messageRecord) || messageRecord.isRemoteDelete() || (messageRecord.getViewedReceiptCount() > 0 && !isAnimating)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -2061,7 +2060,10 @@ public final class ConversationItem extends RelativeLayout implements BindableCo
|
||||
@Override
|
||||
public void setOpenGiftCallback(@NonNull Function1<? super OpenableGift, Unit> openGift) {
|
||||
if (giftViewStub.resolved()) {
|
||||
bodyBubble.setOnClickListener(unused -> openGift.invoke(this));
|
||||
bodyBubble.setOnClickListener(unused -> {
|
||||
openGift.invoke(this);
|
||||
eventListener.onGiftBadgeRevealed(messageRecord);
|
||||
});
|
||||
giftViewStub.get().onGiftNotOpened();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,17 +9,21 @@ import androidx.annotation.WorkerThread;
|
||||
import org.signal.core.util.concurrent.SignalExecutors;
|
||||
import org.signal.core.util.logging.Log;
|
||||
import org.thoughtcrime.securesms.database.GroupDatabase;
|
||||
import org.thoughtcrime.securesms.database.MessageDatabase;
|
||||
import org.thoughtcrime.securesms.database.SignalDatabase;
|
||||
import org.thoughtcrime.securesms.database.ThreadDatabase;
|
||||
import org.thoughtcrime.securesms.dependencies.ApplicationDependencies;
|
||||
import org.thoughtcrime.securesms.jobs.MultiDeviceViewedUpdateJob;
|
||||
import org.thoughtcrime.securesms.keyvalue.SignalStore;
|
||||
import org.thoughtcrime.securesms.recipients.Recipient;
|
||||
import org.thoughtcrime.securesms.recipients.RecipientUtil;
|
||||
import org.thoughtcrime.securesms.util.BubbleUtil;
|
||||
import org.thoughtcrime.securesms.util.ConversationUtil;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
class ConversationRepository {
|
||||
|
||||
@@ -98,4 +102,17 @@ class ConversationRepository {
|
||||
|
||||
return new ConversationData(threadId, lastSeen, lastSeenPosition, lastScrolledPosition, jumpToPosition, threadSize, messageRequestData, showUniversalExpireTimerUpdate);
|
||||
}
|
||||
|
||||
void markGiftBadgeRevealed(long messageId) {
|
||||
SignalExecutors.BOUNDED_IO.execute(() -> {
|
||||
List<MessageDatabase.MarkedMessageInfo> markedMessageInfo = SignalDatabase.mms().setOutgoingGiftsRevealed(Collections.singletonList(messageId));
|
||||
if (!markedMessageInfo.isEmpty()) {
|
||||
Log.d(TAG, "Marked gift badge revealed. Sending view sync message.");
|
||||
MultiDeviceViewedUpdateJob.enqueue(
|
||||
markedMessageInfo.stream()
|
||||
.map(MessageDatabase.MarkedMessageInfo::getSyncMessageId)
|
||||
.collect(Collectors.toList()));
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -276,6 +276,10 @@ public class ConversationViewModel extends ViewModel {
|
||||
searchQuery.setValue(query);
|
||||
}
|
||||
|
||||
void markGiftBadgeRevealed(long messageId) {
|
||||
conversationRepository.markGiftBadgeRevealed(messageId);
|
||||
}
|
||||
|
||||
@NonNull LiveData<String> getSearchQuery() {
|
||||
return searchQuery;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user