2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-08-31 14:38:15 +00:00

Improve context menu in pinned section.

This commit is contained in:
John Preston
2020-10-21 17:41:13 +03:00
parent ebbe75ac0a
commit 61d335469f
12 changed files with 127 additions and 81 deletions

View File

@@ -1124,6 +1124,32 @@ void PeerMenuAddChannelMembers(
}));
}
void ToggleMessagePinned(
not_null<Window::SessionNavigation*> navigation,
FullMsgId itemId,
bool pin) {
const auto item = navigation->session().data().message(itemId);
if (!item || !item->canPin()) {
return;
}
if (pin) {
Ui::show(Box<PinMessageBox>(item->history()->peer, item->id));
} else {
const auto peer = item->history()->peer;
const auto session = &peer->session();
Ui::show(Box<ConfirmBox>(tr::lng_pinned_unpin_sure(tr::now), tr::lng_pinned_unpin(tr::now), crl::guard(session, [=] {
Ui::hideLayer();
session->api().request(MTPmessages_UpdatePinnedMessage(
MTP_flags(MTPmessages_UpdatePinnedMessage::Flag::f_unpin),
peer->input,
MTP_int(itemId.msg)
)).done([=](const MTPUpdates &result) {
session->api().applyUpdates(result);
}).send();
})));
}
}
void PeerMenuAddMuteAction(
not_null<PeerData*> peer,
const PeerMenuCallback &addAction) {