2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-09-02 23:45:44 +00:00

Support pinned locally in filters.

This commit is contained in:
John Preston
2020-03-17 17:04:30 +04:00
parent 483d4e5a4e
commit e27a8fe058
30 changed files with 409 additions and 155 deletions

View File

@@ -32,10 +32,9 @@ struct RowsByLetter {
};
enum class SortMode {
Complex = 0x00,
Date = 0x01,
Name = 0x02,
Add = 0x04,
Date = 0x00,
Name = 0x01,
Add = 0x02,
};
struct PositionChange {
@@ -117,19 +116,18 @@ public:
QChar letter,
not_null<Row*> row);
void updateChatListEntry() const;
bool isPinnedDialog() const {
return _pinnedIndex > 0;
[[nodiscard]] bool isPinnedDialog(FilterId filterId) const {
return lookupPinnedIndex(filterId) != 0;
}
void cachePinnedIndex(int index);
void cachePinnedIndex(FilterId filterId, int index);
bool isProxyPromoted() const {
return _isProxyPromoted;
}
void cacheProxyPromoted(bool promoted);
uint64 sortKeyInChatList() const {
return _sortKeyInChatList;
}
uint64 sortKeyByDate() const {
return _sortKeyByDate;
[[nodiscard]] uint64 sortKeyInChatList(FilterId filterId) const {
return filterId
? computeSortPosition(filterId)
: _sortKeyInChatList;
}
void updateChatListSortPosition();
void setChatListTimeId(TimeId date);
@@ -194,8 +192,12 @@ protected:
});
}
[[nodiscard]] int lookupPinnedIndex(FilterId filterId) const;
private:
virtual void changedChatListPinHook();
void pinnedIndexChanged(int was, int now);
[[nodiscard]] uint64 computeSortPosition(FilterId filterId) const;
void setChatListExistence(bool exists);
RowsByLetter *chatListLinks(FilterId filterId);
@@ -208,7 +210,7 @@ private:
base::flat_map<FilterId, RowsByLetter> _chatListLinks;
uint64 _sortKeyInChatList = 0;
uint64 _sortKeyByDate = 0;
int _pinnedIndex = 0;
base::flat_map<FilterId, int> _pinnedIndex;
bool _isProxyPromoted = false;
TimeId _timeId = 0;