Commit 90f70aca authored by Kateryna Kostiuk's avatar Kateryna Kostiuk

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
......@@ -114,7 +114,7 @@ public:
ContactModel::ContactInfoMap contacts;
ContactModel::ContactInfoMap searchResult;
QList<QString> bannedContacts;
QString query;
QString searchQuery;
std::mutex contactsMtx_;
std::mutex bannedContactsMtx_;
......@@ -389,7 +389,8 @@ ContactModel::searchContact(const QString& query)
pimpl_->searchResult.clear();
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();
if (static_cast<int>(uriScheme) > 2 && owner.profileInfo.type == profile::Type::SIP) {
......@@ -430,6 +431,7 @@ ContactModelPimpl::searchRingContact(const URI& query)
}
if (query.protocolHint() == URI::ProtocolHint::RING) {
updateTemporaryMessage("");
// no lookup, this is a ring infoHash
for (auto &i : contacts) {
if (i.profileInfo.uri == uriID) {
......@@ -818,7 +820,7 @@ ContactModelPimpl::slotRegisteredNameFound(const QString& accountId,
contacts[uri].registeredName = registeredName;
searchResult.clear();
} else {
if ((query != uri && query != registeredName) || query.isEmpty()) {
if ((searchQuery != uri && searchQuery != registeredName) || searchQuery.isEmpty()) {
// we are notified that a previous lookup ended
return;
}
......@@ -834,7 +836,7 @@ ContactModelPimpl::slotRegisteredNameFound(const QString& accountId,
return;
}
}
if ((query != uri && query != registeredName) || query.isEmpty()) {
if ((searchQuery != uri && searchQuery != registeredName) || searchQuery.isEmpty()) {
// we are notified that a previous lookup ended
return;
}
......@@ -1067,16 +1069,18 @@ ContactModelPimpl::slotProfileReceived(const QString& accountId, const QString&
void
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;
searchResult.clear();
switch (status) {
switch (status) {
case 0:/* SUCCESS */
break;
case 3:/* ERROR */
updateTemporaryMessage("could not find contact matching search");
emit linked.modelUpdated(query);
return;
default:
emit linked.modelUpdated(query);
return;
}
updateTemporaryMessage("");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment