diff --git a/Telegram/SourceFiles/history/history_inner_widget.cpp b/Telegram/SourceFiles/history/history_inner_widget.cpp index 8abce4dd04..ebb1c906fc 100644 --- a/Telegram/SourceFiles/history/history_inner_widget.cpp +++ b/Telegram/SourceFiles/history/history_inner_widget.cpp @@ -2177,7 +2177,9 @@ void HistoryInner::showContextMenu(QContextMenuEvent *e, bool showFromTouch) { } const auto link = ClickHandler::getActive(); - if (link + if (_controller->showFrozenError()) { + return; + } else if (link && !link->property( kSendReactionEmojiProperty).value().empty() && _reactionsManager->showContextMenu( diff --git a/Telegram/SourceFiles/history/view/history_view_list_widget.cpp b/Telegram/SourceFiles/history/view/history_view_list_widget.cpp index 7a2d62cd9b..21df444337 100644 --- a/Telegram/SourceFiles/history/view/history_view_list_widget.cpp +++ b/Telegram/SourceFiles/history/view/history_view_list_widget.cpp @@ -2811,7 +2811,9 @@ void ListWidget::showContextMenu(QContextMenuEvent *e, bool showFromTouch) { } const auto link = ClickHandler::getActive(); - if (link + if (controller()->showFrozenError()) { + return; + } else if (link && !link->property( kSendReactionEmojiProperty).value().empty() && _reactionsManager diff --git a/Telegram/SourceFiles/history/view/history_view_top_bar_widget.cpp b/Telegram/SourceFiles/history/view/history_view_top_bar_widget.cpp index 2e9ac641b4..62d5d43a94 100644 --- a/Telegram/SourceFiles/history/view/history_view_top_bar_widget.cpp +++ b/Telegram/SourceFiles/history/view/history_view_top_bar_widget.cpp @@ -271,7 +271,9 @@ void TopBarWidget::refreshLang() { } void TopBarWidget::call() { - if (const auto peer = _activeChat.key.peer()) { + if (_controller->showFrozenError()) { + return; + } else if (const auto peer = _activeChat.key.peer()) { if (const auto user = peer->asUser()) { Core::App().calls().startOutgoingCall(user, false); } @@ -279,7 +281,9 @@ void TopBarWidget::call() { } void TopBarWidget::groupCall() { - if (const auto peer = _activeChat.key.peer()) { + if (_controller->showFrozenError()) { + return; + } else if (const auto peer = _activeChat.key.peer()) { if (HasGroupCallMenu(peer)) { showGroupCallMenu(peer); } else { diff --git a/Telegram/SourceFiles/main/session/session_show.cpp b/Telegram/SourceFiles/main/session/session_show.cpp index a9914e87d8..5dcebcdedc 100644 --- a/Telegram/SourceFiles/main/session/session_show.cpp +++ b/Telegram/SourceFiles/main/session/session_show.cpp @@ -7,6 +7,9 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL */ #include "main/session/session_show.h" +#include "lang/lang_keys.h" +#include "main/main_session.h" + namespace Main { namespace { @@ -70,6 +73,14 @@ Session &SimpleSessionShow::session() const { } // namespace +bool SessionShow::showFrozenError() { + if (!session().frozen()) { + return false; + } + showToast(tr::lng_frozen_bar_title(tr::now)); + return true; +} + std::shared_ptr MakeSessionShow( std::shared_ptr show, not_null session) { diff --git a/Telegram/SourceFiles/main/session/session_show.h b/Telegram/SourceFiles/main/session/session_show.h index ae764e1254..16f8e6f913 100644 --- a/Telegram/SourceFiles/main/session/session_show.h +++ b/Telegram/SourceFiles/main/session/session_show.h @@ -16,6 +16,9 @@ class Session; class SessionShow : public Ui::Show { public: [[nodiscard]] virtual Main::Session &session() const = 0; + + bool showFrozenError(); + }; [[nodiscard]] std::shared_ptr MakeSessionShow( diff --git a/Telegram/SourceFiles/window/window_peer_menu.cpp b/Telegram/SourceFiles/window/window_peer_menu.cpp index 6fbf2c3eb0..08102a6bde 100644 --- a/Telegram/SourceFiles/window/window_peer_menu.cpp +++ b/Telegram/SourceFiles/window/window_peer_menu.cpp @@ -848,9 +848,10 @@ void Filler::addExportChat() { return; } const auto peer = _peer; + const auto navigation = _controller; _addAction( tr::lng_profile_export_chat(tr::now), - [=] { PeerMenuExportChat(peer); }, + [=] { PeerMenuExportChat(navigation, peer); }, &st::menuIconExport); } @@ -1516,7 +1517,9 @@ void Filler::fillSavedSublistActions() { } // namespace -void PeerMenuExportChat(not_null peer) { +void PeerMenuExportChat( + not_null controller, + not_null peer) { base::call_delayed(st::defaultPopupMenu.showDuration, [=] { Core::App().exportManager().start(peer); }); @@ -3126,14 +3129,20 @@ Fn ClearHistoryHandler( not_null controller, not_null peer) { return [=] { - controller->show(Box(peer, true)); + if (!controller->showFrozenError()) { + controller->show(Box(peer, true)); + } }; } Fn DeleteAndLeaveHandler( not_null controller, not_null peer) { - return [=] { controller->show(Box(DeleteChatBox, peer)); }; + return [=] { + if (!controller->showFrozenError()) { + controller->show(Box(DeleteChatBox, peer)); + } + }; } void FillDialogsEntryMenu( diff --git a/Telegram/SourceFiles/window/window_peer_menu.h b/Telegram/SourceFiles/window/window_peer_menu.h index 5ad0c50813..e2406d8ee7 100644 --- a/Telegram/SourceFiles/window/window_peer_menu.h +++ b/Telegram/SourceFiles/window/window_peer_menu.h @@ -89,7 +89,9 @@ void MenuAddMarkAsReadChatListAction( const PeerMenuCallback &addAction, Fn customUnreadState = nullptr); -void PeerMenuExportChat(not_null peer); +void PeerMenuExportChat( + not_null controller, + not_null peer); void PeerMenuDeleteContact( not_null controller, not_null user); diff --git a/Telegram/SourceFiles/window/window_session_controller.cpp b/Telegram/SourceFiles/window/window_session_controller.cpp index a3fdd4d6d4..607077828c 100644 --- a/Telegram/SourceFiles/window/window_session_controller.cpp +++ b/Telegram/SourceFiles/window/window_session_controller.cpp @@ -364,6 +364,10 @@ Main::Session &SessionNavigation::session() const { return *_session; } +bool SessionNavigation::showFrozenError() { + return uiShow()->showFrozenError(); +} + void SessionNavigation::showPeerByLink(const PeerByLinkInfo &info) { Core::App().hideMediaView(); if (!info.phone.isEmpty()) { diff --git a/Telegram/SourceFiles/window/window_session_controller.h b/Telegram/SourceFiles/window/window_session_controller.h index afc847e3f8..c69dc06e9a 100644 --- a/Telegram/SourceFiles/window/window_session_controller.h +++ b/Telegram/SourceFiles/window/window_session_controller.h @@ -180,6 +180,8 @@ public: [[nodiscard]] Main::Session &session() const; + bool showFrozenError(); + virtual void showSection( std::shared_ptr memento, const SectionShow ¶ms = SectionShow()) = 0;