Fix bad notification state with in-thread reaction notifications.

This commit is contained in:
Cody Henthorne
2021-04-14 13:52:34 -04:00
committed by Greyson Parrelli
parent ed8edb5aee
commit c393cd655d
2 changed files with 17 additions and 5 deletions

View File

@@ -68,7 +68,6 @@ import com.annimon.stream.Stream;
import org.signal.core.util.StreamUtil;
import org.signal.core.util.concurrent.SignalExecutors;
import org.signal.core.util.logging.Log;
import org.thoughtcrime.securesms.ApplicationContext;
import org.thoughtcrime.securesms.ApplicationPreferencesActivity;
import org.thoughtcrime.securesms.LoggingFragment;
import org.thoughtcrime.securesms.PassphraseRequiredActivity;
@@ -96,6 +95,7 @@ import org.thoughtcrime.securesms.database.SmsDatabase;
import org.thoughtcrime.securesms.database.model.MediaMmsMessageRecord;
import org.thoughtcrime.securesms.database.model.MessageRecord;
import org.thoughtcrime.securesms.database.model.MmsMessageRecord;
import org.thoughtcrime.securesms.database.model.ReactionRecord;
import org.thoughtcrime.securesms.dependencies.ApplicationDependencies;
import org.thoughtcrime.securesms.groups.GroupId;
import org.thoughtcrime.securesms.groups.GroupMigrationMembershipChange;
@@ -1157,10 +1157,13 @@ public class ConversationFragment extends LoggingFragment {
if (position >= (isTypingIndicatorShowing() ? 1 : 0)) {
ConversationMessage item = getListAdapter().getItem(position);
if (item != null) {
long timestamp = item.getMessageRecord()
.getDateReceived();
MessageRecord record = item.getMessageRecord();
long latestReactionReceived = Stream.of(record.getReactions())
.map(ReactionRecord::getDateReceived)
.max(Long::compareTo)
.orElse(0L);
markReadHelper.onViewsRevealed(timestamp);
markReadHelper.onViewsRevealed(Math.max(record.getDateReceived(), latestReactionReceived));
}
}
}
@@ -1616,6 +1619,12 @@ public class ConversationFragment extends LoggingFragment {
super.onItemRangeInserted(positionStart, itemCount);
}
@Override
public void onItemRangeChanged(int positionStart, int itemCount) {
super.onItemRangeChanged(positionStart, itemCount);
list.post(ConversationFragment.this::postMarkAsReadRequest);
}
}
private final class ConversationScrollRequestValidator implements SnapToTopDataObserver.ScrollRequestValidator {

View File

@@ -56,6 +56,9 @@ object NotificationFactory {
if (Build.VERSION.SDK_INT >= 23 || state.conversations.size == 1) {
state.conversations.forEach { conversation ->
if (conversation.threadId == visibleThreadId && conversation.hasNewNotifications()) {
if (FeatureFlags.internalUser()) {
Log.i(TAG, "Thread is visible, notifying in thread. notificationId: ${conversation.notificationId}")
}
notifyInThread(context, conversation.recipient, lastAudibleNotification)
} else if (conversation.hasNewNotifications() || alertOverrides.contains(conversation.threadId)) {
@@ -73,7 +76,7 @@ object NotificationFactory {
}
}
if (state.conversations.size > 1 || ServiceUtil.getNotificationManager(context).isDisplayingSummaryNotification()) {
if ((state.conversations.size > 1 && threadsThatNewlyAlerted.isNotEmpty()) || ServiceUtil.getNotificationManager(context).isDisplayingSummaryNotification()) {
val builder: NotificationBuilder = NotificationBuilder.create(context)
builder.apply {