diff options
author | Christian Schneppe <christian@pix-art.de> | 2017-11-23 20:44:36 +0100 |
---|---|---|
committer | Christian Schneppe <christian@pix-art.de> | 2017-11-23 20:44:36 +0100 |
commit | a42f6ec1caad233ec9b878ebfa7ba5070ffd67ef (patch) | |
tree | e61d118c1f9b5a7f22e4f5aed0150b50cd913f18 | |
parent | efd0ca9dd0569db2da2dfea7734f421ff923c72b (diff) |
deduplicate read markers if one with real jid is found
4 files changed, 18 insertions, 4 deletions
diff --git a/src/main/java/de/pixart/messenger/entities/Message.java b/src/main/java/de/pixart/messenger/entities/Message.java index 2fa9d7c3a..9d1209830 100644 --- a/src/main/java/de/pixart/messenger/entities/Message.java +++ b/src/main/java/de/pixart/messenger/entities/Message.java @@ -11,6 +11,7 @@ import java.net.MalformedURLException; import java.net.URL; import java.util.Collections; import java.util.HashSet; +import java.util.Iterator; import java.util.List; import java.util.Set; @@ -443,7 +444,20 @@ public class Message extends AbstractEntity { return false; } } - return this.readByMarkers.add(readByMarker); + if (this.readByMarkers.add(readByMarker)) { + if (readByMarker.getRealJid() != null && readByMarker.getFullJid() != null) { + Iterator<ReadByMarker> iterator = this.readByMarkers.iterator(); + while (iterator.hasNext()) { + ReadByMarker marker = iterator.next(); + if (marker.getRealJid() == null && readByMarker.getFullJid().equals(marker.getFullJid())) { + iterator.remove(); + } + } + } + return true; + } else { + return false; + } } public Set<ReadByMarker> getReadByMarkers() { diff --git a/src/main/java/de/pixart/messenger/entities/ReadByMarker.java b/src/main/java/de/pixart/messenger/entities/ReadByMarker.java index 1536a7ccd..3162c26c6 100644 --- a/src/main/java/de/pixart/messenger/entities/ReadByMarker.java +++ b/src/main/java/de/pixart/messenger/entities/ReadByMarker.java @@ -82,7 +82,7 @@ public class ReadByMarker { public static ReadByMarker from(Jid fullJid, Jid realJid) { final ReadByMarker marker = new ReadByMarker(); marker.fullJid = fullJid; - marker.realJid = realJid; + marker.realJid = realJid == null ? null : realJid.toBareJid(); return marker; } diff --git a/src/main/java/de/pixart/messenger/parser/MessageParser.java b/src/main/java/de/pixart/messenger/parser/MessageParser.java index 760b1b068..64317752d 100644 --- a/src/main/java/de/pixart/messenger/parser/MessageParser.java +++ b/src/main/java/de/pixart/messenger/parser/MessageParser.java @@ -713,8 +713,8 @@ public class MessageParser extends AbstractParser implements OnMessagePacketRece 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.markMessage(message, Message.STATUS_SEND_DISPLAYED); mXmppConnectionService.updateMessage(message); + mXmppConnectionService.markMessage(message, Message.STATUS_SEND_DISPLAYED); } } } diff --git a/src/main/java/de/pixart/messenger/utils/UIHelper.java b/src/main/java/de/pixart/messenger/utils/UIHelper.java index 65b80527b..b95c08e38 100644 --- a/src/main/java/de/pixart/messenger/utils/UIHelper.java +++ b/src/main/java/de/pixart/messenger/utils/UIHelper.java @@ -382,7 +382,7 @@ public class UIHelper { if (builder.length() != 0) { builder.append(", "); } - final String name = UIHelper.getDisplayName(users.get(0)); + final String name = UIHelper.getDisplayName(users.get(i)); builder.append(shortNames ? name.split("\\s+")[0] : name); } return builder.toString(); |