always persist current nick (in bookmark and database)
This commit is contained in:
parent
64c956904d
commit
2eb2513615
|
@ -11,6 +11,7 @@ import eu.siacs.conversations.Config;
|
|||
import eu.siacs.conversations.crypto.PgpEngine;
|
||||
import eu.siacs.conversations.crypto.axolotl.AxolotlService;
|
||||
import eu.siacs.conversations.entities.Account;
|
||||
import eu.siacs.conversations.entities.Bookmark;
|
||||
import eu.siacs.conversations.entities.Contact;
|
||||
import eu.siacs.conversations.entities.Conversation;
|
||||
import eu.siacs.conversations.entities.Message;
|
||||
|
@ -74,6 +75,9 @@ public class PresenceParser extends AbstractParser implements
|
|||
mXmppConnectionService.getAvatarService().clear(mucOptions);
|
||||
}
|
||||
mucOptions.setSelf(user);
|
||||
|
||||
mXmppConnectionService.persistSelfNick(user);
|
||||
|
||||
invokeRenameListener(mucOptions, true);
|
||||
}
|
||||
boolean isNew = mucOptions.updateUser(user);
|
||||
|
|
|
@ -2405,6 +2405,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);
|
||||
|
@ -2417,13 +2433,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);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue