diff --git a/Telegram/SourceFiles/history/history_service.cpp b/Telegram/SourceFiles/history/history_service.cpp index 10da7bcbe..7cefbcd66 100644 --- a/Telegram/SourceFiles/history/history_service.cpp +++ b/Telegram/SourceFiles/history/history_service.cpp @@ -11,6 +11,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "mainwidget.h" #include "main/main_session.h" #include "main/main_domain.h" // Core::App().domain().activate(). +#include "menu/menu_ttl_validator.h" #include "apiwrap.h" #include "history/history.h" #include "history/view/media/history_view_invoice.h" @@ -1362,7 +1363,11 @@ void HistoryService::createFromMtp(const MTPDmessage &message) { void HistoryService::createFromMtp(const MTPDmessageService &message) { const auto type = message.vaction().type(); - if (type == mtpc_messageActionGameScore) { + if (type == mtpc_messageActionSetChatTheme) { + setupChatThemeChange(); + } else if (type == mtpc_messageActionSetMessagesTTL) { + setupTTLChange(); + } else if (type == mtpc_messageActionGameScore) { const auto &data = message.vaction().c_messageActionGameScore(); UpdateComponents(HistoryServiceGameScore::Bit()); Get()->score = data.vscore().v; @@ -1525,6 +1530,42 @@ void HistoryService::clearDependency() { } } +void HistoryService::setupChatThemeChange() { + if (const auto user = history()->peer->asUser()) { + auto link = std::make_shared([=]( + ClickContext context) { + const auto my = context.other.value(); + if (const auto controller = my.sessionWindow.get()) { + controller->toggleChooseChatTheme(user); + } + }); + + UpdateComponents(HistoryServiceChatThemeChange::Bit()); + Get()->link = std::move(link); + } else { + RemoveComponents(HistoryServiceChatThemeChange::Bit()); + } +} + +void HistoryService::setupTTLChange() { + const auto peer = history()->peer; + auto link = std::make_shared([=]( + ClickContext context) { + const auto my = context.other.value(); + if (const auto controller = my.sessionWindow.get()) { + const auto validator = TTLMenu::TTLValidator( + std::make_shared(controller), + peer); + if (validator.can()) { + validator.showBox(); + } + } + }); + + UpdateComponents(HistoryServiceTTLChange::Bit()); + Get()->link = std::move(link); +} + void HistoryService::dependencyItemRemoved(HistoryItem *dependency) { clearDependency(); updateDependentText(); diff --git a/Telegram/SourceFiles/history/history_service.h b/Telegram/SourceFiles/history/history_service.h index dd9805da7..2c788b911 100644 --- a/Telegram/SourceFiles/history/history_service.h +++ b/Telegram/SourceFiles/history/history_service.h @@ -59,6 +59,16 @@ struct HistoryServiceOngoingCall rpl::lifetime lifetime; }; +struct HistoryServiceChatThemeChange +: public RuntimeComponent { + ClickHandlerPtr link; +}; + +struct HistoryServiceTTLChange +: public RuntimeComponent { + ClickHandlerPtr link; +}; + namespace HistoryView { class ServiceMessagePainter; } // namespace HistoryView @@ -155,6 +165,8 @@ private: void updateDependentText(); void updateText(PreparedText &&text); void clearDependency(); + void setupChatThemeChange(); + void setupTTLChange(); void createFromMtp(const MTPDmessage &message); void createFromMtp(const MTPDmessageService &message); diff --git a/Telegram/SourceFiles/history/view/history_view_service_message.cpp b/Telegram/SourceFiles/history/view/history_view_service_message.cpp index 790e0bb41..13fad925d 100644 --- a/Telegram/SourceFiles/history/view/history_view_service_message.cpp +++ b/Telegram/SourceFiles/history/view/history_view_service_message.cpp @@ -19,6 +19,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "ui/text/text_options.h" #include "ui/ui_utility.h" #include "mainwidget.h" +#include "menu/menu_ttl_validator.h" #include "lang/lang_keys.h" #include "styles/style_chat.h" @@ -613,6 +614,12 @@ TextState Service::textState(QPoint point, StateRequest request) const { if (PeerHasThisCall(peer, call->id).value_or(false)) { result.link = call->link; } + } else if (const auto theme = item->Get()) { + result.link = theme->link; + } else if (const auto ttl = item->Get()) { + if (TTLMenu::TTLValidator(nullptr, history()->peer).can()) { + result.link = ttl->link; + } } } } else if (media) {