Skip to content

Conversation

chrisbobbe
Copy link
Collaborator

Before After
image image
image image

cc @alya

UnreadCountBadge has a needlessly loose API for specifying a
background color, with three options:

1. Channel-colorized: callers are supposed to pass a
   ChannelColorSwatch and the implementation picks
   `unreadCountBadgeBackground` off of that.
2. Any other Color. (ChannelColorSwatch is a Color.)
3. A default color, chosen by the implementation, if `null` is
   passed.

We don't actually have any use for option 2, at least currently, so
we'll remove it next.

The buggy caller here was using option 2 when it should have used
option 1: it wanted a channel-colored background, but it itself
picked `unreadCountBadgeBackground` off of the swatch instead of
passing the whole swatch to UnreadCountBadge for it to do that. That
would have been fine except that the channel-colorized case has its
own associated *text* color, and that's conditioned on whether the
passed background color is a ChannelColorSwatch.
Previously, this widget had three options for the background color:

1. Colorized for a channel: callers could pass a ChannelColorSwatch,
   and the implementation would pick `unreadCountBadgeBackground` off
   of that.
2. Any `Color`.
3. A default, chosen by the implementation.

One caller was using option 2 when option 1 would be a better fit:
it wanted a channel-colored background, but it was picking
`unreadCountBadgeBackground` itself from the ChannelColorSwatch
instead of letting the implementation do that.

After changing that caller to just pass the ChannelColorSwatch
(option 1), no more callers use option 2, so we remove it. Now
UnreadCountBadge has a tighter interface.

Next we'll encapsulate finding the channel color swatch itself, so
callers only need to have a channel ID if they want a
channel-colored background.
@chrisbobbe chrisbobbe added the maintainer review PR ready for review by Zulip maintainers label Oct 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
maintainer review PR ready for review by Zulip maintainers
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants