diff --git a/Telegram/Resources/langs/lang.strings b/Telegram/Resources/langs/lang.strings index 72652b6eee..64c11ae7a2 100644 --- a/Telegram/Resources/langs/lang.strings +++ b/Telegram/Resources/langs/lang.strings @@ -1404,6 +1404,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL "lng_context_view_group" = "View group info"; "lng_context_view_channel" = "View channel info"; //"lng_context_view_feed_info" = "View feed info"; +"lng_context_hide_psa" = "Hide this announcement"; "lng_context_pin_to_top" = "Pin to top"; "lng_context_unpin_from_top" = "Unpin from top"; "lng_context_mark_unread" = "Mark as unread"; diff --git a/Telegram/SourceFiles/apiwrap.cpp b/Telegram/SourceFiles/apiwrap.cpp index cc66e12239..24d30648db 100644 --- a/Telegram/SourceFiles/apiwrap.cpp +++ b/Telegram/SourceFiles/apiwrap.cpp @@ -342,7 +342,7 @@ void ApiWrap::topPromotionDone(const MTPhelp_PromoData &proxy) { _topPromotionNextRequestTime); proxy.match([&](const MTPDhelp_promoDataEmpty &data) { - _session->data().setTopPromoted(nullptr, false, QString()); + _session->data().setTopPromoted(nullptr, QString(), QString()); }, [&](const MTPDhelp_promoData &data) { _session->data().processChats(data.vchats()); _session->data().processUsers(data.vusers()); diff --git a/Telegram/SourceFiles/window/window_peer_menu.cpp b/Telegram/SourceFiles/window/window_peer_menu.cpp index be88faf175..93a6555019 100644 --- a/Telegram/SourceFiles/window/window_peer_menu.cpp +++ b/Telegram/SourceFiles/window/window_peer_menu.cpp @@ -72,9 +72,11 @@ public: void fill(); private: - bool showInfo(); - bool showToggleArchived(); - bool showTogglePin(); + [[nodiscard]] bool showInfo(); + [[nodiscard]] bool showHidePromotion(); + [[nodiscard]] bool showToggleArchived(); + [[nodiscard]] bool showTogglePin(); + void addHidePromotion(); void addTogglePin(); void addInfo(); //void addSearch(); @@ -248,6 +250,16 @@ bool Filler::showInfo() { return false; } +bool Filler::showHidePromotion() { + if (_source != PeerMenuSource::ChatsList) { + return false; + } + const auto history = _peer->owner().historyLoaded(_peer); + return history + && history->useTopPromotion() + && !history->topPromotionType().isEmpty(); +} + bool Filler::showToggleArchived() { if (_source != PeerMenuSource::ChatsList) { return false; @@ -269,6 +281,16 @@ bool Filler::showTogglePin() { return history && !history->fixedOnTopIndex(); } +void Filler::addHidePromotion() { + const auto history = _peer->owner().history(_peer); + _addAction(tr::lng_context_hide_psa(tr::now), [=] { + history->cacheTopPromotion(false, QString(), QString()); + history->session().api().request(MTPhelp_HidePromoData( + history->peer->input + )).send(); + }); +} + void Filler::addTogglePin() { const auto filterId = _filterId; const auto peer = _peer; @@ -571,6 +593,9 @@ void Filler::addChannelActions(not_null channel) { } void Filler::fill() { + if (showHidePromotion()) { + addHidePromotion(); + } if (showToggleArchived()) { addToggleArchive(); }