From 72b9c37ec891c0db20e4e5aff2dfaa4218afaad4 Mon Sep 17 00:00:00 2001 From: Moxie Marlinspike Date: Wed, 4 Nov 2015 12:39:53 -0800 Subject: [PATCH] Mark muted messages as read when in thread Fixes #3562 Closes #3643 // FREEBIE --- .../notifications/MessageNotifier.java | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/org/thoughtcrime/securesms/notifications/MessageNotifier.java b/src/org/thoughtcrime/securesms/notifications/MessageNotifier.java index ffff998c4d..f4c71c732c 100644 --- a/src/org/thoughtcrime/securesms/notifications/MessageNotifier.java +++ b/src/org/thoughtcrime/securesms/notifications/MessageNotifier.java @@ -50,10 +50,8 @@ import org.thoughtcrime.securesms.recipients.Recipient; import org.thoughtcrime.securesms.recipients.RecipientFactory; import org.thoughtcrime.securesms.recipients.Recipients; import org.thoughtcrime.securesms.service.KeyCachingService; -import org.thoughtcrime.securesms.util.ListenableFutureTask; import org.thoughtcrime.securesms.util.SpanUtil; import org.thoughtcrime.securesms.util.TextSecurePreferences; -import org.thoughtcrime.securesms.util.concurrent.ListenableFuture; import org.whispersystems.textsecure.api.messages.TextSecureEnvelope; import java.io.IOException; @@ -120,8 +118,15 @@ public class MessageNotifier { boolean includePushDatabase, long threadId) { - Recipients recipients = DatabaseFactory.getThreadDatabase(context) - .getRecipientsForThreadId(threadId); + boolean isVisible = visibleThread == threadId; + + ThreadDatabase threads = DatabaseFactory.getThreadDatabase(context); + Recipients recipients = DatabaseFactory.getThreadDatabase(context) + .getRecipientsForThreadId(threadId); + + if (isVisible) { + threads.setRead(threadId); + } if (!TextSecurePreferences.isNotificationsEnabled(context) || (recipients != null && recipients.isMuted())) @@ -129,9 +134,7 @@ public class MessageNotifier { return; } - if (visibleThread == threadId) { - ThreadDatabase threads = DatabaseFactory.getThreadDatabase(context); - threads.setRead(threadId); + if (isVisible) { sendInThreadNotification(context, threads.getRecipientsForThreadId(threadId)); } else { updateNotification(context, masterSecret, true, includePushDatabase, 0);