diff --git a/src/client/http/SearchSavesRequest.cpp b/src/client/http/SearchSavesRequest.cpp index 09f67f273..edfe165cb 100644 --- a/src/client/http/SearchSavesRequest.cpp +++ b/src/client/http/SearchSavesRequest.cpp @@ -83,6 +83,7 @@ namespace http SearchSavesRequest::SearchSavesRequest(int start, int count, ByteString query, Period period, Sort sort, Category category) : APIRequest(Url(start, count, query, period, sort, category), authUse, false) { + includesFp = category == categoryNone && period == http::allSaves && sort == http::sortByVotes && query == ""; } std::pair>> SearchSavesRequest::Finish() diff --git a/src/client/http/SearchSavesRequest.h b/src/client/http/SearchSavesRequest.h index 3ce53d29a..6367469f5 100644 --- a/src/client/http/SearchSavesRequest.h +++ b/src/client/http/SearchSavesRequest.h @@ -7,9 +7,16 @@ namespace http { class SearchSavesRequest : public APIRequest { + bool includesFp; + public: SearchSavesRequest(int start, int count, ByteString query, Period period, Sort sort, Category category); + bool GetIncludesFp() const + { + return includesFp; + } + std::pair>> Finish(); }; } diff --git a/src/gui/search/SearchModel.cpp b/src/gui/search/SearchModel.cpp index 6edc0867a..d8ce2365e 100644 --- a/src/gui/search/SearchModel.cpp +++ b/src/gui/search/SearchModel.cpp @@ -15,6 +15,7 @@ SearchModel::SearchModel(): currentSort(http::sortByVotes), currentPage(1), resultCount(0), + includesFp(false), showOwn(false), showFavourite(false), showTags(true) @@ -37,6 +38,7 @@ void SearchModel::BeginSearchSaves(int start, int count, String query, http::Per resultCount = 0; searchSaves = std::make_unique(start, count, query.ToUtf8(), period, sort, category); searchSaves->Start(); + includesFp = searchSaves->GetIncludesFp(); } std::vector> SearchModel::EndSearchSaves() @@ -96,10 +98,18 @@ bool SearchModel::UpdateSaveList(int pageNumber, String query) //resultCount = 0; currentPage = pageNumber; - if(pageNumber == 1 && !showOwn && !showFavourite && currentPeriod == http::allSaves && currentSort == http::sortByVotes && query == "") - SetShowTags(true); - else - SetShowTags(false); + auto category = http::categoryNone; + if (showFavourite) + { + category = http::categoryFavourites; + } + if (showOwn && Client::Ref().GetAuthUser().UserID) + { + category = http::categoryMyOwn; + } + BeginSearchSaves((currentPage-1)*20, 20, lastQuery, currentPeriod, currentSort, category); + + SetShowTags(includesFp && pageNumber == 1); notifySaveListChanged(); notifyTagListChanged(); @@ -112,16 +122,6 @@ bool SearchModel::UpdateSaveList(int pageNumber, String query) BeginGetTags(0, 24, ""); } - auto category = http::categoryNone; - if (showFavourite) - { - category = http::categoryFavourites; - } - if (showOwn && Client::Ref().GetAuthUser().UserID) - { - category = http::categoryMyOwn; - } - BeginSearchSaves((currentPage-1)*20, 20, lastQuery, currentPeriod, currentSort, category); return true; } return false; @@ -307,8 +307,5 @@ void SearchModel::notifySelectedChanged() int SearchModel::GetPageCount() { - if (!showOwn && !showFavourite && currentPeriod == http::allSaves && currentSort == http::sortByVotes && lastQuery == "") - return std::max(1, (int)(ceil(resultCount/20.0f))+1); //add one for front page (front page saves are repeated twice) - else - return std::max(1, (int)(ceil(resultCount/20.0f))); + return std::max(1, (int)(ceil(resultCount/20.0f)) + (includesFp ? 1 : 0)); //add one for front page (front page saves are repeated twice) } diff --git a/src/gui/search/SearchModel.h b/src/gui/search/SearchModel.h index 0acefc8ac..e0d323e7f 100644 --- a/src/gui/search/SearchModel.h +++ b/src/gui/search/SearchModel.h @@ -36,6 +36,7 @@ private: std::vector > tagList; int currentPage; int resultCount; + bool includesFp; bool showOwn; bool showFavourite; bool showTags;