Skip to content

Commit

Permalink
Fixed color update of badges in chat filters strip on palette change.
Browse files Browse the repository at this point in the history
  • Loading branch information
23rd authored and john-preston committed Feb 10, 2025
1 parent 5e2bc33 commit b61befa
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
13 changes: 12 additions & 1 deletion Telegram/SourceFiles/ui/widgets/chat_filters_tabs_slider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,13 @@ ChatsFiltersTabs::ChatsFiltersTabs(
};
_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);
}

Expand Down Expand Up @@ -88,7 +95,11 @@ void ChatsFiltersTabs::setUnreadCount(int index, int unreadCount, bool mute) {
if (unreadCount) {
_unreadCounts.emplace(index, Unread{
.cache = cacheUnreadCount(unreadCount, mute),
.count = unreadCount,
.count = ushort(std::clamp(
unreadCount,
0,
int(std::numeric_limits<ushort>::max()))),
.muted = mute,
});
}
} else {
Expand Down
3 changes: 2 additions & 1 deletion Telegram/SourceFiles/ui/widgets/chat_filters_tabs_slider.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@ class ChatsFiltersTabs final : public Ui::SettingsSlider {
using Index = int;
struct Unread final {
QImage cache;
int count = 0;
ushort count = 0;
bool muted = false;
};
base::flat_map<Index, Unread> _unreadCounts;
const style::SettingsSlider &_st;
Expand Down

0 comments on commit b61befa

Please sign in to comment.