diff options
Diffstat (limited to 'Swift/Controllers/Chat/UserSearchController.cpp')
-rw-r--r-- | Swift/Controllers/Chat/UserSearchController.cpp | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/Swift/Controllers/Chat/UserSearchController.cpp b/Swift/Controllers/Chat/UserSearchController.cpp index f259a9a..f1849c9 100644 --- a/Swift/Controllers/Chat/UserSearchController.cpp +++ b/Swift/Controllers/Chat/UserSearchController.cpp @@ -164,71 +164,72 @@ void UserSearchController::handleSearch(boost::shared_ptr<SearchPayload> fields, void UserSearchController::handleSearchResponse(boost::shared_ptr<SearchPayload> resultsPayload, ErrorPayload::ref error) { if (error || !resultsPayload) { window_->setSearchError(true); return; } std::vector<UserSearchResult> results; if (resultsPayload->getForm()) { window_->setResultsForm(resultsPayload->getForm()); } else { foreach (SearchPayload::Item item, resultsPayload->getItems()) { JID jid(item.jid); std::map<std::string, std::string> fields; fields["first"] = item.first; fields["last"] = item.last; fields["nick"] = item.nick; fields["email"] = item.email; UserSearchResult result(jid, fields); results.push_back(result); } window_->setResults(results); } } 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) { const std::vector<JID> existingJIDs = window_->getJIDs(); - std::vector<Contact::ref> suggestions = contactSuggester_->getSuggestions(text); + std::vector<Contact::ref> suggestions = contactSuggester_->getSuggestions(text, false); + /* do not suggest contacts that have already been added to the chat list */ 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)); } void UserSearchController::handleAvatarChanged(const JID& jid) { handleJIDUpdateRequested(std::vector<JID>(1, jid)); } void UserSearchController::handlePresenceChanged(Presence::ref presence) { handleJIDUpdateRequested(std::vector<JID>(1, presence->getFrom().toBare())); } void UserSearchController::handleJIDUpdateRequested(const std::vector<JID>& jids) { |