From 116e3fd9c5a022bc5fdec383c37a8ad2a26faff8 Mon Sep 17 00:00:00 2001 From: John Preston Date: Mon, 4 Dec 2017 16:08:43 +0400 Subject: [PATCH] Fix admin stars disappearing in members list. --- Telegram/SourceFiles/boxes/peer_list_box.cpp | 2 +- Telegram/SourceFiles/boxes/peer_list_box.h | 8 ++++---- .../info_common_groups_inner_widget.cpp | 9 +++------ .../profile/info_profile_members_controllers.cpp | 4 ++-- .../profile/profile_channel_controllers.cpp | 16 +++++----------- .../profile/profile_channel_controllers.h | 4 ++-- 6 files changed, 17 insertions(+), 26 deletions(-) diff --git a/Telegram/SourceFiles/boxes/peer_list_box.cpp b/Telegram/SourceFiles/boxes/peer_list_box.cpp index 27fad2274..f0d864e71 100644 --- a/Telegram/SourceFiles/boxes/peer_list_box.cpp +++ b/Telegram/SourceFiles/boxes/peer_list_box.cpp @@ -260,7 +260,7 @@ void PeerListController::setSearchNoResultsText(const QString &text) { } } -std::unique_ptr PeerListController::saveState() { +std::unique_ptr PeerListController::saveState() const { return delegate()->peerListSaveState(); } diff --git a/Telegram/SourceFiles/boxes/peer_list_box.h b/Telegram/SourceFiles/boxes/peer_list_box.h index 203998f41..a708601ae 100644 --- a/Telegram/SourceFiles/boxes/peer_list_box.h +++ b/Telegram/SourceFiles/boxes/peer_list_box.h @@ -265,7 +265,7 @@ public: virtual int peerListSelectedRowsCount() = 0; virtual std::vector> peerListCollectSelectedRows() = 0; - virtual std::unique_ptr peerListSaveState() = 0; + virtual std::unique_ptr peerListSaveState() const = 0; virtual void peerListRestoreState( std::unique_ptr state) = 0; virtual ~PeerListDelegate() = default; @@ -299,7 +299,7 @@ public: _delegate = delegate; } - virtual std::unique_ptr saveState() { + virtual std::unique_ptr saveState() const { return nullptr; } virtual void restoreState( @@ -354,7 +354,7 @@ public: return nullptr; } - virtual std::unique_ptr saveState(); + virtual std::unique_ptr saveState() const ; virtual void restoreState( std::unique_ptr state); @@ -714,7 +714,7 @@ public: }); return result; } - std::unique_ptr peerListSaveState() override { + std::unique_ptr peerListSaveState() const override { return _content->saveState(); } void peerListRestoreState( diff --git a/Telegram/SourceFiles/info/common_groups/info_common_groups_inner_widget.cpp b/Telegram/SourceFiles/info/common_groups/info_common_groups_inner_widget.cpp index d4d30687f..5ef0fd85b 100644 --- a/Telegram/SourceFiles/info/common_groups/info_common_groups_inner_widget.cpp +++ b/Telegram/SourceFiles/info/common_groups/info_common_groups_inner_widget.cpp @@ -56,7 +56,7 @@ public: return createRow(peer); } - std::unique_ptr saveState() override; + std::unique_ptr saveState() const override; void restoreState(std::unique_ptr state) override; private: @@ -132,15 +132,12 @@ void ListController::loadMoreRows() { }).send(); } -std::unique_ptr ListController::saveState() { +std::unique_ptr ListController::saveState() const { auto result = PeerListController::saveState(); auto my = std::make_unique(); my->preloadGroupId = _preloadGroupId; my->allLoaded = _allLoaded; - if (auto requestId = base::take(_preloadRequestId)) { - request(requestId).cancel(); - my->wasLoading = true; - } + my->wasLoading = (_preloadRequestId != 0); result->controllerState = std::move(my); return result; } diff --git a/Telegram/SourceFiles/info/profile/info_profile_members_controllers.cpp b/Telegram/SourceFiles/info/profile/info_profile_members_controllers.cpp index 7af15435c..06f0e37a4 100644 --- a/Telegram/SourceFiles/info/profile/info_profile_members_controllers.cpp +++ b/Telegram/SourceFiles/info/profile/info_profile_members_controllers.cpp @@ -61,7 +61,7 @@ public: std::unique_ptr createRestoredRow( not_null peer) override; - std::unique_ptr saveState() override; + std::unique_ptr saveState() const override; void restoreState(std::unique_ptr state) override; private: @@ -147,7 +147,7 @@ void ChatMembersController::sortByOnline() { refreshOnlineCount(); } -std::unique_ptr ChatMembersController::saveState() { +std::unique_ptr ChatMembersController::saveState() const { auto result = PeerListController::saveState(); auto my = std::make_unique(); using Flag = Notify::PeerUpdate::Flag; diff --git a/Telegram/SourceFiles/profile/profile_channel_controllers.cpp b/Telegram/SourceFiles/profile/profile_channel_controllers.cpp index 5d8bfc824..0ad0ed2f7 100644 --- a/Telegram/SourceFiles/profile/profile_channel_controllers.cpp +++ b/Telegram/SourceFiles/profile/profile_channel_controllers.cpp @@ -253,19 +253,16 @@ std::unique_ptr ParticipantsBoxController::createRestoredRow( return nullptr; } -std::unique_ptr ParticipantsBoxController::saveState() { +std::unique_ptr ParticipantsBoxController::saveState() const { Expects(_role == Role::Profile); auto result = PeerListController::saveState(); auto my = std::make_unique(); - my->additional = std::move(_additional); + my->additional = _additional; my->offset = _offset; my->allLoaded = _allLoaded; - if (auto requestId = base::take(_loadRequestId)) { - request(requestId).cancel(); - my->wasLoading = true; - } + my->wasLoading = (_loadRequestId != 0); if (auto search = searchController()) { my->searchState = search->saveState(); } @@ -982,16 +979,13 @@ void ParticipantsBoxSearchController::searchQuery(const QString &query) { } } -auto ParticipantsBoxSearchController::saveState() +auto ParticipantsBoxSearchController::saveState() const -> std::unique_ptr { auto result = std::make_unique(); result->query = _query; result->offset = _offset; result->allLoaded = _allLoaded; - if (auto requestId = base::take(_requestId)) { - request(requestId).cancel(); - result->wasLoading = true; - } + result->wasLoading = (_requestId != 0); return std::move(result); } diff --git a/Telegram/SourceFiles/profile/profile_channel_controllers.h b/Telegram/SourceFiles/profile/profile_channel_controllers.h index cf71eab16..24a7968da 100644 --- a/Telegram/SourceFiles/profile/profile_channel_controllers.h +++ b/Telegram/SourceFiles/profile/profile_channel_controllers.h @@ -84,7 +84,7 @@ public: std::unique_ptr createRestoredRow( not_null peer) override; - std::unique_ptr saveState() override; + std::unique_ptr saveState() const override; void restoreState(std::unique_ptr state) override; // Callback(not_null) @@ -171,7 +171,7 @@ public: bool isLoading() override; bool loadMoreRows() override; - std::unique_ptr saveState() override; + std::unique_ptr saveState() const override; void restoreState(std::unique_ptr state) override; private: