-
Notifications
You must be signed in to change notification settings - Fork 308
subscription_list: Show @-mention indicator when that applies #875
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
Changes from all commits
4362559
b3b9f53
2a00ea1
ef6d4c3
b1e8fb7
a635d4f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -185,16 +185,26 @@ class _SubscriptionList extends StatelessWidget { | |
|
||
@override | ||
Widget build(BuildContext context) { | ||
final channelsWithMentions = unreadsModel!.channelsWithUnreadMentions; | ||
final channelsWithUnmutedMentions = unreadsModel!.channelsWithUnmutedMentions; | ||
return SliverList.builder( | ||
itemCount: subscriptions.length, | ||
itemBuilder: (BuildContext context, int index) { | ||
final subscription = subscriptions[index]; | ||
final unreadCount = unreadsModel!.countInChannel(subscription.streamId); | ||
final showMutedUnreadBadge = unreadCount == 0 | ||
&& unreadsModel!.countInChannelNarrow(subscription.streamId) > 0; | ||
final hasMentions = channelsWithMentions.contains(subscription.streamId); | ||
final hasOnlyMutedMentions = !subscription.isMuted && hasMentions | ||
&& !channelsWithUnmutedMentions.contains(subscription.streamId); | ||
final mutedUnreadCount = hasOnlyMutedMentions && unreadCount == 0 ? | ||
unreadsModel!.countAll(subscription.streamId) : 0; | ||
Comment on lines
+198
to
+201
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 commentThe 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 |
||
return SubscriptionItem(subscription: subscription, | ||
unreadCount: unreadCount, | ||
showMutedUnreadBadge: showMutedUnreadBadge); | ||
mutedUnreadCount: mutedUnreadCount, | ||
showMutedUnreadBadge: showMutedUnreadBadge, | ||
hasMentions: hasMentions, | ||
hasOnlyMutedMentions: hasOnlyMutedMentions); | ||
}); | ||
} | ||
} | ||
|
@@ -205,20 +215,27 @@ class SubscriptionItem extends StatelessWidget { | |
super.key, | ||
required this.subscription, | ||
required this.unreadCount, | ||
required this.mutedUnreadCount, | ||
required this.showMutedUnreadBadge, | ||
required this.hasMentions, | ||
required this.hasOnlyMutedMentions, | ||
}); | ||
|
||
final Subscription subscription; | ||
final int unreadCount; | ||
final int mutedUnreadCount; | ||
final bool showMutedUnreadBadge; | ||
final bool hasMentions; | ||
final bool hasOnlyMutedMentions; | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
final designVariables = DesignVariables.of(context); | ||
|
||
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 commentThe 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 commentThe 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 commentThe reason will be displayed to describe this comment to others. Learn more. |
||
final opacity = subscription.isMuted ? mutedOpacity : 1.0; | ||
return Material( | ||
// TODO(design) check if this is the right variable | ||
color: designVariables.background, | ||
|
@@ -258,16 +275,25 @@ class SubscriptionItem extends StatelessWidget { | |
subscription.name)))), | ||
if (hasUnreads) ...[ | ||
const SizedBox(width: 12), | ||
// TODO(#747) show @-mention indicator when it applies | ||
if (hasMentions) AtMentionMarker(muted: !subscription.isMuted && hasOnlyMutedMentions), | ||
Opacity( | ||
opacity: opacity, | ||
child: UnreadCountBadge( | ||
count: unreadCount, | ||
backgroundColor: swatch, | ||
bold: true)), | ||
] else if (hasOnlyMutedMentions && !subscription.isMuted) ...[ | ||
const SizedBox(width: 12), | ||
const AtMentionMarker(muted: true), | ||
Opacity( | ||
opacity: mutedOpacity, | ||
child: UnreadCountBadge( | ||
count: mutedUnreadCount, | ||
backgroundColor: swatch, | ||
bold: true)), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
||
] else if (showMutedUnreadBadge) ...[ | ||
const SizedBox(width: 12), | ||
// TODO(#747) show @-mention indicator when it applies | ||
if (hasMentions) const AtMentionMarker(muted: true), | ||
const MutedUnreadBadge(), | ||
], | ||
const SizedBox(width: 16), | ||
|
Uh oh!
There was an error while loading. Please reload this page.