From 66435d52697ab9ca318701918d9024ed99222a26 Mon Sep 17 00:00:00 2001 From: John Preston Date: Tue, 8 Nov 2022 21:20:25 +0400 Subject: [PATCH] Better folder / chat closing by escape. --- Telegram/SourceFiles/mainwidget.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/Telegram/SourceFiles/mainwidget.cpp b/Telegram/SourceFiles/mainwidget.cpp index c8ac4647d..40cf7f0a0 100644 --- a/Telegram/SourceFiles/mainwidget.cpp +++ b/Telegram/SourceFiles/mainwidget.cpp @@ -2653,12 +2653,16 @@ void MainWidget::handleHistoryBack() { if (!_dialogs) { return; } - const auto historyFromFolder = _history->history() - ? _history->history()->folder() - : nullptr; const auto openedFolder = _controller->openedFolder().current(); + const auto rootPeer = _stack.empty() + ? _history->peer() + : _stack.front()->peer(); + const auto rootHistory = rootPeer + ? rootPeer->owner().historyLoaded(rootPeer) + : nullptr; + const auto rootFolder = rootHistory ? rootHistory->folder() : nullptr; if (!openedFolder - || historyFromFolder == openedFolder + || rootFolder == openedFolder || _dialogs->isHidden()) { _controller->showBackFromStack(); _dialogs->setInnerFocus();