diff options
author | Christian Schneppe <christian@pix-art.de> | 2018-02-10 20:19:28 +0100 |
---|---|---|
committer | Christian Schneppe <christian@pix-art.de> | 2018-02-10 20:19:28 +0100 |
commit | 0325594075c2844580cd3d92943aa06f1832e4d4 (patch) | |
tree | 91c983edd60634ae8062810bc1f4b35fad273b3e /src/main | |
parent | 356fb36bca8b41a7709d4683b84b0a0e168a9a61 (diff) |
always persist current nick (in bookmark and database)
Diffstat (limited to 'src/main')
-rw-r--r-- | src/main/java/de/pixart/messenger/parser/PresenceParser.java | 1 | ||||
-rw-r--r-- | src/main/java/de/pixart/messenger/services/XmppConnectionService.java | 23 |
2 files changed, 17 insertions, 7 deletions
diff --git a/src/main/java/de/pixart/messenger/parser/PresenceParser.java b/src/main/java/de/pixart/messenger/parser/PresenceParser.java index 13dd70106..ae2cdc4ad 100644 --- a/src/main/java/de/pixart/messenger/parser/PresenceParser.java +++ b/src/main/java/de/pixart/messenger/parser/PresenceParser.java @@ -72,6 +72,7 @@ public class PresenceParser extends AbstractParser implements mXmppConnectionService.getAvatarService().clear(mucOptions); } mucOptions.setSelf(user); + mXmppConnectionService.persistSelfNick(user); invokeRenameListener(mucOptions, true); } boolean isNew = mucOptions.updateUser(user); diff --git a/src/main/java/de/pixart/messenger/services/XmppConnectionService.java b/src/main/java/de/pixart/messenger/services/XmppConnectionService.java index b436d9ec9..2a458414c 100644 --- a/src/main/java/de/pixart/messenger/services/XmppConnectionService.java +++ b/src/main/java/de/pixart/messenger/services/XmppConnectionService.java @@ -2591,6 +2591,22 @@ public class XmppConnectionService extends Service { return false; } + public void persistSelfNick(MucOptions.User self) { + final Conversation conversation = self.getConversation(); + Jid full = self.getFullJid(); + if (!full.equals(conversation.getJid())) { + Log.d(Config.LOGTAG, "nick changed. updating"); + conversation.setContactJid(full); + databaseBackend.updateConversation(conversation); + } + + Bookmark bookmark = conversation.getBookmark(); + if (bookmark != null && !full.getResourcepart().equals(bookmark.getNick())) { + bookmark.setNick(full.getResourcepart()); + pushBookmarks(bookmark.getAccount()); + } + } + public boolean renameInMuc(final Conversation conversation, final String nick, final UiCallback<Conversation> callback) { final MucOptions options = conversation.getMucOptions(); final Jid joinJid = options.createJoinJid(nick); @@ -2603,13 +2619,6 @@ public class XmppConnectionService extends Service { @Override public void onSuccess() { - conversation.setContactJid(joinJid); - databaseBackend.updateConversation(conversation); - Bookmark bookmark = conversation.getBookmark(); - if (bookmark != null) { - bookmark.setNick(nick); - pushBookmarks(bookmark.getAccount()); - } callback.success(conversation); } |