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();
if (link
if (_controller->showFrozenError()) {
return;
} else if (link
&& !link->property(
kSendReactionEmojiProperty).value<Data::ReactionId>().empty()
&& _reactionsManager->showContextMenu(

View file

@ -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<Data::ReactionId>().empty()
&& _reactionsManager

View file

@ -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 {

View file

@ -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<SessionShow> MakeSessionShow(
std::shared_ptr<Ui::Show> show,
not_null<Session*> session) {

View file

@ -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<SessionShow> MakeSessionShow(

View file

@ -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<PeerData*> peer) {
void PeerMenuExportChat(
not_null<Window::SessionController*> controller,
not_null<PeerData*> peer) {
base::call_delayed(st::defaultPopupMenu.showDuration, [=] {
Core::App().exportManager().start(peer);
});
@ -3126,14 +3129,20 @@ Fn<void()> ClearHistoryHandler(
not_null<Window::SessionController*> controller,
not_null<PeerData*> peer) {
return [=] {
controller->show(Box<DeleteMessagesBox>(peer, true));
if (!controller->showFrozenError()) {
controller->show(Box<DeleteMessagesBox>(peer, true));
}
};
}
Fn<void()> DeleteAndLeaveHandler(
not_null<Window::SessionController*> controller,
not_null<PeerData*> peer) {
return [=] { controller->show(Box(DeleteChatBox, peer)); };
return [=] {
if (!controller->showFrozenError()) {
controller->show(Box(DeleteChatBox, peer));
}
};
}
void FillDialogsEntryMenu(

View file

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

View file

@ -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()) {

View file

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