Fixed color update of badges in chat filters strip on palette change.

This commit is contained in:
23rd 2025-02-06 22:19:29 +03:00 committed by John Preston
parent 5e2bc337bc
commit b61befa210
2 changed files with 14 additions and 2 deletions

View file

@ -42,6 +42,13 @@ ChatsFiltersTabs::ChatsFiltersTabs(
}; };
_cachedBadgeHeight = one.height(); _cachedBadgeHeight = one.height();
} }
style::PaletteChanged(
) | rpl::start_with_next([=] {
for (auto &[index, unread] : _unreadCounts) {
unread.cache = cacheUnreadCount(unread.count, unread.muted);
}
update();
}, lifetime());
Ui::DiscreteSlider::setSelectOnPress(false); Ui::DiscreteSlider::setSelectOnPress(false);
} }
@ -88,7 +95,11 @@ void ChatsFiltersTabs::setUnreadCount(int index, int unreadCount, bool mute) {
if (unreadCount) { if (unreadCount) {
_unreadCounts.emplace(index, Unread{ _unreadCounts.emplace(index, Unread{
.cache = cacheUnreadCount(unreadCount, mute), .cache = cacheUnreadCount(unreadCount, mute),
.count = unreadCount, .count = ushort(std::clamp(
unreadCount,
0,
int(std::numeric_limits<ushort>::max()))),
.muted = mute,
}); });
} }
} else { } else {

View file

@ -72,7 +72,8 @@ private:
using Index = int; using Index = int;
struct Unread final { struct Unread final {
QImage cache; QImage cache;
int count = 0; ushort count = 0;
bool muted = false;
}; };
base::flat_map<Index, Unread> _unreadCounts; base::flat_map<Index, Unread> _unreadCounts;
const style::SettingsSlider &_st; const style::SettingsSlider &_st;