diff options
author | Kevin Smith <git@kismith.co.uk> | 2011-05-12 16:02:33 (GMT) |
---|---|---|
committer | Kevin Smith <git@kismith.co.uk> | 2011-05-12 16:02:33 (GMT) |
commit | 8a18d6692c246adf14a8b0aec270f9b96d1b4baf (patch) | |
tree | e2f327fa3f1bb6486949e0be3dfec25f8b855d9e | |
parent | e8c0dfa8173b3e6bf1b8274d183f633585a0bec5 (diff) | |
download | swift-8a18d6692c246adf14a8b0aec270f9b96d1b4baf.zip swift-8a18d6692c246adf14a8b0aec270f9b96d1b4baf.tar.bz2 |
Remove duplicate entries from the recent chat list.
Resolves: #860
-rw-r--r-- | Swift/Controllers/Chat/ChatsManager.cpp | 17 | ||||
-rw-r--r-- | Swift/Controllers/Chat/ChatsManager.h | 2 | ||||
-rw-r--r-- | Swift/Controllers/UIInterfaces/ChatListWindow.h | 2 |
3 files changed, 16 insertions, 5 deletions
diff --git a/Swift/Controllers/Chat/ChatsManager.cpp b/Swift/Controllers/Chat/ChatsManager.cpp index b60f9a3..0af1a81 100644 --- a/Swift/Controllers/Chat/ChatsManager.cpp +++ b/Swift/Controllers/Chat/ChatsManager.cpp @@ -129,9 +129,9 @@ void ChatsManager::loadRecents() { bool isMUC = recent[2] == "true"; std::string nick(recent[3]); ChatListWindow::Chat chat(jid, nickResolver_->jidToNick(jid), activity, isMUC, nick); - recentChats_.push_back(chat); - chatListWindow_->setRecents(recentChats_); + prependRecent(chat); } + chatListWindow_->setRecents(recentChats_); } void ChatsManager::setupBookmarks() { @@ -171,12 +171,21 @@ void ChatsManager::handleChatActivity(const JID& jid, const std::string& activit /* FIXME: MUC use requires changes here. */ ChatListWindow::Chat chat(jid, nickResolver_->jidToNick(jid), activity, false); /* FIXME: handle nick changes */ - recentChats_.erase(std::remove(recentChats_.begin(), recentChats_.end(), chat), recentChats_.end()); - recentChats_.push_front(chat); + appendRecent(chat); chatListWindow_->setRecents(recentChats_); saveRecents(); } +void ChatsManager::appendRecent(const ChatListWindow::Chat& chat) { + recentChats_.erase(std::remove(recentChats_.begin(), recentChats_.end(), chat), recentChats_.end()); + recentChats_.push_front(chat); +} + +void ChatsManager::prependRecent(const ChatListWindow::Chat& chat) { + recentChats_.erase(std::remove(recentChats_.begin(), recentChats_.end(), chat), recentChats_.end()); + recentChats_.push_back(chat); +} + void ChatsManager::handleUserLeftMUC(MUCController* mucController) { std::map<JID, MUCController*>::iterator it; for (it = mucControllers_.begin(); it != mucControllers_.end(); it++) { diff --git a/Swift/Controllers/Chat/ChatsManager.h b/Swift/Controllers/Chat/ChatsManager.h index f489034..170e87c 100644 --- a/Swift/Controllers/Chat/ChatsManager.h +++ b/Swift/Controllers/Chat/ChatsManager.h @@ -64,6 +64,8 @@ namespace Swift { void handleUserLeftMUC(MUCController* mucController); void handleBookmarksReady(); void handleChatActivity(const JID& jid, const std::string& activity); + void appendRecent(const ChatListWindow::Chat& chat); + void prependRecent(const ChatListWindow::Chat& chat); void setupBookmarks(); void loadRecents(); void saveRecents(); diff --git a/Swift/Controllers/UIInterfaces/ChatListWindow.h b/Swift/Controllers/UIInterfaces/ChatListWindow.h index f717684..a52f24d 100644 --- a/Swift/Controllers/UIInterfaces/ChatListWindow.h +++ b/Swift/Controllers/UIInterfaces/ChatListWindow.h @@ -17,7 +17,7 @@ namespace Swift { public: Chat(const JID& jid, const std::string& chatName, const std::string& activity, bool isMUC, const std::string& nick = "") : jid(jid), chatName(chatName), activity(activity), isMUC(isMUC), nick(nick) {} /** Assume that nicks aren't important for equality */ - bool operator==(const Chat& other) const {return jid == other.jid && isMUC == other.isMUC;}; + bool operator==(const Chat& other) const {return jid.toBare() == other.jid.toBare() && isMUC == other.isMUC;}; JID jid; std::string chatName; std::string activity; |