mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Added ability to cache filter colors in dialog entries.
This commit is contained in:
parent
f888008dc1
commit
d5dbde0a24
2 changed files with 30 additions and 0 deletions
|
@ -338,6 +338,17 @@ not_null<Row*> Entry::addToChatList(
|
||||||
if (const auto main = maybeMainChatListLink(filterId)) {
|
if (const auto main = maybeMainChatListLink(filterId)) {
|
||||||
return main;
|
return main;
|
||||||
}
|
}
|
||||||
|
if (filterId) {
|
||||||
|
const auto &list = owner().chatsFilters().list();
|
||||||
|
const auto it = ranges::find(list, filterId, &Data::ChatFilter::id);
|
||||||
|
if (it != end(list) && it->colorIndex()) {
|
||||||
|
_tagColors[filterId] = *(it->colorIndex());
|
||||||
|
} else {
|
||||||
|
if (it != end(list)) {
|
||||||
|
}
|
||||||
|
_tagColors.remove(filterId);
|
||||||
|
}
|
||||||
|
}
|
||||||
return _chatListLinks.emplace(
|
return _chatListLinks.emplace(
|
||||||
filterId,
|
filterId,
|
||||||
list->addEntry(this)
|
list->addEntry(this)
|
||||||
|
@ -350,6 +361,12 @@ void Entry::removeFromChatList(
|
||||||
if (isPinnedDialog(filterId)) {
|
if (isPinnedDialog(filterId)) {
|
||||||
owner().setChatPinned(this, filterId, false);
|
owner().setChatPinned(this, filterId, false);
|
||||||
}
|
}
|
||||||
|
if (filterId) {
|
||||||
|
const auto it = _tagColors.find(filterId);
|
||||||
|
if (it != end(_tagColors)) {
|
||||||
|
_tagColors.erase(it);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const auto i = _chatListLinks.find(filterId);
|
const auto i = _chatListLinks.find(filterId);
|
||||||
if (i == end(_chatListLinks)) {
|
if (i == end(_chatListLinks)) {
|
||||||
|
@ -397,4 +414,15 @@ void Entry::updateChatListEntryHeight() {
|
||||||
session().changes().entryUpdated(this, Data::EntryUpdate::Flag::Height);
|
session().changes().entryUpdated(this, Data::EntryUpdate::Flag::Height);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[[nodiscard]] bool Entry::hasChatsFilterTags(FilterId exclude) const {
|
||||||
|
if (exclude) {
|
||||||
|
if (_tagColors.size() == 1) {
|
||||||
|
if (_tagColors.begin()->first == exclude) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return !_tagColors.empty();
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace Dialogs
|
} // namespace Dialogs
|
||||||
|
|
|
@ -254,6 +254,7 @@ public:
|
||||||
return _chatListPeerBadge;
|
return _chatListPeerBadge;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[[nodiscard]] bool hasChatsFilterTags(FilterId exclude) const;
|
||||||
protected:
|
protected:
|
||||||
void notifyUnreadStateChange(const UnreadState &wasState);
|
void notifyUnreadStateChange(const UnreadState &wasState);
|
||||||
inline auto unreadStateChangeNotifier(bool required);
|
inline auto unreadStateChangeNotifier(bool required);
|
||||||
|
@ -284,6 +285,7 @@ private:
|
||||||
uint64 _sortKeyInChatList = 0;
|
uint64 _sortKeyInChatList = 0;
|
||||||
uint64 _sortKeyByDate = 0;
|
uint64 _sortKeyByDate = 0;
|
||||||
base::flat_map<FilterId, int> _pinnedIndex;
|
base::flat_map<FilterId, int> _pinnedIndex;
|
||||||
|
base::flat_map<FilterId, uint8> _tagColors;
|
||||||
mutable Ui::PeerBadge _chatListPeerBadge;
|
mutable Ui::PeerBadge _chatListPeerBadge;
|
||||||
mutable Ui::Text::String _chatListNameText;
|
mutable Ui::Text::String _chatListNameText;
|
||||||
mutable int _chatListNameVersion = 0;
|
mutable int _chatListNameVersion = 0;
|
||||||
|
|
Loading…
Add table
Reference in a new issue