mirror of
https://github.com/telegramdesktop/tdesktop
synced 2025-08-31 06:26:18 +00:00
Allow hiding PSA from the chats list.
This commit is contained in:
@@ -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<ChannelData*> channel) {
|
||||
}
|
||||
|
||||
void Filler::fill() {
|
||||
if (showHidePromotion()) {
|
||||
addHidePromotion();
|
||||
}
|
||||
if (showToggleArchived()) {
|
||||
addToggleArchive();
|
||||
}
|
||||
|
Reference in New Issue
Block a user