From 120d9c16fa08add7d5945cdcbc7af707a1d8cf2b Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Wed, 7 Dec 2022 03:39:35 +0200 Subject: SL-18776 Avatar picker search not updated on http error --- indra/newview/llfloateravatarpicker.cpp | 130 +++++++++++++++++--------------- 1 file changed, 71 insertions(+), 59 deletions(-) (limited to 'indra/newview') diff --git a/indra/newview/llfloateravatarpicker.cpp b/indra/newview/llfloateravatarpicker.cpp index 0186c4aebe..7cd2e0146a 100644 --- a/indra/newview/llfloateravatarpicker.cpp +++ b/indra/newview/llfloateravatarpicker.cpp @@ -428,13 +428,18 @@ void LLFloaterAvatarPicker::findCoro(std::string url, LLUUID queryID, std::strin if (status || (status == LLCore::HttpStatus(HTTP_BAD_REQUEST))) { - LLFloaterAvatarPicker* floater = - LLFloaterReg::findTypedInstance("avatar_picker", name); - if (floater) - { - result.erase(LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS); - floater->processResponse(queryID, result); - } + result.erase(LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS); + } + else + { + result["failure_reason"] = status.toString(); + } + + LLFloaterAvatarPicker* floater = + LLFloaterReg::findTypedInstance("avatar_picker", name); + if (floater) + { + floater->processResponse(queryID, result); } } @@ -672,59 +677,66 @@ void LLFloaterAvatarPicker::processResponse(const LLUUID& query_id, const LLSD& { LLScrollListCtrl* search_results = getChild("SearchResults"); - LLSD agents = content["agents"]; - - // clear "Searching" label on first results - search_results->deleteAllItems(); - - LLSD item; - LLSD::array_const_iterator it = agents.beginArray(); - for ( ; it != agents.endArray(); ++it) - { - const LLSD& row = *it; - if (row["id"].asUUID() != gAgent.getID() || !mExcludeAgentFromSearchResults) - { - item["id"] = row["id"]; - LLSD& columns = item["columns"]; - columns[0]["column"] = "name"; - columns[0]["value"] = row["display_name"]; - columns[1]["column"] = "username"; - columns[1]["value"] = row["username"]; - search_results->addElement(item); - - // add the avatar name to our list - LLAvatarName avatar_name; - avatar_name.fromLLSD(row); - sAvatarNameMap[row["id"].asUUID()] = avatar_name; - } - } + // clear "Searching" label on first results + search_results->deleteAllItems(); - if (search_results->isEmpty()) - { - std::string name = "'" + getChild("Edit")->getValue().asString() + "'"; - LLSD item; - item["id"] = LLUUID::null; - item["columns"][0]["column"] = "name"; - item["columns"][0]["value"] = name; - item["columns"][1]["column"] = "username"; - item["columns"][1]["value"] = getString("not_found_text"); - search_results->addElement(item); - search_results->setEnabled(false); - getChildView("ok_btn")->setEnabled(false); - } - else - { - getChildView("ok_btn")->setEnabled(true); - search_results->setEnabled(true); - search_results->sortByColumnIndex(1, TRUE); - std::string text = getChild("Edit")->getValue().asString(); - if (!search_results->selectItemByLabel(text, TRUE, 1)) - { - search_results->selectFirstItem(); - } - onList(); - search_results->setFocus(TRUE); - } + if (content.has("agents")) + { + LLSD agents = content["agents"]; + + LLSD item; + LLSD::array_const_iterator it = agents.beginArray(); + for (; it != agents.endArray(); ++it) + { + const LLSD& row = *it; + if (row["id"].asUUID() != gAgent.getID() || !mExcludeAgentFromSearchResults) + { + item["id"] = row["id"]; + LLSD& columns = item["columns"]; + columns[0]["column"] = "name"; + columns[0]["value"] = row["display_name"]; + columns[1]["column"] = "username"; + columns[1]["value"] = row["username"]; + search_results->addElement(item); + + // add the avatar name to our list + LLAvatarName avatar_name; + avatar_name.fromLLSD(row); + sAvatarNameMap[row["id"].asUUID()] = avatar_name; + } + } + + if (search_results->isEmpty()) + { + std::string name = "'" + getChild("Edit")->getValue().asString() + "'"; + LLSD item; + item["id"] = LLUUID::null; + item["columns"][0]["column"] = "name"; + item["columns"][0]["value"] = name; + item["columns"][1]["column"] = "username"; + item["columns"][1]["value"] = getString("not_found_text"); + search_results->addElement(item); + search_results->setEnabled(false); + getChildView("ok_btn")->setEnabled(false); + } + else + { + getChildView("ok_btn")->setEnabled(true); + search_results->setEnabled(true); + search_results->sortByColumnIndex(1, TRUE); + std::string text = getChild("Edit")->getValue().asString(); + if (!search_results->selectItemByLabel(text, TRUE, 1)) + { + search_results->selectFirstItem(); + } + onList(); + search_results->setFocus(TRUE); + } + } + else if (content.has("failure_reason")) + { + getChild("SearchResults")->setCommentText(content["failure_reason"].asString()); + } } } -- cgit v1.2.3