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

Implement pinned topics reordering.

This commit is contained in:
John Preston
2022-11-08 17:57:54 +04:00
parent c7741cb62a
commit 8a288476b8
17 changed files with 221 additions and 105 deletions

View File

@@ -2308,6 +2308,29 @@ void Updates::feedUpdate(const MTPUpdate &update) {
case mtpc_updateChannelPinnedTopics: {
const auto &d = update.c_updateChannelPinnedTopics();
const auto peerId = peerFromChannel(d.vchannel_id());
if (const auto peer = session().data().peerLoaded(peerId)) {
if (const auto forum = peer->forum()) {
const auto done = [&] {
const auto list = d.vorder();
if (!list) {
return false;
}
const auto &order = list->v;
const auto notLoaded = [&](const MTPint &topicId) {
return !forum->topicFor(topicId.v);
};
if (!ranges::none_of(order, notLoaded)) {
return false;
}
session().data().applyPinnedTopics(forum, order);
return true;
}();
if (!done) {
forum->reloadTopics();
}
}
}
} break;
// Pinned message.