From 80a1e6ecf3ab87555986f3d81e2f79c5a64848d2 Mon Sep 17 00:00:00 2001
From: 23rd <23rd@vivaldi.net>
Date: Fri, 20 Dec 2024 19:05:49 +0300
Subject: [PATCH] Fixed ability to mark as read all chats for wrong account.

---
 Telegram/SourceFiles/settings/settings_information.cpp | 3 ++-
 Telegram/SourceFiles/window/window_peer_menu.cpp       | 7 ++++---
 Telegram/SourceFiles/window/window_peer_menu.h         | 3 ++-
 3 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/Telegram/SourceFiles/settings/settings_information.cpp b/Telegram/SourceFiles/settings/settings_information.cpp
index 97fe68bd9..cde71d622 100644
--- a/Telegram/SourceFiles/settings/settings_information.cpp
+++ b/Telegram/SourceFiles/settings/settings_information.cpp
@@ -751,7 +751,8 @@ void SetupAccountsWrap(
 				raw,
 				st::popupMenuWithIcons);
 			Window::MenuAddMarkAsReadAllChatsAction(
-				window,
+				session,
+				window->uiShow(),
 				Ui::Menu::CreateAddActionCallback(state->menu));
 			state->menu->popup(QCursor::pos());
 			return;
diff --git a/Telegram/SourceFiles/window/window_peer_menu.cpp b/Telegram/SourceFiles/window/window_peer_menu.cpp
index 9ec50c3a0..108579e46 100644
--- a/Telegram/SourceFiles/window/window_peer_menu.cpp
+++ b/Telegram/SourceFiles/window/window_peer_menu.cpp
@@ -2767,10 +2767,11 @@ void UnpinAllMessages(
 }
 
 void MenuAddMarkAsReadAllChatsAction(
-		not_null<Window::SessionController*> controller,
+		not_null<Main::Session*> session,
+		std::shared_ptr<Ui::Show> show,
 		const PeerMenuCallback &addAction) {
 	// There is no async to make weak from controller.
-	auto callback = [=, owner = &controller->session().data()] {
+	auto callback = [=, owner = &session->data()] {
 		auto boxCallback = [=](Fn<void()> &&close) {
 			close();
 
@@ -2779,7 +2780,7 @@ void MenuAddMarkAsReadAllChatsAction(
 				MarkAsReadChatList(folder->chatsList());
 			}
 		};
-		controller->show(
+		show->show(
 			Ui::MakeConfirmBox({
 				tr::lng_context_mark_read_all_sure(),
 				std::move(boxCallback)
diff --git a/Telegram/SourceFiles/window/window_peer_menu.h b/Telegram/SourceFiles/window/window_peer_menu.h
index 6ef96c9f5..7e2314f59 100644
--- a/Telegram/SourceFiles/window/window_peer_menu.h
+++ b/Telegram/SourceFiles/window/window_peer_menu.h
@@ -74,7 +74,8 @@ void FillSenderUserpicMenu(
 	const PeerMenuCallback &addAction);
 
 void MenuAddMarkAsReadAllChatsAction(
-	not_null<Window::SessionController*> controller,
+	not_null<Main::Session*> session,
+	std::shared_ptr<Ui::Show> show,
 	const PeerMenuCallback &addAction);
 
 void MenuAddMarkAsReadChatListAction(