diff options
author | Daniel Gultsch <daniel@gultsch.de> | 2015-12-27 17:29:32 +0100 |
---|---|---|
committer | Daniel Gultsch <daniel@gultsch.de> | 2015-12-27 17:29:32 +0100 |
commit | c3bdec1ce9a28cadc2cacbe619801e94829118e8 (patch) | |
tree | 60669ee282e01249292888f6032ca2ea501f747b /src/main | |
parent | bcf99db3df27c196caba823b08fb55cf196dc9c8 (diff) |
dedublicate bookmarks
Diffstat (limited to 'src/main')
-rw-r--r-- | src/main/java/eu/siacs/conversations/services/XmppConnectionService.java | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java b/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java index 649ddacd..28d6e355 100644 --- a/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java +++ b/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java @@ -50,6 +50,7 @@ import java.util.Arrays; import java.util.Collection; import java.util.Collections; import java.util.Comparator; +import java.util.HashMap; import java.util.Hashtable; import java.util.Iterator; import java.util.List; @@ -992,13 +993,16 @@ public class XmppConnectionService extends Service implements OnPhoneContactsLoa public void onIqPacketReceived(final Account account, final IqPacket packet) { if (packet.getType() == IqPacket.TYPE.RESULT) { final Element query = packet.query(); - final List<Bookmark> bookmarks = new CopyOnWriteArrayList<>(); + final HashMap<Jid, Bookmark> bookmarks = new HashMap<>(); final Element storage = query.findChild("storage", "storage:bookmarks"); if (storage != null) { for (final Element item : storage.getChildren()) { if (item.getName().equals("conference")) { final Bookmark bookmark = Bookmark.parse(item, account); - bookmarks.add(bookmark); + Bookmark old = bookmarks.put(bookmark.getJid(), bookmark); + if (old != null && old.getBookmarkName() != null && bookmark.getBookmarkName() == null) { + bookmark.setBookmarkName(old.getBookmarkName()); + } Conversation conversation = find(bookmark); if (conversation != null) { conversation.setBookmark(bookmark); @@ -1011,7 +1015,7 @@ public class XmppConnectionService extends Service implements OnPhoneContactsLoa } } } - account.setBookmarks(bookmarks); + account.setBookmarks(new ArrayList<>(bookmarks.values())); } else { Log.d(Config.LOGTAG, account.getJid().toBareJid() + ": could not fetch bookmarks"); } |