diff options
-rw-r--r-- | indra/newview/llgroupmgr.cpp | 55 | ||||
-rw-r--r-- | indra/newview/llgroupmgr.h | 6 | ||||
-rw-r--r-- | indra/newview/llpanelgrouproles.cpp | 5 |
3 files changed, 50 insertions, 16 deletions
diff --git a/indra/newview/llgroupmgr.cpp b/indra/newview/llgroupmgr.cpp index ec2002d8c5..76d3e3e049 100644 --- a/indra/newview/llgroupmgr.cpp +++ b/indra/newview/llgroupmgr.cpp @@ -2145,9 +2145,11 @@ void LLGroupMgr::processGroupBanRequest(const LLSD& content) LLGroupMgr::getInstance()->notifyObservers(GC_BANLIST); } -void LLGroupMgr::groupMembersRequestCoro(std::string url, LLUUID group_id, U32 page_size, U32 page_start, std::string sort_column) +void LLGroupMgr::groupMembersRequestCoro(std::string url, LLUUID group_id, U32 page_size, U32 page_start, U32 sort_column, bool sort_descending) { - LL_INFOS("GrpMgr") << "group_id: '" << group_id << "', sort_column: '" << sort_column << "', page_size: " << page_size << ", page_start: " << page_start << LL_ENDL; + LL_INFOS("GrpMgr") << "group_id: '" << group_id << "'" + << ", page_size: " << page_size << ", page_start: " << page_start + << ", sort_column: " << sort_column << ", sort_descending: " << sort_descending << LL_ENDL; LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("groupMembersRequest", httpPolicy)); @@ -2156,6 +2158,7 @@ void LLGroupMgr::groupMembersRequestCoro(std::string url, LLUUID group_id, U32 p LLSD postData = LLSD::emptyMap(); postData["group_id"] = group_id; + if (page_size) { postData["page_size"] = LLSD::Integer(page_size); @@ -2163,12 +2166,19 @@ void LLGroupMgr::groupMembersRequestCoro(std::string url, LLUUID group_id, U32 p { postData["page_start"] = LLSD::Integer(page_start); } - if (!sort_column.empty()) + } + + if (sort_column) + { + postData["sort_column"] = LLSD::Integer(sort_column); + if (sort_descending) { - postData["sort_column"] = sort_column; + postData["sort_descending"] = 1; } } + mMemberRequestInFlight = true; + LLSD response = httpAdapter->postAndSuspend(httpRequest, url, postData, httpOpts); mMemberRequestInFlight = false; @@ -2183,10 +2193,10 @@ void LLGroupMgr::groupMembersRequestCoro(std::string url, LLUUID group_id, U32 p } response.erase(LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS); - processCapGroupMembersResponse(response, page_size, page_start, sort_column); + processCapGroupMembersResponse(response, url, page_size, page_start, sort_column, sort_descending); } -void LLGroupMgr::sendCapGroupMembersRequest(const LLUUID& group_id, U32 page_size, U32 page_start, const std::string& sort_column) +void LLGroupMgr::sendCapGroupMembersRequest(const LLUUID& group_id, U32 page_size, U32 page_start, const std::string& sort_column_name, bool sort_descending) { static U32 lastGroupMemberRequestFrame = 0; @@ -2195,6 +2205,10 @@ void LLGroupMgr::sendCapGroupMembersRequest(const LLUUID& group_id, U32 page_siz if ((lastGroupMemberRequestFrame == gFrameCount) || mMemberRequestInFlight) return; + LL_INFOS("GrpMgr") << "group_id: '" << group_id << "'" + << ", page_size: " << page_size << ", page_start: " << page_start + << ", sort_column_name: '" << sort_column_name << "', sort_descending: " << sort_descending << LL_ENDL; + LLViewerRegion* currentRegion = gAgent.getRegion(); // Thank you FS:Ansariel! if (!currentRegion) @@ -2226,18 +2240,34 @@ void LLGroupMgr::sendCapGroupMembersRequest(const LLUUID& group_id, U32 page_siz lastGroupMemberRequestFrame = gFrameCount; - mMemberRequestInFlight = true; + U32 sort_column = 0; // No sorting by default + if (!sort_column_name.empty()) + { + static const std::vector<std::string> column_names = { "name", "donated", "online", "title" }; + auto it = std::find(column_names.begin(), column_names.end(), sort_column_name); + if (it == column_names.end()) + { + LL_WARNS("GrpMgr") << "Invalid column name: '" << sort_column_name << "'" << LL_ENDL; + } + else + { + // Use offset (1) because 0 means "no sorting" + sort_column = 1 + (U32)std::distance(column_names.begin(), it); + } + } LLCoros::instance().launch("LLGroupMgr::groupMembersRequestCoro", [&]() { - groupMembersRequestCoro(cap_url, group_id, page_size, page_start, sort_column); + groupMembersRequestCoro(cap_url, group_id, page_size, page_start, sort_column, sort_descending); }); } -void LLGroupMgr::processCapGroupMembersResponse(const LLSD& response, U32 page_size, U32 page_start, const std::string& sort_column) +void LLGroupMgr::processCapGroupMembersResponse(const LLSD& response, const std::string& url, U32 page_size, U32 page_start, U32 sort_column, bool sort_descending) { LLUUID group_id = response["group_id"].asUUID(); - LL_INFOS("GrpMgr") << "group_id: '" << group_id << "', sort_column: '" << sort_column << "', page_size: " << page_size << ", page_start: " << page_start << LL_ENDL; + LL_INFOS("GrpMgr") << "group_id: '" << group_id << "'" + << ", page_size: " << page_size << ", page_start: " << page_start + << ", sort_column: " << sort_column << ", sort_descending: " << sort_descending << LL_ENDL; // Did we get anything in content? if (!response.size()) @@ -2357,7 +2387,10 @@ void LLGroupMgr::processCapGroupMembersResponse(const LLSD& response, U32 page_s if (page_size && members_loaded >= page_size && member_count > members_before) { - sendCapGroupMembersRequest(group_id, page_size, member_count, sort_column); + LLCoros::instance().launch("LLGroupMgr::groupMembersRequestCoro", [&]() + { + groupMembersRequestCoro(url, group_id, page_size, page_start, sort_column, sort_descending); + }); } // Make the role-member data request diff --git a/indra/newview/llgroupmgr.h b/indra/newview/llgroupmgr.h index f96c5ccc14..21cf4a62b6 100644 --- a/indra/newview/llgroupmgr.h +++ b/indra/newview/llgroupmgr.h @@ -414,7 +414,7 @@ public: void sendCapGroupMembersRequest(const LLUUID& group_id, - U32 page_size = 0, U32 page_start = 0, const std::string& sort_column = LLStringUtil::null); + U32 page_size = 0, U32 page_start = 0, const std::string& sort_column_name = LLStringUtil::null, bool sort_descending = false); void cancelGroupRoleChanges(const LLUUID& group_id); @@ -437,8 +437,8 @@ public: void clearGroupData(const LLUUID& group_id); private: - void groupMembersRequestCoro(std::string url, LLUUID group_id, U32 page_size, U32 page_start, std::string sort_column); - void processCapGroupMembersResponse(const LLSD& response, U32 page_size, U32 page_start, const std::string& sort_column); + void groupMembersRequestCoro(std::string url, LLUUID group_id, U32 page_size, U32 page_start, U32 sort_column, bool sort_descending); + void processCapGroupMembersResponse(const LLSD& response, const std::string& url, U32 page_size, U32 page_start, U32 sort_column, bool sort_descending); void getGroupBanRequestCoro(std::string url, LLUUID group_id); void postGroupBanRequestCoro(std::string url, LLUUID group_id, U32 action, uuid_vec_t ban_list, bool update); diff --git a/indra/newview/llpanelgrouproles.cpp b/indra/newview/llpanelgrouproles.cpp index 864d73683e..4404efff98 100644 --- a/indra/newview/llpanelgrouproles.cpp +++ b/indra/newview/llpanelgrouproles.cpp @@ -1361,8 +1361,9 @@ void LLPanelGroupMembersSubTab::activate() if (!gdatap || !gdatap->isMemberDataComplete()) { const U32 page_size = 50; - std::string sort_column = mMembersList->getSortColumnName(); - LLGroupMgr::getInstance()->sendCapGroupMembersRequest(mGroupID, page_size, 0, sort_column); + std::string sort_column_name = mMembersList->getSortColumnName(); + bool sort_descending = !mMembersList->getSortAscending(); + LLGroupMgr::getInstance()->sendCapGroupMembersRequest(mGroupID, page_size, 0, sort_column_name, sort_descending); } if (!gdatap || !gdatap->isRoleMemberDataComplete()) |