diff options
Diffstat (limited to 'Swift')
-rw-r--r-- | Swift/Controllers/RosterController.cpp | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/Swift/Controllers/RosterController.cpp b/Swift/Controllers/RosterController.cpp index ea7c7bb..9364e93 100644 --- a/Swift/Controllers/RosterController.cpp +++ b/Swift/Controllers/RosterController.cpp @@ -131,19 +131,25 @@ void RosterController::handleOnJIDRemoved(const JID& jid) { roster_->removeContact(jid); } -void RosterController::handleOnJIDUpdated(const JID& jid, const String& oldName, const std::vector<String> oldGroups) { +void RosterController::handleOnJIDUpdated(const JID& jid, const String& oldName, const std::vector<String> passedOldGroups) { if (oldName != xmppRoster_->getNameForJID(jid)) { + handleOnJIDRemoved(jid); handleOnJIDAdded(jid); + //FIXME: use a roster visitor to avoid losing presence. return; } std::vector<String> groups = xmppRoster_->getGroupsForJID(jid); + std::vector<String> oldGroups = passedOldGroups; String name = xmppRoster_->getNameForJID(jid); String contactsGroup = "Contacts"; + if (oldGroups.empty()) { + oldGroups.push_back(contactsGroup); + } if (groups.empty()) { groups.push_back(contactsGroup); } foreach(const String& group, groups) { - if (std::find(oldGroups.begin(), oldGroups.end(), jid) == oldGroups.end()) { + if (std::find(oldGroups.begin(), oldGroups.end(), group) == oldGroups.end()) { roster_->addContact(jid, xmppRoster_->getNameForJID(jid), group); } } |