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

Only colorize valid mentions #52

Open
vanyasem opened this issue Dec 1, 2018 · 5 comments
Open

Only colorize valid mentions #52

vanyasem opened this issue Dec 1, 2018 · 5 comments

Comments

@vanyasem
Copy link

vanyasem commented Dec 1, 2018

Some mentions can be invalid. For example, Telegram only highlights mentions that are in fact valid and existing users.

A simple solution for that would be to have an option to disable auto-coloring, so that I can check for mention validity in a text-watcher and only call colorize() if that mention is in fact valid

@vanyasem
Copy link
Author

vanyasem commented Dec 1, 2018

I've settled with a hack that calls setMentionColor() with the default text color upon creation, and calls setMentionColor() with the accent color once again (overriding the first value) upon detecting a valid mention

(This works for me because in my case only one mention can be used at a time, see #51)

@hanggrian
Copy link
Owner

I've seen issues with similar request. While it is absolutely possible to limit the mention colorization, I can't find a solution that we universally can agree is the best one to achieve it.

For example, an extremely easy solution is to keep a list of Mentionable in SocialView, only mentions that are registered in that list will then be colorized. It's not a perfect solution, since app with large user base will suffer.

Another solution is to provide (String) -> Boolean everytime a mention is being detected, only mentions that return true are being colorized. But in my opinion it poses another issue: what about those app that performs this check asynchronously?

Until we can agree for the best solution, this library keeps it as simple as colorizing all mentions. I would hope that there is some kind of error handling if the mentions interacted by users are indeed non-existent.

@vanyasem
Copy link
Author

vanyasem commented Dec 3, 2018

In the mean time, please-please-please, make an option .setAutoColorize(false), so that i can handle mentions colorization myself when i need it by calling .colorize(). It will partially fix the issue for me

@v1pu2
Copy link

v1pu2 commented Aug 21, 2019

Really, I also need to set the color of mention only when it comes in start of word. No need of color while typing email id or any else word, which contains @ in between. Please fix this issue.

@mathan1987
Copy link

mathan1987 commented Feb 11, 2021

@hendraanggrian
Any updates or any solution for this issue.

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

No branches or pull requests

4 participants