-
Notifications
You must be signed in to change notification settings - Fork 11.1k
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
[FIX] Message_AllowedMaxSize fails for emoji sequences #10431
Conversation
6a0d1fe
to
0c9dfc2
Compare
0c9dfc2
to
d458112
Compare
Is this working only for :shortname: ? Or is it covering also the case where the user types the actual "👨👨👧👦" emoji instead of its :shortname: . From the iOS emoji keyboard for instance. When I said emoji sequences I meant unicode sequences. |
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 @c0dzilla ..
looking at the code it is only taking care of :emojis:
and not unicode ones.. can you please confirm that and make sure you have the same behavior for both (treating them as only one character)?
there is function called emojione.shortnameToUnicode
that might help you.
595f344
to
e2c5d13
Compare
@sampaiodiego I've converted emoji unicodes to shortnames using |
@c0dzilla @sampaiodiego we need a better solution than this. Converting back to shortname would imply that this solution only works for unicode graphemes with a corresponding shortname, which is very limiting. The iOS App for instance has many more emojis than in the Web App. We need a generic solution for counting unicode graphemes. From what I've searched, it's non-trivial in JS and we may need a new dependency, but I think it's worth it. |
Here is a possible solution https://stackoverflow.com/a/46085089 |
99812f1
to
ba74537
Compare
@sampaiodiego @graywolf336 please have a look :) |
3f0119c
to
1f3bd47
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.
I really liked your solution, but I got some points, please see if my questions make sense for you
} | ||
return match; | ||
}); | ||
return message && RocketChat.messageProperties(adjustedMessage).length > this.messageMaxSize; |
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 test on 'message' should not be done before?
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, sorry about that 😅
@@ -554,7 +554,13 @@ this.ChatMessages = class ChatMessages { | |||
} | |||
|
|||
isMessageTooLong(message) { | |||
return message && message.length > this.messageMaxSize; | |||
const adjustedMessage = message.replace(/:\w+:/gm, (match) => { |
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 we have this replace in two places... maybe use an export/import? (:
728ca2f
to
2053ec1
Compare
@ggazzo I've made the changes |
Closes #10422
This pr ensures emojis are treated as single characters when determining if message size exceeds allowed limit, for better experience.
Taking same example as mentioned in issue, if max allowed size is 10
now works and has effective size 10.