Skip to content

@-mention markers #509

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

Merged
merged 4 commits into from
Feb 12, 2024
Merged

@-mention markers #509

merged 4 commits into from
Feb 12, 2024

Conversation

sirpengi
Copy link
Contributor

@sirpengi sirpengi commented Feb 8, 2024

This PR is built on top of #510

Fixes: #384

Simulator Screenshot - iPhone 14 - 2024-02-08 at 16 50 20

@sirpengi sirpengi requested a review from gnprice February 8, 2024 16:51
Copy link
Member

@gnprice gnprice left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @sirpengi! Generally this looks good. Small comments below.

class _AtMentionMarker extends StatelessWidget {
const _AtMentionMarker();

static Color markerColor = const HSLColor.fromAHSL(0.5, 0, 0, 0.2).toColor();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
static Color markerColor = const HSLColor.fromAHSL(0.5, 0, 0, 0.2).toColor();
static final markerColor = const HSLColor.fromAHSL(0.5, 0, 0, 0.2).toColor();

(If we wanted to be explicit about the type, it'd be static final Color markerColor = ….)

Comment on lines 455 to 457
isMentioned: isMentioned,
streamCount: data.count,
streamIsMentioned: data.isMentioned,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These "is mentioned" names work if the subject is implicitly taken to be the self-user — the user is mentioned — but because they're attached to objects describing a topic or a stream etc., they sound a lot more like "this topic is mentioned", "this stream is mentioned", etc.

Let's therefore say "has mention" rather than "is mentioned": so hasMention, streamHasMention, and so on.

Comment on lines 145 to 148
final isMentioned = messageIds.any((messageId) => unreadsModel!.mentions.contains(messageId));
topicItems.add((topic, countInTopic, isMentioned, messageIds.last));
countInStream += countInTopic;
if (isMentioned) mentionedInStream = true;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit:

Suggested change
final isMentioned = messageIds.any((messageId) => unreadsModel!.mentions.contains(messageId));
topicItems.add((topic, countInTopic, isMentioned, messageIds.last));
countInStream += countInTopic;
if (isMentioned) mentionedInStream = true;
final isMentioned = messageIds.any((messageId) => unreadsModel!.mentions.contains(messageId));
if (isMentioned) mentionedInStream = true;
topicItems.add((topic, countInTopic, isMentioned, messageIds.last));
countInStream += countInTopic;

This ordering is a bit more consistent internally — mentions, then counts, rather than mention, count, mention — and also keeps this code parallel with the similar code for DMs above.

Comment on lines 357 to 359
header: _AllDmsHeaderItem(
count: allDmsCount,
isMentioned: isMentioned,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems wrong — it's using the is-mentioned flag for the individual DM conversation, but passing it to use for the all-DMs header.

Hmm but I can't actually trigger any symptom from that bug.

… Aha. This header has no effect! That's a pre-existing latent bug in this file. What's happening is that the items of the list view are the entire sections — all DMs, then each stream — and not the individual conversations, so the StickyHeaderItem widgets on the individual conversations never get consulted.

I'll send a quick PR removing those StickyHeaderItems, to avoid causing us similar confusion in the future. Then you can rebase atop that PR, and I think it will slightly simplify some of this code.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Padding(padding: const EdgeInsetsDirectional.only(end: 16),
child: UnreadCountBadge(backgroundColor: subscription.colorSwatch(),
count: count)),
])))));
}
}

class _AtMentionMarker extends StatelessWidget {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These two commits are best squashed together:
ce34ec0 inbox: Show at-mention marker on topics
b6ac522 inbox [nfc]: Pull out _AtMentionMarker

because the latter basically amounts to rethinking how to arrange some of the code added by the former, and so it's simplest to go straight to the revised way of arranging it.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In fact let's squash those together with the next commit, handling streams:
ce34ec0 inbox: Show at-mention marker on topics
b6ac522 inbox [nfc]: Pull out _AtMentionMarker
6e74d2a inbox: Show at-mention marker on streams

That way there isn't an intermediate state where we have @-mention markers on the individual topics but missing on the streams, which feels a little glitchy given expectations set by web. And conversely the squashed commit is still a quite reasonable size.

@sirpengi sirpengi force-pushed the pr-at-mention-markers branch 2 times, most recently from c57bd8a to 1b4adc0 Compare February 9, 2024 17:04
@sirpengi
Copy link
Contributor Author

sirpengi commented Feb 9, 2024

@gnprice ready for review again!

Copy link
Member

@gnprice gnprice left a 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! Generally this all looks good now, pending #510. One nit below.

Comment on lines -249 to +260
// TODO(#384) for streams, show @-mention indicator when it applies
if (hasMention) const _AtMentionMarker(),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit in commit message:

inbox: Show at-mention marker on topics

Should say "topics and streams", since the same commit does it for streams too.

@sirpengi sirpengi force-pushed the pr-at-mention-markers branch from 1b4adc0 to aad1988 Compare February 12, 2024 09:20
@sirpengi
Copy link
Contributor Author

@gnprice Commit message updated per comment, now just waiting on #510

Taken today from Figma at:
  https://www.figma.com/file/1JTNtYo9memgW7vV6d0ygq/Zulip-Mobile?type=design&node-id=171-12359&mode=design&t=LQ4ZzSZnD39eDpDf-0

Exported svg was processed in inkscape to expand strokes to
paths and resulting file cleaned of unnecessary markup.
This will be used later to match other types
of rows.
The `hasMention` flag was added to the abstract
`_HeaderItem` class so `_AllDmsHeaderItem` is
affected by this change. It isn't used in the
DMs header for now so will be hard-coded
as False and changed in the next commit.
@gnprice gnprice force-pushed the pr-at-mention-markers branch from aad1988 to ee99129 Compare February 12, 2024 20:19
@gnprice gnprice merged commit ee99129 into zulip:main Feb 12, 2024
@gnprice
Copy link
Member

gnprice commented Feb 12, 2024

Thanks! Looks good, and #510 is now in, so merging.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Inbox: Show @-mention indicator beside stream unread count badge
2 participants