2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-08-31 06:26:18 +00:00

Add hide / unpin all button in pinned section.

This commit is contained in:
John Preston
2020-10-22 10:53:56 +03:00
parent 61d335469f
commit 994e3d8da7
12 changed files with 254 additions and 26 deletions

View File

@@ -435,6 +435,7 @@ QString PeerData::computeUnavailableReason() const {
return (first != filtered.end()) ? first->text : QString();
}
// This is duplicated in CanPinMessagesValue().
bool PeerData::canPinMessages() const {
if (const auto user = asUser()) {
return user->fullFlags() & MTPDuserFull::Flag::f_can_pin_message;
@@ -1028,4 +1029,16 @@ MsgId ResolveTopPinnedId(not_null<PeerData*> peer) {
return slice.messageIds.empty() ? 0 : slice.messageIds.back();
}
std::optional<int> ResolvePinnedCount(not_null<PeerData*> peer) {
const auto slice = peer->session().storage().snapshot(
Storage::SharedMediaQuery(
Storage::SharedMediaKey(
peer->id,
Storage::SharedMediaType::Pinned,
0),
0,
0));
return slice.count;
}
} // namespace Data