-
Notifications
You must be signed in to change notification settings - Fork 229
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
Add names characters limit and truncate #1754
base: master
Are you sure you want to change the base?
Conversation
[sr-frontend] [Sat Mar 16 06:43:18 UTC 2024] - Deployed 81e72ee to https://genshin-optimizer-prs.github.io/pr/1754/sr-frontend (Takes 3-5 minutes after this completes to be available) [frontend] [Sat Mar 16 06:44:17 UTC 2024] - Deployed 81e72ee to https://genshin-optimizer-prs.github.io/pr/1754/frontend (Takes 3-5 minutes after this completes to be available) [sr-frontend] [Sat Mar 16 11:23:03 UTC 2024] - Deployed c2df5de to https://genshin-optimizer-prs.github.io/pr/1754/sr-frontend (Takes 3-5 minutes after this completes to be available) [frontend] [Sat Mar 16 11:24:07 UTC 2024] - Deployed c2df5de to https://genshin-optimizer-prs.github.io/pr/1754/frontend (Takes 3-5 minutes after this completes to be available) |
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 more truncation may be needed for team and loadout names:
In format of ( display / max string length in db)
- team ( 100 / 200)
- loadout ( 100 / 200)
- Build (50 /100)
For truncating the string(enforce final length), I'd recommend doing it in the database.
Since all data is validated in the database, ensuring string length should be as well:
code that validates loadout(TeamChar) name string
|
||
// truncate string to a certain length, and add ellipsis if it's longer | ||
export function truncateString(str: string, length: number) { | ||
return str.length > length ? str.slice(0, length) + '...' : str |
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.
return str.length > length ? str.slice(0, length) + '...' : str | |
return str.length > length ? str.slice(0, length - 3) + '...' : str |
By doing it in the database, do you mean truncating the string before saving the names in the database? |
I guess I should be more specific since your function is called |
Describe your changes
Issue or discord link
Testing/validation
Checklist before requesting a review (leave this PR as draft if any part of this list is not done.)
yarn run mini-ci
locally to validate format and lint.