Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3408599
D8047.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
3 KB
Referenced Files
None
Subscribers
None
D8047.diff
View Options
diff --git a/native/avatars/edit-user-avatar-provider.react.js b/native/avatars/edit-user-avatar-provider.react.js
--- a/native/avatars/edit-user-avatar-provider.react.js
+++ b/native/avatars/edit-user-avatar-provider.react.js
@@ -36,6 +36,7 @@
+updateImageUserAvatar: (selection: NativeMediaSelection) => Promise<void>,
+setUserAvatar: (avatarRequest: UpdateUserAvatarRequest) => Promise<void>,
+setRegistrationMode: (registrationMode: RegistrationMode) => void,
+ +registrationModeEnabled: boolean,
};
const EditUserAvatarContext: React.Context<?EditUserAvatarContextType> =
@@ -147,6 +148,7 @@
[registrationMode, updateUserAvatarCall, dispatchActionPromise],
);
+ const registrationModeEnabled = registrationMode.registrationMode === 'on';
const context = React.useMemo(
() => ({
userAvatarSaveInProgress,
@@ -154,6 +156,7 @@
updateImageUserAvatar,
setUserAvatar,
setRegistrationMode,
+ registrationModeEnabled,
}),
[
userAvatarSaveInProgress,
@@ -161,6 +164,7 @@
updateImageUserAvatar,
setUserAvatar,
setRegistrationMode,
+ registrationModeEnabled,
],
);
diff --git a/native/avatars/edit-user-avatar.react.js b/native/avatars/edit-user-avatar.react.js
--- a/native/avatars/edit-user-avatar.react.js
+++ b/native/avatars/edit-user-avatar.react.js
@@ -16,6 +16,8 @@
import {
EmojiUserAvatarCreationRouteName,
UserAvatarCameraModalRouteName,
+ EmojiAvatarSelectionRouteName,
+ RegistrationUserAvatarCameraModalRouteName,
} from '../navigation/route-names.js';
import { useSelector } from '../redux/redux-utils.js';
import { useStyles } from '../themes/colors.js';
@@ -30,6 +32,7 @@
userAvatarSaveInProgress,
selectFromGalleryAndUpdateUserAvatar,
setUserAvatar,
+ registrationModeEnabled,
} = editUserAvatarContext;
const currentUserInfo = useSelector(state => state.currentUserInfo);
@@ -44,13 +47,25 @@
const { navigate } = useNavigation();
- const navigateToUserEmojiAvatarCreation = React.useCallback(() => {
- navigate(EmojiUserAvatarCreationRouteName);
- }, [navigate]);
+ const usernameOrEthAddress = userInfo?.username;
+ const navigateToEmojiSelection = React.useCallback(() => {
+ if (!registrationModeEnabled) {
+ navigate(EmojiUserAvatarCreationRouteName);
+ return;
+ }
+ navigate<'EmojiAvatarSelection'>({
+ name: EmojiAvatarSelectionRouteName,
+ params: { usernameOrEthAddress },
+ });
+ }, [navigate, registrationModeEnabled, usernameOrEthAddress]);
const navigateToCamera = React.useCallback(() => {
- navigate(UserAvatarCameraModalRouteName);
- }, [navigate]);
+ navigate(
+ registrationModeEnabled
+ ? RegistrationUserAvatarCameraModalRouteName
+ : UserAvatarCameraModalRouteName,
+ );
+ }, [navigate, registrationModeEnabled]);
const setENSUserAvatar = React.useCallback(() => {
setUserAvatar({ type: 'ens' });
@@ -63,7 +78,7 @@
const hasCurrentAvatar = !!userInfo?.avatar;
const actionSheetConfig = React.useMemo(() => {
const configOptions = [
- { id: 'emoji', onPress: navigateToUserEmojiAvatarCreation },
+ { id: 'emoji', onPress: navigateToEmojiSelection },
{ id: 'image', onPress: selectFromGalleryAndUpdateUserAvatar },
{ id: 'camera', onPress: navigateToCamera },
];
@@ -81,7 +96,7 @@
hasCurrentAvatar,
ensAvatarURI,
navigateToCamera,
- navigateToUserEmojiAvatarCreation,
+ navigateToEmojiSelection,
removeUserAvatar,
setENSUserAvatar,
selectFromGalleryAndUpdateUserAvatar,
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Thu, Dec 5, 12:01 PM (17 h, 11 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2616999
Default Alt Text
D8047.diff (3 KB)
Attached To
Mode
D8047: [native] Make EditUserAvatar component conditionally navigate to registration screens
Attached
Detach File
Event Timeline
Log In to Comment