Mark muted messages as read when in thread

Fixes #3562
Closes #3643
// FREEBIE
This commit is contained in:
Moxie Marlinspike 2015-11-04 12:39:53 -08:00
parent 5704fad7cc
commit 72b9c37ec8

View File

@ -50,10 +50,8 @@ import org.thoughtcrime.securesms.recipients.Recipient;
import org.thoughtcrime.securesms.recipients.RecipientFactory; import org.thoughtcrime.securesms.recipients.RecipientFactory;
import org.thoughtcrime.securesms.recipients.Recipients; import org.thoughtcrime.securesms.recipients.Recipients;
import org.thoughtcrime.securesms.service.KeyCachingService; import org.thoughtcrime.securesms.service.KeyCachingService;
import org.thoughtcrime.securesms.util.ListenableFutureTask;
import org.thoughtcrime.securesms.util.SpanUtil; import org.thoughtcrime.securesms.util.SpanUtil;
import org.thoughtcrime.securesms.util.TextSecurePreferences; import org.thoughtcrime.securesms.util.TextSecurePreferences;
import org.thoughtcrime.securesms.util.concurrent.ListenableFuture;
import org.whispersystems.textsecure.api.messages.TextSecureEnvelope; import org.whispersystems.textsecure.api.messages.TextSecureEnvelope;
import java.io.IOException; import java.io.IOException;
@ -120,18 +118,23 @@ public class MessageNotifier {
boolean includePushDatabase, boolean includePushDatabase,
long threadId) long threadId)
{ {
boolean isVisible = visibleThread == threadId;
ThreadDatabase threads = DatabaseFactory.getThreadDatabase(context);
Recipients recipients = DatabaseFactory.getThreadDatabase(context) Recipients recipients = DatabaseFactory.getThreadDatabase(context)
.getRecipientsForThreadId(threadId); .getRecipientsForThreadId(threadId);
if (isVisible) {
threads.setRead(threadId);
}
if (!TextSecurePreferences.isNotificationsEnabled(context) || if (!TextSecurePreferences.isNotificationsEnabled(context) ||
(recipients != null && recipients.isMuted())) (recipients != null && recipients.isMuted()))
{ {
return; return;
} }
if (visibleThread == threadId) { if (isVisible) {
ThreadDatabase threads = DatabaseFactory.getThreadDatabase(context);
threads.setRead(threadId);
sendInThreadNotification(context, threads.getRecipientsForThreadId(threadId)); sendInThreadNotification(context, threads.getRecipientsForThreadId(threadId));
} else { } else {
updateNotification(context, masterSecret, true, includePushDatabase, 0); updateNotification(context, masterSecret, true, includePushDatabase, 0);