-
Notifications
You must be signed in to change notification settings - Fork 175
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
subscription_list: Show @-mention indicator when that applies #875
base: main
Are you sure you want to change the base?
Conversation
838e874
to
2656d84
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
99d2413
to
e159b22
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
39188fd
to
d7a742d
Compare
Thanks @sm-sayedi and @kenclary for the reviews! And currently, we |
9874510
to
e4b4101
Compare
GitHub is showing there's a conflict in lib/widgets/theme.dart, could you resolve that please? |
e4b4101
to
64ac89e
Compare
Sure! just fixed PTAL @chrisbobbe. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! I've read through the first six commits:
69abbbc msglist: Add message to mentions if mentioned
200129e unreads [nfc]: Introduce _reverseStreamsLookup data structure
674c4ad unreads [nfc]: Enhance performance in _isPresentInStreams
6e9afd5 unreads [nfc]: Enhance performance in _removeAllInStreams
195c1de inbox [nfc]: Move AtMentionMarker to unread_count_badge
2e18afd inbox [nfc]: Introduce muted property to AtMentionMarker
with the last two left for next time:
0c52009 subscription_list: Show @-mention marker when that applies
64ac89e subscription_list: Show unread count when hasOnlyMutedMentions
because it looks like there's something to be straightened out in that sixth commit, as noted below. (All of AtMentionMarker
's callers passing muted: true
, which I think doesn't make sense intuitively.)
lib/widgets/theme.dart
Outdated
atMentionMarker: const HSLColor.fromAHSL(0.5, 0, 0, 0.2).toColor(), | ||
atMentionMarker: const HSLColor.fromAHSL(0.7, 0, 0, 0.2).toColor(), | ||
mutedAtMentionMarker: const HSLColor.fromAHSL(0.5, 0, 0, 0.2).toColor(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you explain how you chose both of these colors? I see `atMentionMarker was changed from its previous value, but I don't understand why.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well I've tried to copy the values from the web app.. here is my inspector values:
for unmuted mentions and mentions in inbox screen
hsl(0, 0, 0.2)
or #333
with an opacity 0.7
And for muted mentions:
hsla(0, 0%, 20%, .5)
with an opacity 0.7
Which could be simplified as: hsla(0, 0%, 20%, 0.35)
Please let me know if I am missing something.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It will probably be helpful to link (in the commit message) the lines containing the CSS styles in effect.
2d1e718
to
74a010b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the revision! Left some comments.
When testing this manually, I observed that the @-mention marker shows up for all channels with unreads in the subscription list, even if those channels do not contain unread mentions. So that's something we can cover in tests as well.
lib/model/unreads.dart
Outdated
@@ -236,6 +234,19 @@ class Unreads extends ChangeNotifier { | |||
notifyListeners(); | |||
} | |||
|
|||
void onMessagesFetched(List<Message> messages) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: onSomething
typically names a parameter that takes a callback function. reconcileMessages
might be a better name.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Logically, the new method is different from the group of handleFooEvents
methods, so perhaps we should move it before handleMessageEvent
. This way the implementation matches the current order in tests too.
@@ -230,7 +235,8 @@ class SubscriptionItem extends StatelessWidget { | |||
|
|||
final swatch = colorSwatchFor(context, subscription); | |||
final hasUnreads = (unreadCount > 0); | |||
final opacity = subscription.isMuted ? 0.55 : 1.0; | |||
const mutedOpacity = 0.55; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be helpful to link the source of the opacity.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure if I got it correctly; I just used the same one that we've used before for the channel name and unread count badge.
Are you suggesting to link it to zulip mobile or web design?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will be helpful for efficiently checking for @-mention in subscription_list.
AtMentionMarker is going to be used in subscription_list as well as inbox, so it would be better to reuse it by having it declared as a public class.
74a010b
to
a635d4f
Compare
final hasOnlyMutedMentions = !subscription.isMuted && hasMentions | ||
&& !channelsWithUnmutedMentions.contains(subscription.streamId); | ||
final mutedUnreadCount = hasOnlyMutedMentions && unreadCount == 0 ? | ||
unreadsModel!.countAll(subscription.streamId) : 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It feels like there's a lot of different conditions that are interacting here, which means there are a lot of different cases for how this can end up behaving. I can't easily tell from reading this code what all those cases are and what its behavior is in all of them, which makes it hard to tell if the behavior is what we want.
Can you try laying out (just in text, in this thread) what you believe the different cases are for a given channel, and how you believe this screen should behave in each case? Then we can discuss at that level what behavior we want, and then go back to the code and make sure the code reflects that behavior.
(Ultimately I suspect we can express the desired behavior with somewhat simpler logic than this.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree with Greg that laying this out will be helpful.
Adding the @-markers to the SubscriptionItem
, in addition to the unreads seem to complicate the widget more. Perhaps we should be cautious about adding more flags to that widget and simplify these conditions.
child: UnreadCountBadge( | ||
count: mutedUnreadCount, | ||
backgroundColor: swatch, | ||
bold: true)), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like the later part is mostly identical to the previous branch except for the opacity/unread count. I think it would be beneficial to find a way that do not couple AtMentionMarker
with UnreadCountBadge
, so that each has individual logic, making the change easier to verify.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For example, we can have something like (not sure if the conditions are right):
if (hasMentions) ...[
AtMentionMarker(muted: hasOnlyMutedMentions || subscription.isMuted)
]
that is adjancent to but independent from the UnreadCountBadge
branches
Fixes: #747
unreads changes here are reflections of what web has at unread.ts