Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3407558
D8283.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
2 KB
Referenced Files
None
Subscribers
None
D8283.diff
View Options
diff --git a/web/avatars/emoji-avatar-selection-modal.react.js b/web/avatars/emoji-avatar-selection-modal.react.js
--- a/web/avatars/emoji-avatar-selection-modal.react.js
+++ b/web/avatars/emoji-avatar-selection-modal.react.js
@@ -34,9 +34,8 @@
const { setUserAvatar, userAvatarSaveInProgress } = editUserAvatarContext;
- const [errorMessage, setErrorMessage] = React.useState<?string>();
- const [updateSuccessful, setUpdateSuccessful] =
- React.useState<boolean>(false);
+ const [updateAvatarStatus, setUpdateAvatarStatus] =
+ React.useState<?('success' | 'failure')>();
const currentUserInfo = useSelector(state => state.currentUserInfo);
const currentUserAvatar: ClientAvatar = getAvatarForUser(currentUserInfo);
@@ -67,23 +66,21 @@
);
const onEmojiSelect = React.useCallback(selection => {
- setErrorMessage();
- setUpdateSuccessful(false);
+ setUpdateAvatarStatus();
setPendingAvatarEmoji(selection.native);
}, []);
const onColorSelection = React.useCallback((hex: string) => {
- setErrorMessage();
- setUpdateSuccessful(false);
+ setUpdateAvatarStatus();
setPendingAvatarColor(hex);
}, []);
const onSaveAvatar = React.useCallback(async () => {
try {
await setUserAvatar(pendingEmojiAvatar);
- setUpdateSuccessful(true);
+ setUpdateAvatarStatus('success');
} catch {
- setErrorMessage('Avatar update failed. Please try again.');
+ setUpdateAvatarStatus('failure');
}
}, [pendingEmojiAvatar, setUserAvatar]);
@@ -92,7 +89,7 @@
if (userAvatarSaveInProgress) {
buttonColor = buttonThemes.standard;
saveButtonContent = <LoadingIndicator status="loading" size="medium" />;
- } else if (updateSuccessful) {
+ } else if (updateAvatarStatus === 'success') {
buttonColor = buttonThemes.success;
saveButtonContent = (
<>
@@ -100,12 +97,12 @@
{'Avatar update succeeded.'}
</>
);
- } else if (errorMessage) {
+ } else if (updateAvatarStatus === 'failure') {
buttonColor = buttonThemes.danger;
saveButtonContent = (
<>
<SWMansionIcon icon="warning-circle" size={24} />
- {errorMessage}
+ {'Avatar update failed. Please try again.'}
</>
);
} else {
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Thu, Dec 5, 6:40 AM (14 h, 57 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2616269
Default Alt Text
D8283.diff (2 KB)
Attached To
Mode
D8283: [web] Consolidate `errorMessage` and `updateSuccessful` state in `EmojiAvatarSelectionModal`
Attached
Detach File
Event Timeline
Log In to Comment