diff --git a/web/avatars/emoji-avatar-selection-modal.css b/web/avatars/emoji-avatar-selection-modal.css
--- a/web/avatars/emoji-avatar-selection-modal.css
+++ b/web/avatars/emoji-avatar-selection-modal.css
@@ -31,4 +31,5 @@
justify-content: center;
align-items: center;
min-height: 24px;
+ gap: 4px;
}
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
@@ -7,6 +7,7 @@
import { EditUserAvatarContext } from 'lib/components/base-edit-user-avatar-provider.react.js';
import { useModalContext } from 'lib/components/modal-provider.react.js';
+import SWMansionIcon from 'lib/components/SWMansionIcon.react.js';
import {
defaultAnonymousUserEmojiAvatar,
getAvatarForUser,
@@ -33,6 +34,8 @@
const { setUserAvatar, userAvatarSaveInProgress } = editUserAvatarContext;
+ const [errorMessage, setErrorMessage] = React.useState();
+
const currentUserInfo = useSelector(state => state.currentUserInfo);
const currentUserAvatar: ClientAvatar = getAvatarForUser(currentUserInfo);
const defaultUserAvatar: ClientEmojiAvatar = currentUserInfo?.username
@@ -62,17 +65,33 @@
);
const onEmojiSelect = React.useCallback(selection => {
+ setErrorMessage();
setPendingAvatarEmoji(selection.native);
}, []);
- const onSaveAvatar = React.useCallback(
- () => setUserAvatar(pendingEmojiAvatar),
- [pendingEmojiAvatar, setUserAvatar],
- );
+ const onColorSelection = React.useCallback((hex: string) => {
+ setErrorMessage();
+ setPendingAvatarColor(hex);
+ }, []);
+
+ const onSaveAvatar = React.useCallback(async () => {
+ try {
+ await setUserAvatar(pendingEmojiAvatar);
+ } catch {
+ setErrorMessage('Avatar update failed. Please try again.');
+ }
+ }, [pendingEmojiAvatar, setUserAvatar]);
let saveButtonContent;
if (userAvatarSaveInProgress) {
saveButtonContent =