deduplicate read markers if one with real jid is found
This commit is contained in:
parent
513427c8a8
commit
333e7a6510
|
@ -12,6 +12,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;
|
||||
|
||||
|
@ -433,16 +434,27 @@ public class Message extends AbstractEntity {
|
|||
public boolean addReadByMarker(ReadByMarker readByMarker) {
|
||||
if (readByMarker.getRealJid() != null) {
|
||||
if (readByMarker.getRealJid().toBareJid().equals(trueCounterpart)) {
|
||||
Log.d(Config.LOGTAG,"trying to add read marker by "+readByMarker.getRealJid()+" to "+body);
|
||||
return false;
|
||||
}
|
||||
} else if (readByMarker.getFullJid() != null) {
|
||||
if (readByMarker.getFullJid().equals(counterpart)) {
|
||||
Log.d(Config.LOGTAG,"trying to add read marker by "+readByMarker.getFullJid()+" to "+body);
|
||||
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() {
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -375,7 +375,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();
|
||||
|
|
Loading…
Reference in a new issue