2
0
mirror of https://github.com/kotatogram/kotatogram-desktop synced 2025-08-30 22:25:12 +00:00

Loop pinned messages in the top bar.

This commit is contained in:
John Preston
2020-10-26 14:46:08 +03:00
parent 08f7069370
commit 53c308c24b
6 changed files with 72 additions and 9 deletions

View File

@@ -1051,6 +1051,40 @@ FullMsgId ResolveTopPinnedId(
}
}
FullMsgId ResolveMinPinnedId(
not_null<PeerData*> peer,
PeerData *migrated) {
const auto slice = peer->session().storage().snapshot(
Storage::SharedMediaQuery(
Storage::SharedMediaKey(
peer->id,
Storage::SharedMediaType::Pinned,
1),
1,
1));
const auto old = migrated
? migrated->session().storage().snapshot(
Storage::SharedMediaQuery(
Storage::SharedMediaKey(
migrated->id,
Storage::SharedMediaType::Pinned,
1),
1,
1))
: Storage::SharedMediaResult{
.count = 0,
.skippedBefore = 0,
.skippedAfter = 0,
};
if (!old.messageIds.empty()) {
return FullMsgId(0, old.messageIds.front());
} else if (old.count == 0 && !slice.messageIds.empty()) {
return FullMsgId(peerToChannel(peer->id), slice.messageIds.front());
} else {
return FullMsgId();
}
}
std::optional<int> ResolvePinnedCount(
not_null<PeerData*> peer,
PeerData *migrated) {

View File

@@ -446,6 +446,9 @@ void SetTopPinnedMessageId(not_null<PeerData*> peer, MsgId messageId);
[[nodiscard]] FullMsgId ResolveTopPinnedId(
not_null<PeerData*> peer,
PeerData *migrated);
[[nodiscard]] FullMsgId ResolveMinPinnedId(
not_null<PeerData*> peer,
PeerData *migrated);
[[nodiscard]] std::optional<int> ResolvePinnedCount(
not_null<PeerData*> peer,
PeerData *migrated);