From ab16e8e0830a47af0488e46f213e32ba2abc5805 Mon Sep 17 00:00:00 2001 From: John Preston Date: Fri, 20 Mar 2020 17:12:13 +0400 Subject: [PATCH] Improve archive <-> filter navigation. --- .../dialogs/dialogs_inner_widget.cpp | 20 +++++++++++-------- .../window/window_session_controller.cpp | 4 ++++ 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/Telegram/SourceFiles/dialogs/dialogs_inner_widget.cpp b/Telegram/SourceFiles/dialogs/dialogs_inner_widget.cpp index 8ccc03aac..f8de2ed16 100644 --- a/Telegram/SourceFiles/dialogs/dialogs_inner_widget.cpp +++ b/Telegram/SourceFiles/dialogs/dialogs_inner_widget.cpp @@ -382,7 +382,6 @@ void InnerWidget::changeOpenedFolder(Data::Folder *folder) { //const auto lastMousePosition = _lastMousePosition; clearSelection(); _openedFolder = folder; - _filterId = _openedFolder ? 0 : _controller->activeChatsFilterCurrent(); refreshWithCollapsedRows(true); // This doesn't work, because we clear selection in leaveEvent on hide. //if (mouseSelection && lastMousePosition) { @@ -2258,9 +2257,7 @@ void InnerWidget::searchInChat(Key key, UserData *from) { _searchInChat = key; _searchFromUser = from; if (_searchInChat) { - if (_openedFolder) { - changeOpenedFolder(nullptr); - } + _controller->closeFolder(); onHashtagFilterUpdate(QStringRef()); _cancelSearchInChat->show(); refreshSearchInChatLabel(); @@ -2549,7 +2546,6 @@ bool InnerWidget::chooseCollapsedRow() { } void InnerWidget::switchToFilter(FilterId filterId) { - clearSelection(); const auto found = ranges::contains( session().data().chatsFilters().list(), filterId, @@ -2557,9 +2553,17 @@ void InnerWidget::switchToFilter(FilterId filterId) { if (!found) { filterId = 0; } - stopReorderPinned(); - _filterId = filterId; - refreshWithCollapsedRows(true); + if (_filterId == filterId) { + return; + } + if (_openedFolder) { + _filterId = filterId; + } else { + clearSelection(); + stopReorderPinned(); + _filterId = filterId; + refreshWithCollapsedRows(true); + } } bool InnerWidget::chooseHashtag() { diff --git a/Telegram/SourceFiles/window/window_session_controller.cpp b/Telegram/SourceFiles/window/window_session_controller.cpp index 0823a1089..d2e3a3bcf 100644 --- a/Telegram/SourceFiles/window/window_session_controller.cpp +++ b/Telegram/SourceFiles/window/window_session_controller.cpp @@ -244,6 +244,7 @@ bool SessionController::uniqueChatsInSearchResults() const { } void SessionController::openFolder(not_null folder) { + setActiveChatsFilter(0); _openedFolder = folder.get(); } @@ -775,6 +776,9 @@ FilterId SessionController::activeChatsFilterCurrent() const { void SessionController::setActiveChatsFilter(FilterId id) { _activeChatsFilter = id; + if (id) { + closeFolder(); + } } SessionController::~SessionController() = default;