Handle some frozen cases.

This commit is contained in:
John Preston 2025-03-11 16:09:34 +04:00
parent d9b270b477
commit fbab3964e6
9 changed files with 48 additions and 9 deletions

View file

@ -2177,7 +2177,9 @@ void HistoryInner::showContextMenu(QContextMenuEvent *e, bool showFromTouch) {
} }
const auto link = ClickHandler::getActive(); const auto link = ClickHandler::getActive();
if (link if (_controller->showFrozenError()) {
return;
} else if (link
&& !link->property( && !link->property(
kSendReactionEmojiProperty).value<Data::ReactionId>().empty() kSendReactionEmojiProperty).value<Data::ReactionId>().empty()
&& _reactionsManager->showContextMenu( && _reactionsManager->showContextMenu(

View file

@ -2811,7 +2811,9 @@ void ListWidget::showContextMenu(QContextMenuEvent *e, bool showFromTouch) {
} }
const auto link = ClickHandler::getActive(); const auto link = ClickHandler::getActive();
if (link if (controller()->showFrozenError()) {
return;
} else if (link
&& !link->property( && !link->property(
kSendReactionEmojiProperty).value<Data::ReactionId>().empty() kSendReactionEmojiProperty).value<Data::ReactionId>().empty()
&& _reactionsManager && _reactionsManager

View file

@ -271,7 +271,9 @@ void TopBarWidget::refreshLang() {
} }
void TopBarWidget::call() { 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()) { if (const auto user = peer->asUser()) {
Core::App().calls().startOutgoingCall(user, false); Core::App().calls().startOutgoingCall(user, false);
} }
@ -279,7 +281,9 @@ void TopBarWidget::call() {
} }
void TopBarWidget::groupCall() { 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)) { if (HasGroupCallMenu(peer)) {
showGroupCallMenu(peer); showGroupCallMenu(peer);
} else { } else {

View file

@ -7,6 +7,9 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
*/ */
#include "main/session/session_show.h" #include "main/session/session_show.h"
#include "lang/lang_keys.h"
#include "main/main_session.h"
namespace Main { namespace Main {
namespace { namespace {
@ -70,6 +73,14 @@ Session &SimpleSessionShow::session() const {
} // namespace } // namespace
bool SessionShow::showFrozenError() {
if (!session().frozen()) {
return false;
}
showToast(tr::lng_frozen_bar_title(tr::now));
return true;
}
std::shared_ptr<SessionShow> MakeSessionShow( std::shared_ptr<SessionShow> MakeSessionShow(
std::shared_ptr<Ui::Show> show, std::shared_ptr<Ui::Show> show,
not_null<Session*> session) { not_null<Session*> session) {

View file

@ -16,6 +16,9 @@ class Session;
class SessionShow : public Ui::Show { class SessionShow : public Ui::Show {
public: public:
[[nodiscard]] virtual Main::Session &session() const = 0; [[nodiscard]] virtual Main::Session &session() const = 0;
bool showFrozenError();
}; };
[[nodiscard]] std::shared_ptr<SessionShow> MakeSessionShow( [[nodiscard]] std::shared_ptr<SessionShow> MakeSessionShow(

View file

@ -848,9 +848,10 @@ void Filler::addExportChat() {
return; return;
} }
const auto peer = _peer; const auto peer = _peer;
const auto navigation = _controller;
_addAction( _addAction(
tr::lng_profile_export_chat(tr::now), tr::lng_profile_export_chat(tr::now),
[=] { PeerMenuExportChat(peer); }, [=] { PeerMenuExportChat(navigation, peer); },
&st::menuIconExport); &st::menuIconExport);
} }
@ -1516,7 +1517,9 @@ void Filler::fillSavedSublistActions() {
} // namespace } // namespace
void PeerMenuExportChat(not_null<PeerData*> peer) { void PeerMenuExportChat(
not_null<Window::SessionController*> controller,
not_null<PeerData*> peer) {
base::call_delayed(st::defaultPopupMenu.showDuration, [=] { base::call_delayed(st::defaultPopupMenu.showDuration, [=] {
Core::App().exportManager().start(peer); Core::App().exportManager().start(peer);
}); });
@ -3126,14 +3129,20 @@ Fn<void()> ClearHistoryHandler(
not_null<Window::SessionController*> controller, not_null<Window::SessionController*> controller,
not_null<PeerData*> peer) { not_null<PeerData*> peer) {
return [=] { return [=] {
controller->show(Box<DeleteMessagesBox>(peer, true)); if (!controller->showFrozenError()) {
controller->show(Box<DeleteMessagesBox>(peer, true));
}
}; };
} }
Fn<void()> DeleteAndLeaveHandler( Fn<void()> DeleteAndLeaveHandler(
not_null<Window::SessionController*> controller, not_null<Window::SessionController*> controller,
not_null<PeerData*> peer) { not_null<PeerData*> peer) {
return [=] { controller->show(Box(DeleteChatBox, peer)); }; return [=] {
if (!controller->showFrozenError()) {
controller->show(Box(DeleteChatBox, peer));
}
};
} }
void FillDialogsEntryMenu( void FillDialogsEntryMenu(

View file

@ -89,7 +89,9 @@ void MenuAddMarkAsReadChatListAction(
const PeerMenuCallback &addAction, const PeerMenuCallback &addAction,
Fn<Dialogs::UnreadState()> customUnreadState = nullptr); Fn<Dialogs::UnreadState()> customUnreadState = nullptr);
void PeerMenuExportChat(not_null<PeerData*> peer); void PeerMenuExportChat(
not_null<Window::SessionController*> controller,
not_null<PeerData*> peer);
void PeerMenuDeleteContact( void PeerMenuDeleteContact(
not_null<Window::SessionController*> controller, not_null<Window::SessionController*> controller,
not_null<UserData*> user); not_null<UserData*> user);

View file

@ -364,6 +364,10 @@ Main::Session &SessionNavigation::session() const {
return *_session; return *_session;
} }
bool SessionNavigation::showFrozenError() {
return uiShow()->showFrozenError();
}
void SessionNavigation::showPeerByLink(const PeerByLinkInfo &info) { void SessionNavigation::showPeerByLink(const PeerByLinkInfo &info) {
Core::App().hideMediaView(); Core::App().hideMediaView();
if (!info.phone.isEmpty()) { if (!info.phone.isEmpty()) {

View file

@ -180,6 +180,8 @@ public:
[[nodiscard]] Main::Session &session() const; [[nodiscard]] Main::Session &session() const;
bool showFrozenError();
virtual void showSection( virtual void showSection(
std::shared_ptr<SectionMemento> memento, std::shared_ptr<SectionMemento> memento,
const SectionShow &params = SectionShow()) = 0; const SectionShow &params = SectionShow()) = 0;