From 01906c1161002695dac86b350a3a5d1cd8908ecb Mon Sep 17 00:00:00 2001 From: 23rd <23rd@vivaldi.net> Date: Thu, 21 Dec 2023 02:32:07 +0300 Subject: [PATCH] Fixed display of archiving toasts on wrong window. --- .../history/view/history_view_contact_status.cpp | 5 +++-- Telegram/SourceFiles/window/window_peer_menu.cpp | 11 +++++++---- Telegram/SourceFiles/window/window_peer_menu.h | 5 ++++- 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/Telegram/SourceFiles/history/view/history_view_contact_status.cpp b/Telegram/SourceFiles/history/view/history_view_contact_status.cpp index 85985a49ee..5767831e29 100644 --- a/Telegram/SourceFiles/history/view/history_view_contact_status.cpp +++ b/Telegram/SourceFiles/history/view/history_view_contact_status.cpp @@ -714,8 +714,9 @@ void ContactStatus::setupShareHandler(not_null user) { void ContactStatus::setupUnarchiveHandler(not_null peer) { _inner->unarchiveClicks( - ) | rpl::start_with_next([=] { - Window::ToggleHistoryArchived(peer->owner().history(peer), false); + ) | rpl::start_with_next([=, show = _controller->uiShow()] { + using namespace Window; + ToggleHistoryArchived(show, peer->owner().history(peer), false); peer->owner().notifySettings().resetToDefault(peer); if (const auto settings = peer->settings()) { const auto flags = PeerSetting::AutoArchived diff --git a/Telegram/SourceFiles/window/window_peer_menu.cpp b/Telegram/SourceFiles/window/window_peer_menu.cpp index fddb1379d8..5556864aa6 100644 --- a/Telegram/SourceFiles/window/window_peer_menu.cpp +++ b/Telegram/SourceFiles/window/window_peer_menu.cpp @@ -652,8 +652,8 @@ void Filler::addToggleArchive() { ? tr::lng_archived_remove(tr::now) : tr::lng_archived_add(tr::now); }; - const auto toggle = [=] { - ToggleHistoryArchived(history, !isArchived()); + const auto toggle = [=, show = _controller->uiShow()] { + ToggleHistoryArchived(show, history, !isArchived()); }; const auto archiveAction = _addAction( label(), @@ -2406,9 +2406,12 @@ void MenuAddMarkAsReadChatListAction( &st::menuIconMarkRead); } -void ToggleHistoryArchived(not_null history, bool archived) { +void ToggleHistoryArchived( + std::shared_ptr show, + not_null history, + bool archived) { const auto callback = [=] { - Ui::Toast::Show(Ui::Toast::Config{ + show->showToast(Ui::Toast::Config{ .text = { (archived ? tr::lng_archived_added(tr::now) : tr::lng_archived_removed(tr::now)) }, diff --git a/Telegram/SourceFiles/window/window_peer_menu.h b/Telegram/SourceFiles/window/window_peer_menu.h index f5fff7f1f0..44503042b8 100644 --- a/Telegram/SourceFiles/window/window_peer_menu.h +++ b/Telegram/SourceFiles/window/window_peer_menu.h @@ -116,7 +116,10 @@ void BlockSenderFromRepliesBox( not_null controller, FullMsgId id); -void ToggleHistoryArchived(not_null history, bool archived); +void ToggleHistoryArchived( + std::shared_ptr show, + not_null history, + bool archived); Fn ClearHistoryHandler( not_null controller, not_null peer);