-
Notifications
You must be signed in to change notification settings - Fork 155
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
Integrate mentions in the composer #1799
Integrate mentions in the composer #1799
Conversation
8cabddd
to
9270e29
Compare
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## develop #1799 +/- ##
===========================================
+ Coverage 63.40% 63.45% +0.04%
===========================================
Files 1293 1296 +3
Lines 33628 33727 +99
Branches 6982 7002 +20
===========================================
+ Hits 21322 21401 +79
- Misses 9117 9129 +12
- Partials 3189 3197 +8 ☔ View full report in Codecov by Sentry. |
9270e29
to
ab624c6
Compare
📱 Scan the QR code below to install the build (arm64 only) for this PR. |
- Add `MentionSpanProvider`. - Add custom colors needed for mentions. - Use the span provider to render mentions in the composer. - Allow selecting users from the mentions suggestions to insert a mention.
33689de
to
cb33a13
Compare
This works wonderfully! Nice work |
This was broken before.
Thanks for your comment, I hadn't noticed it myself, but I just realised the code is not working as expected: it's supposed to return the first 100 matching results for the mention, but it was actually returning all possible results, so in large rooms it could be quite slow. I just changed that. |
append("mention", mentionSpan, 0) | ||
append(" to the current user and this is a ") | ||
append("mention", mentionSpan2, 0) | ||
append("to other user") |
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.
add space before => " to other user" ?
sealed interface RoomMemberSuggestion { | ||
data object Room : RoomMemberSuggestion | ||
data class Member(val roomMember: RoomMember) : RoomMemberSuggestion | ||
sealed interface MentionSuggestion { |
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'd extract this class outs of this file
|
||
@Suppress("ComposableNaming") | ||
@Composable | ||
fun setup() { |
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.
make private?
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.
Is this method called each time composer
is recomposed?
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.
make private?
I can make it internal
at best, since it's used in the rememberMentionSpanProvider
function.
Is this method called each time composer is recomposed?
I think so, yeah. Since those colors don't change I'm not sure if they will be re-calculated and re-assigned to each property, but I don't see any other way to be able to reach the @Composable
color: we can't use remember
or LaunchedEffect
for that.
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.
Some small remarks otherwise LGTM
Interestingly (prior to your changes 8d7f24e) for me it consistently takes around 1 second to open both in a group chat with a few participants (~6 iirc) as well as Matrix HQ |
It's probably the |
This should now work better: the initial time to display when using |
Kudos, SonarCloud Quality Gate passed! |
Type of change
Content
MentionSpanProvider
to provide the RTE composer with the customReplacementSpan
for mentions.Motivation and context
Closes #1453
Screenshots / GIFs
Tests
@
in the composer.Tested devices
Checklist