diff options
Diffstat (limited to 'Swift/Controllers')
| -rw-r--r-- | Swift/Controllers/Chat/UserSearchController.cpp | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/Swift/Controllers/Chat/UserSearchController.cpp b/Swift/Controllers/Chat/UserSearchController.cpp index 8503609..12c6777 100644 --- a/Swift/Controllers/Chat/UserSearchController.cpp +++ b/Swift/Controllers/Chat/UserSearchController.cpp @@ -188,19 +188,36 @@ void UserSearchController::handleSearchResponse(boost::shared_ptr<SearchPayload> void UserSearchController::handleNameSuggestionRequest(const JID &jid) { suggestionsJID_= jid; VCard::ref vcard = vcardManager_->getVCardAndRequestWhenNeeded(jid); if (vcard) { handleVCardChanged(jid, vcard); } } void UserSearchController::handleContactSuggestionsRequested(std::string text) { - window_->setContactSuggestions(contactSuggester_->getSuggestions(text)); + const std::vector<JID> existingJIDs = window_->getJIDs(); + std::vector<Contact::ref> suggestions = contactSuggester_->getSuggestions(text); + std::vector<Contact::ref>::iterator i = suggestions.begin(); + while (i != suggestions.end()) { + bool found = false; + foreach (const JID& jid, existingJIDs) { + if ((*i)->jid == jid) { + found = true; + break; + } + } + if (found) { + i = suggestions.erase(i); + } else { + i++; + } + } + window_->setContactSuggestions(suggestions); } void UserSearchController::handleVCardChanged(const JID& jid, VCard::ref vcard) { if (jid == suggestionsJID_) { window_->setNameSuggestions(ContactEditController::nameSuggestionsFromVCard(vcard)); suggestionsJID_ = JID(); } handleJIDUpdateRequested(std::vector<JID>(1, jid)); } |
Swift