Skip to content
Snippets Groups Projects
Commit 90f70aca authored by Kateryna Kostiuk's avatar Kateryna Kostiuk
Browse files

user search: fixes

- clear previous result when query return an error
- check if query still valid when search result received
- fix searches for queries with scheme type

Change-Id: I7837dd8318ce4f940da3da2a445f5d69270fd7c9
parent 433027af
No related branches found
No related tags found
No related merge requests found
...@@ -114,7 +114,7 @@ public: ...@@ -114,7 +114,7 @@ public:
ContactModel::ContactInfoMap contacts; ContactModel::ContactInfoMap contacts;
ContactModel::ContactInfoMap searchResult; ContactModel::ContactInfoMap searchResult;
QList<QString> bannedContacts; QList<QString> bannedContacts;
QString query; QString searchQuery;
std::mutex contactsMtx_; std::mutex contactsMtx_;
std::mutex bannedContactsMtx_; std::mutex bannedContactsMtx_;
...@@ -389,7 +389,8 @@ ContactModel::searchContact(const QString& query) ...@@ -389,7 +389,8 @@ ContactModel::searchContact(const QString& query)
pimpl_->searchResult.clear(); pimpl_->searchResult.clear();
auto uri = URI(query); auto uri = URI(query);
pimpl_->query = query; QString uriID = uri.format(URI::Section::USER_INFO | URI::Section::HOSTNAME | URI::Section::PORT);
pimpl_->searchQuery = uriID;
auto uriScheme = uri.schemeType(); auto uriScheme = uri.schemeType();
if (static_cast<int>(uriScheme) > 2 && owner.profileInfo.type == profile::Type::SIP) { if (static_cast<int>(uriScheme) > 2 && owner.profileInfo.type == profile::Type::SIP) {
...@@ -430,6 +431,7 @@ ContactModelPimpl::searchRingContact(const URI& query) ...@@ -430,6 +431,7 @@ ContactModelPimpl::searchRingContact(const URI& query)
} }
if (query.protocolHint() == URI::ProtocolHint::RING) { if (query.protocolHint() == URI::ProtocolHint::RING) {
updateTemporaryMessage("");
// no lookup, this is a ring infoHash // no lookup, this is a ring infoHash
for (auto &i : contacts) { for (auto &i : contacts) {
if (i.profileInfo.uri == uriID) { if (i.profileInfo.uri == uriID) {
...@@ -818,7 +820,7 @@ ContactModelPimpl::slotRegisteredNameFound(const QString& accountId, ...@@ -818,7 +820,7 @@ ContactModelPimpl::slotRegisteredNameFound(const QString& accountId,
contacts[uri].registeredName = registeredName; contacts[uri].registeredName = registeredName;
searchResult.clear(); searchResult.clear();
} else { } else {
if ((query != uri && query != registeredName) || query.isEmpty()) { if ((searchQuery != uri && searchQuery != registeredName) || searchQuery.isEmpty()) {
// we are notified that a previous lookup ended // we are notified that a previous lookup ended
return; return;
} }
...@@ -834,7 +836,7 @@ ContactModelPimpl::slotRegisteredNameFound(const QString& accountId, ...@@ -834,7 +836,7 @@ ContactModelPimpl::slotRegisteredNameFound(const QString& accountId,
return; return;
} }
} }
if ((query != uri && query != registeredName) || query.isEmpty()) { if ((searchQuery != uri && searchQuery != registeredName) || searchQuery.isEmpty()) {
// we are notified that a previous lookup ended // we are notified that a previous lookup ended
return; return;
} }
...@@ -1067,7 +1069,7 @@ ContactModelPimpl::slotProfileReceived(const QString& accountId, const QString& ...@@ -1067,7 +1069,7 @@ ContactModelPimpl::slotProfileReceived(const QString& accountId, const QString&
void void
ContactModelPimpl::slotUserSearchEnded(const QString& accountId, int status, const QString& query, const VectorMapStringString& result) ContactModelPimpl::slotUserSearchEnded(const QString& accountId, int status, const QString& query, const VectorMapStringString& result)
{ {
if (query != query) return; if (searchQuery != query) return;
if (accountId != linked.owner.id) return; if (accountId != linked.owner.id) return;
searchResult.clear(); searchResult.clear();
switch (status) { switch (status) {
...@@ -1075,8 +1077,10 @@ ContactModelPimpl::slotUserSearchEnded(const QString& accountId, int status, con ...@@ -1075,8 +1077,10 @@ ContactModelPimpl::slotUserSearchEnded(const QString& accountId, int status, con
break; break;
case 3:/* ERROR */ case 3:/* ERROR */
updateTemporaryMessage("could not find contact matching search"); updateTemporaryMessage("could not find contact matching search");
emit linked.modelUpdated(query);
return; return;
default: default:
emit linked.modelUpdated(query);
return; return;
} }
updateTemporaryMessage(""); updateTemporaryMessage("");
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment