diff options
author | Christian Schneppe <christian@pix-art.de> | 2018-04-22 17:11:45 +0200 |
---|---|---|
committer | Christian Schneppe <christian@pix-art.de> | 2018-04-22 17:11:45 +0200 |
commit | 1b4bae25fe4c4ff29ab1db532fa3f16e5232c583 (patch) | |
tree | 619dbf2b3556111e978e36baa1d50482b7db26c1 /src/main/java/de/pixart/messenger/services/XmppConnectionService.java | |
parent | 73bfa9c1ccb076974c41de45001f7885242208c5 (diff) |
only mark visible messages as read
Diffstat (limited to '')
-rw-r--r-- | src/main/java/de/pixart/messenger/services/XmppConnectionService.java | 33 |
1 files changed, 20 insertions, 13 deletions
diff --git a/src/main/java/de/pixart/messenger/services/XmppConnectionService.java b/src/main/java/de/pixart/messenger/services/XmppConnectionService.java index dfd05bbe3..9a9f53589 100644 --- a/src/main/java/de/pixart/messenger/services/XmppConnectionService.java +++ b/src/main/java/de/pixart/messenger/services/XmppConnectionService.java @@ -632,7 +632,7 @@ public class XmppConnectionService extends Service { } try { restoredFromDatabaseLatch.await(); - sendReadMarker(c); + sendReadMarker(c, null); } catch (InterruptedException e) { Log.d(Config.LOGTAG, "unable to process notification read marker for conversation " + c.getName()); } @@ -3444,9 +3444,11 @@ public class XmppConnectionService extends Service { } public void markMessage(Message message, int status, String errorMessage) { - if (status == Message.STATUS_SEND_FAILED - && (message.getStatus() == Message.STATUS_SEND_RECEIVED || message - .getStatus() == Message.STATUS_SEND_DISPLAYED)) { + final int c = message.getStatus(); + if (status == Message.STATUS_SEND_FAILED && (c == Message.STATUS_SEND_RECEIVED || c == Message.STATUS_SEND_DISPLAYED)) { + return; + } + if (status == Message.STATUS_SEND_RECEIVED && c == Message.STATUS_SEND_DISPLAYED) { return; } message.setErrorMessage(errorMessage); @@ -3603,15 +3605,19 @@ public class XmppConnectionService extends Service { return null; } + public boolean markRead(final Conversation conversation, boolean dismiss) { + return markRead(conversation, null, dismiss).size() > 0; + } + public boolean markRead(final Conversation conversation) { - return markRead(conversation, true); + return markRead(conversation, null, true).size() > 0; } - public boolean markRead(final Conversation conversation, boolean clear) { - if (clear) { + public List<Message> markRead(final Conversation conversation, String upToUuid, boolean dismiss) { + if (dismiss) { mNotificationService.clear(conversation); } - final List<Message> readMessages = conversation.markRead(); + final List<Message> readMessages = conversation.markRead(upToUuid); if (readMessages.size() > 0) { Runnable runnable = () -> { for (Message message : readMessages) { @@ -3620,9 +3626,9 @@ public class XmppConnectionService extends Service { }; mDatabaseWriterExecutor.execute(runnable); updateUnreadCountBadge(); - return true; + return readMessages; } else { - return false; + return readMessages; } } @@ -3641,12 +3647,13 @@ public class XmppConnectionService extends Service { }).start(); } - public void sendReadMarker(final Conversation conversation) { + public void sendReadMarker(final Conversation conversation, String upToUuid) { final boolean isPrivateAndNonAnonymousMuc = conversation.getMode() == Conversation.MODE_MULTI && conversation.isPrivateAndNonAnonymous(); - final Message markable = conversation.getLatestMarkableMessage(isPrivateAndNonAnonymousMuc); - if (this.markRead(conversation)) { + final List<Message> readMessages = this.markRead(conversation, upToUuid, true); + if (readMessages.size() > 0) { updateConversationUi(); } + final Message markable = Conversation.getLatestMarkableMessage(readMessages, isPrivateAndNonAnonymousMuc); if (confirmMessages() && markable != null && (markable.trusted() || isPrivateAndNonAnonymousMuc) |