2
0
mirror of https://github.com/kotatogram/kotatogram-desktop synced 2025-08-31 06:35:14 +00:00

Implement unpin all messages within a thread.

This commit is contained in:
John Preston
2022-11-01 09:22:21 +04:00
parent 1ac051a812
commit 6d215d3729
6 changed files with 38 additions and 9 deletions

View File

@@ -1757,15 +1757,18 @@ void UnpinAllMessages(
const auto callback = crl::guard(navigation, [=](Fn<void()> &&close) {
close();
const auto strong = weak.get();
if (!strong || !strong->asHistory()) { // #TODO forum pinned
if (!strong) {
return;
}
const auto api = &strong->session().api();
const auto sendRequest = [=](auto self) -> void {
const auto history = strong->owningHistory();
const auto topicRootId = strong->topicRootId();
using Flag = MTPmessages_UnpinAllMessages::Flag;
api->request(MTPmessages_UnpinAllMessages(
history->peer->input
MTP_flags(topicRootId ? Flag::f_top_msg_id : Flag()),
history->peer->input,
MTP_int(topicRootId.bare)
)).done([=](const MTPmessages_AffectedHistory &result) {
const auto peer = history->peer;
const auto offset = api->applyAffectedHistory(peer, result);