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",
|
"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"
|
"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": {
|
"icu:ProfileEditor--username--unavailable": {
|
||||||
"messageformat": "This username is not available",
|
"messageformat": "This username is not available",
|
||||||
"description": "Shown if the username is not available for registration"
|
"description": "Shown if the username is not available for registration"
|
||||||
|
|
|
@ -53,6 +53,7 @@ export default {
|
||||||
CheckCharacters: UsernameReservationError.CheckCharacters,
|
CheckCharacters: UsernameReservationError.CheckCharacters,
|
||||||
UsernameNotAvailable: UsernameReservationError.UsernameNotAvailable,
|
UsernameNotAvailable: UsernameReservationError.UsernameNotAvailable,
|
||||||
General: UsernameReservationError.General,
|
General: UsernameReservationError.General,
|
||||||
|
TooManyAttempts: UsernameReservationError.TooManyAttempts,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
reservation: {
|
reservation: {
|
||||||
|
|
|
@ -208,6 +208,9 @@ export function EditUsernameModalBody({
|
||||||
'icu:ProfileEditor--username--check-discriminator-leading-zero'
|
'icu:ProfileEditor--username--check-discriminator-leading-zero'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
if (error === UsernameReservationError.TooManyAttempts) {
|
||||||
|
return i18n('icu:ProfileEditor--username--too-many-attempts');
|
||||||
|
}
|
||||||
// Displayed through confirmation modal below
|
// Displayed through confirmation modal below
|
||||||
if (
|
if (
|
||||||
error === UsernameReservationError.General ||
|
error === UsernameReservationError.General ||
|
||||||
|
|
|
@ -138,11 +138,10 @@ export async function reserveUsername(
|
||||||
return { ok: false, error: ReserveUsernameError.Conflict };
|
return { ok: false, error: ReserveUsernameError.Conflict };
|
||||||
}
|
}
|
||||||
if (error.code === 413 || error.code === 429) {
|
if (error.code === 413 || error.code === 429) {
|
||||||
const time = findRetryAfterTimeFromError(error);
|
return {
|
||||||
log.warn(`reserveUsername: got ${error.code}, waiting ${time}ms`);
|
ok: false,
|
||||||
await sleep(time, abortSignal);
|
error: ReserveUsernameError.TooManyAttempts,
|
||||||
|
};
|
||||||
return reserveUsername(options);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (error instanceof LibSignalErrorBase) {
|
if (error instanceof LibSignalErrorBase) {
|
||||||
|
|
|
@ -476,6 +476,8 @@ export function reducer(
|
||||||
stateError = UsernameReservationError.AllZeroDiscriminator;
|
stateError = UsernameReservationError.AllZeroDiscriminator;
|
||||||
} else if (error === ReserveUsernameError.LeadingZeroDiscriminator) {
|
} else if (error === ReserveUsernameError.LeadingZeroDiscriminator) {
|
||||||
stateError = UsernameReservationError.LeadingZeroDiscriminator;
|
stateError = UsernameReservationError.LeadingZeroDiscriminator;
|
||||||
|
} else if (error === ReserveUsernameError.TooManyAttempts) {
|
||||||
|
stateError = UsernameReservationError.TooManyAttempts;
|
||||||
} else {
|
} else {
|
||||||
throw missingCaseError(error);
|
throw missingCaseError(error);
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,4 +43,5 @@ export enum UsernameReservationError {
|
||||||
NotEnoughDiscriminator = 'NotEnoughDiscriminator',
|
NotEnoughDiscriminator = 'NotEnoughDiscriminator',
|
||||||
AllZeroDiscriminator = 'AllZeroDiscriminator',
|
AllZeroDiscriminator = 'AllZeroDiscriminator',
|
||||||
LeadingZeroDiscriminator = 'LeadingZeroDiscriminator',
|
LeadingZeroDiscriminator = 'LeadingZeroDiscriminator',
|
||||||
|
TooManyAttempts = 'TooManyAttempts',
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,6 +19,7 @@ export enum ReserveUsernameError {
|
||||||
NotEnoughDiscriminator = 'NotEnoughDiscriminator',
|
NotEnoughDiscriminator = 'NotEnoughDiscriminator',
|
||||||
AllZeroDiscriminator = 'AllZeroDiscriminator',
|
AllZeroDiscriminator = 'AllZeroDiscriminator',
|
||||||
LeadingZeroDiscriminator = 'LeadingZeroDiscriminator',
|
LeadingZeroDiscriminator = 'LeadingZeroDiscriminator',
|
||||||
|
TooManyAttempts = 'TooManyAttempts',
|
||||||
}
|
}
|
||||||
|
|
||||||
export enum ConfirmUsernameResult {
|
export enum ConfirmUsernameResult {
|
||||||
|
|
Loading…
Reference in a new issue