-
Notifications
You must be signed in to change notification settings - Fork 11.1k
fix(profile): stop regenerating the access token when the dialog opens #6726
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
Closed
ENCHIGO
wants to merge
1
commit into
QuantumNous:main
from
ENCHIGO:fix/access-token-no-auto-regenerate
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
Repository: QuantumNous/new-api
Length of output: 6698
🏁 Script executed:
Repository: QuantumNous/new-api
Length of output: 27609
🏁 Script executed:
Repository: QuantumNous/new-api
Length of output: 45372
🌐 Web query:
i18next conditional pluralization ifelse zero one example💡 Result:
In i18next, pluralization is handled via suffix-based naming conventions rather than explicit if-else logic [1][2]. The framework uses the
countvariable to determine which suffix to select based on the language's specific plural rules (powered byIntl.PluralRules) [1][3]. To handle specific cases like zero, one, and others, you define keys in your resource file with the appropriate suffixes [1]. Resource Example: { "key_zero": "No items", "key_one": "{{count}} item", "key_other": "{{count}} items" } Usage: i18next.t('key', { count: 0 }); // -> "No items" i18next.t('key', { count: 1 }); // -> "1 item" i18next.t('key', { count: 5 }); // -> "5 items" Key Concepts: - Suffix Resolution: i18next automatically appends suffixes like _zero, _one, or _other to your base key [1][4]. If a _zero entry is provided, i18next will prioritize it when count is 0, overriding the language's default plural rules [1][2]. - Intl.PluralRules: i18next relies on the native Intl.PluralRules API [1]. In environments without this support (e.g., some legacy environments or specific versions of React Native), you must use a polyfill [1][3]. - ICU Message Format: If you require more complex conditional logic (e.g., specific messages for non-plural numbers like 42 or 13), you can use ICU Message Format within your translation strings [2][5]. This allows for syntax like {count, plural, =0 {None} =42 {Answer} one {One} other {# items}} [2][5]. For simple pluralization, stick to the _one/_other or _zero/_one/_other suffix pattern as it is the standard, optimized approach for i18next [1][4].Citations:
Fix the access token regenerate UI state and confirmation copy.
useAccessToken()starts withtoken === ''and never tracks whether a token was previously created, so the empty state is ambiguous. This causes the regenerate button to use the non-destructive'default'variant when a token is present and the destructive'destructive'variant at the first-generation state.Also,
useAccessToken()cannot distinguish “no token was ever created” from “a token exists but is hidden”, so the confirmation and empty-state copy should not claim that regenerating invalidates a current token. Iftokenremains the only flag, use the absence of a token for the default confirm/empty messaging, and use destruction only when a token is known to exist or the backend reports an existing token.🤖 Prompt for AI Agents