aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Gultsch <daniel@gultsch.de>2017-11-21 13:26:23 +0100
committerDaniel Gultsch <daniel@gultsch.de>2017-11-21 13:26:23 +0100
commit702d6cf2a5e10c2a130e2d0d8240b9f9c7bc4d3f (patch)
tree2dba05f75f32626f65bb9efacdd323b8cc6d507f
parent05b6fdb9f12872181262f6d28ac92575353e6314 (diff)
MessageParser: dismiss notification when receiving read marker from another client
-rw-r--r--src/main/java/eu/siacs/conversations/parser/MessageParser.java19
1 files changed, 12 insertions, 7 deletions
diff --git a/src/main/java/eu/siacs/conversations/parser/MessageParser.java b/src/main/java/eu/siacs/conversations/parser/MessageParser.java
index 8deae03..e5ea361 100644
--- a/src/main/java/eu/siacs/conversations/parser/MessageParser.java
+++ b/src/main/java/eu/siacs/conversations/parser/MessageParser.java
@@ -712,15 +712,20 @@ public class MessageParser extends AbstractParser implements OnMessagePacketRece
if (conversation != null && id != null) {
Message message = conversation.findMessageWithRemoteId(id);
if (message != null) {
- final Jid fallback = conversation.getMucOptions().getTrueCounterpart(counterpart);
- Jid trueJid = getTrueCounterpart(query != null ? mucUserElement : null, fallback);
- ReadByMarker readByMarker = ReadByMarker.from(counterpart,trueJid);
- if (!conversation.getMucOptions().isSelf(counterpart) && message.addReadByMarker(readByMarker)) {
- Log.d(Config.LOGTAG,account.getJid().toBareJid()+": added read by ("+readByMarker.getRealJid()+") to message '"+message.getBody()+"'");
- mXmppConnectionService.updateMessage(message);
+ if (conversation.getMucOptions().isSelf(counterpart)) {
+ if (!message.isRead() && (query == null || query.isCatchup())) { //checking if message is unread fixes race conditions with reflections
+ mXmppConnectionService.markRead(conversation);
+ }
+ } else {
+ final Jid fallback = conversation.getMucOptions().getTrueCounterpart(counterpart);
+ Jid trueJid = getTrueCounterpart(query != null ? mucUserElement : null, fallback);
+ ReadByMarker readByMarker = ReadByMarker.from(counterpart, trueJid);
+ if (message.addReadByMarker(readByMarker)) {
+ Log.d(Config.LOGTAG, account.getJid().toBareJid() + ": added read by (" + readByMarker.getRealJid() + ") to message '" + message.getBody() + "'");
+ mXmppConnectionService.updateMessage(message);
+ }
}
}
-
}
} else {
final Message displayedMessage = mXmppConnectionService.markMessage(account, from.toBareJid(), id, Message.STATUS_SEND_DISPLAYED);