-
Notifications
You must be signed in to change notification settings - Fork 306
content: Handle @-topic mentions #1071
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
Conversation
55f6453
to
48f31fb
Compare
(Rebased to main) |
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 working on this. Left some comments. This looks good to me!
lib/model/content.dart
Outdated
enum UserMentionType { user, userGroup } | ||
|
||
class UserMentionNode extends InlineContainerNode { | ||
class UserMentionNode extends MentionNode { | ||
const UserMentionNode({ | ||
super.debugHtmlNode, | ||
required super.nodes, |
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: the comments below and in the body should move with MentionNode
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.
Hmm, I'm not sure how the comment about silent mentions would apply to this generic MentionNode
, since it's being introduced for @topic
mention and not sure how a silent @topic
would work. I feel this comment is specific to UserMentionNode
.
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.
Oh I see! Yeah that makes sense.
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.
A silent @-topic mention might not be super useful, but it does exist:
https://chat.zulip.org/#narrow/channel/7-test-here/topic/mention/near/2007548
test/widgets/content_test.dart
Outdated
@@ -684,6 +684,47 @@ void main() { | |||
// TODO(#647): | |||
// testFontWeight('non-silent self-user mention in bold context', | |||
// expectedWght: 800, // [etc.] | |||
|
|||
testContentSmoke(ContentExample.topicMentionPlain); | |||
testContentSmoke(ContentExample.topicMentionSilent); |
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: looks like the other smoke tests are up top in this group. Let's move these there too.
@@ -180,6 +180,26 @@ class ContentExample { | |||
expectedText: 'all', | |||
'<p><span class="silent user-mention" data-user-id="*">all</span></p>', | |||
const UserMentionNode(nodes: [TextNode('all')])); | |||
static final topicMentionPlain = ContentExample.inline( |
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: blank line before this
48f31fb
to
612ae1f
Compare
Thanks for the review @PIG208! |
Looks good to me! Marking this for Greg's review. |
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 @rajveermalviya, and thanks @PIG208 for the previous review!
Let's actually handle this within the existing class UserMentionNode. It's meant to encompass not only mentions of individual users, but of sets of users either via user groups, the current channel, the current topic, or any other such features we might introduce in the future. And it's already how we currently handle @-channel mentions.
To distinguish @-topic mentions from mentions of individual users, we can use the mentionType
field that's sketched in a comment, and the currently-unused UserMentionType enum. That can happen in a separate commit, either before or after the commit that adds @-topic mentions in the first place; if we introduce @-topic mentions first (and just give them the same background as direct user mentions), their treatment isn't any worse than what we have now for @-channel.
lib/model/content.dart
Outdated
enum UserMentionType { user, userGroup } | ||
|
||
class UserMentionNode extends InlineContainerNode { | ||
class UserMentionNode extends MentionNode { | ||
const UserMentionNode({ | ||
super.debugHtmlNode, | ||
required super.nodes, |
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.
A silent @-topic mention might not be super useful, but it does exist:
https://chat.zulip.org/#narrow/channel/7-test-here/topic/mention/near/2007548
lib/model/content.dart
Outdated
@@ -717,6 +721,10 @@ class UserMentionNode extends InlineContainerNode { | |||
// final bool isSilent; // TODO(#647) | |||
} | |||
|
|||
class TopicMentionNode extends MentionNode { |
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 think the name "topic mention" for this, with no further context, will be confusing — it sounds like it might refer to the #**channel > topic**
feature, which is unrelated.
lib/widgets/content.dart
Outdated
// TODO(#646) different for wildcard mentions | ||
color: contentTheme.colorDirectMentionBackground, | ||
color: switch (node) { | ||
UserMentionNode() => contentTheme.colorDirectMentionBackground, | ||
TopicMentionNode() => contentTheme.colorTopicMentionBackground, |
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 seems like this is beginning to implement #646 — we're now giving some wildcard mentions (namely for topics) a different background vs. direct mentions.
Should @-channel mentions get the same background as @-topic?
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.
Yeah! But personal mentions trump channel/topic/group mentions if a message has both kinds.
Original issue for reference (we've probably tweaked colors since then): zulip/zulip#22059
Corner case that needed fixing, in case this helps avoid an issue: zulip/zulip#27654
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 references!
To possibly clarify, though: the immediate code here is about how the mention is formatted within the message, rather than how the message as a whole gets highlighted when it is/has a mention. The latter is tracked under #647. I think that part will probably call for a separate PR from this one, but the formatting of the mention elements themselves might be easy to fold in here.
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.
Updated to remove this part, will open separate PR for #646 later as it's a post-launch issue.
612ae1f
to
6b4bb87
Compare
6b4bb87
to
0edabbf
Compare
Thanks for the review @gnprice! Pushed a new revision, PTAL. |
Thanks! Looks good; merging. |
Fixes: #892