Add extra error state to EditUsernameModalBody
This commit is contained in:
parent
47fd4125fe
commit
e12b5fd0af
7 changed files with 16 additions and 5 deletions
|
@ -5643,6 +5643,10 @@
|
|||
"messageformat": "Numbers with more than 2 digits can’t start with 0",
|
||||
"description": "Shown if user has attempted to enter a username with leading 0 in discriminator"
|
||||
},
|
||||
"icu:ProfileEditor--username--too-many-attempts": {
|
||||
"messageformat": "Too many attempts made, please try again later",
|
||||
"description": "Shown if user has made too many attempts to pick a username and has to wait before retrying"
|
||||
},
|
||||
"icu:ProfileEditor--username--unavailable": {
|
||||
"messageformat": "This username is not available",
|
||||
"description": "Shown if the username is not available for registration"
|
||||
|
|
|
@ -53,6 +53,7 @@ export default {
|
|||
CheckCharacters: UsernameReservationError.CheckCharacters,
|
||||
UsernameNotAvailable: UsernameReservationError.UsernameNotAvailable,
|
||||
General: UsernameReservationError.General,
|
||||
TooManyAttempts: UsernameReservationError.TooManyAttempts,
|
||||
},
|
||||
},
|
||||
reservation: {
|
||||
|
|
|
@ -208,6 +208,9 @@ export function EditUsernameModalBody({
|
|||
'icu:ProfileEditor--username--check-discriminator-leading-zero'
|
||||
);
|
||||
}
|
||||
if (error === UsernameReservationError.TooManyAttempts) {
|
||||
return i18n('icu:ProfileEditor--username--too-many-attempts');
|
||||
}
|
||||
// Displayed through confirmation modal below
|
||||
if (
|
||||
error === UsernameReservationError.General ||
|
||||
|
|
|
@ -138,11 +138,10 @@ export async function reserveUsername(
|
|||
return { ok: false, error: ReserveUsernameError.Conflict };
|
||||
}
|
||||
if (error.code === 413 || error.code === 429) {
|
||||
const time = findRetryAfterTimeFromError(error);
|
||||
log.warn(`reserveUsername: got ${error.code}, waiting ${time}ms`);
|
||||
await sleep(time, abortSignal);
|
||||
|
||||
return reserveUsername(options);
|
||||
return {
|
||||
ok: false,
|
||||
error: ReserveUsernameError.TooManyAttempts,
|
||||
};
|
||||
}
|
||||
}
|
||||
if (error instanceof LibSignalErrorBase) {
|
||||
|
|
|
@ -476,6 +476,8 @@ export function reducer(
|
|||
stateError = UsernameReservationError.AllZeroDiscriminator;
|
||||
} else if (error === ReserveUsernameError.LeadingZeroDiscriminator) {
|
||||
stateError = UsernameReservationError.LeadingZeroDiscriminator;
|
||||
} else if (error === ReserveUsernameError.TooManyAttempts) {
|
||||
stateError = UsernameReservationError.TooManyAttempts;
|
||||
} else {
|
||||
throw missingCaseError(error);
|
||||
}
|
||||
|
|
|
@ -43,4 +43,5 @@ export enum UsernameReservationError {
|
|||
NotEnoughDiscriminator = 'NotEnoughDiscriminator',
|
||||
AllZeroDiscriminator = 'AllZeroDiscriminator',
|
||||
LeadingZeroDiscriminator = 'LeadingZeroDiscriminator',
|
||||
TooManyAttempts = 'TooManyAttempts',
|
||||
}
|
||||
|
|
|
@ -19,6 +19,7 @@ export enum ReserveUsernameError {
|
|||
NotEnoughDiscriminator = 'NotEnoughDiscriminator',
|
||||
AllZeroDiscriminator = 'AllZeroDiscriminator',
|
||||
LeadingZeroDiscriminator = 'LeadingZeroDiscriminator',
|
||||
TooManyAttempts = 'TooManyAttempts',
|
||||
}
|
||||
|
||||
export enum ConfirmUsernameResult {
|
||||
|
|
Loading…
Reference in a new issue