Skip to content
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

idea: public method to get size of emoji-only message #26

Closed
Simon-Laux opened this issue Jan 30, 2023 · 1 comment · Fixed by #56
Closed

idea: public method to get size of emoji-only message #26

Simon-Laux opened this issue Jan 30, 2023 · 1 comment · Fixed by #56
Assignees
Labels
enhancement New feature or request

Comments

@Simon-Laux
Copy link
Member

Simon-Laux commented Jan 30, 2023

Emoji only messages consisting of only a few emojis should be displayed in a bigger font-size than other messages on all platforms, afaik android and desktop have this, iOS does not have it yet.

Basically we would move this method to the message parser and make it more efficient
https://github.com/deltachat/deltachat-desktop/blob/308c598d1e615425cad8bee3daadfc84382b384c/src/renderer/components/conversations/emoji.ts#L50-L69

the method could return an enum or number representing the size.

  1. if text not longer than 6 unicode characters
  2. if text only contains emojis
  3. count the emojis and return the size class accordingly

for emoji parsing we could check for character ranges like described here: https://medium.com/reactnative/emojis-in-javascript-f693d0eb79fb (discord recommended that regex in their blog: https://discord.com/blog/how-discord-achieves-native-ios-performance-with-react-native)

Having this method would mean we can get rid of the emoji-regex desktop dependency (which is 140kb in size).
UPDATE: Already used the new regex and removed the dependency in deltachat/deltachat-desktop#3102. Still it makes sense to go for a unified solution for all platforms, especially as the unicode emoji counter method is not implemented in Firefox (https://stackoverflow.com/a/72915759), and such an api might not even be available on older androids.

For rust there is this crate that we could use: https://crates.io/crates/unicode-segmentation

@Simon-Laux Simon-Laux added enhancement New feature or request good first issue Good for newcomers and removed good first issue Good for newcomers labels Jan 30, 2023
@Simon-Laux Simon-Laux self-assigned this Nov 16, 2023
@Simon-Laux
Copy link
Member Author

I think it makes not much change to check size in this method, you should check it before, because passing a long string to the function (especially over language barriers like wasm or jsonrpc) also takes time. So we should rather check the length before.

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

Successfully merging a pull request may close this issue.

1 participant