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 @@ -1,7 +1,6 @@ // @flow import * as React from 'react'; -import { Alert } from 'react-native'; import { updateUserAvatar, @@ -46,19 +45,12 @@ updateUserAvatarActionTypes, ); -const displayFailureAlert = () => - Alert.alert( - 'Couldn’t save avatar', - 'Please try again later', - [{ text: 'OK' }], - { cancelable: true }, - ); - type Props = { + +displayFailureAlert: () => mixed, +children: React.Node, }; function EditUserAvatarProvider(props: Props): React.Node { - const { children } = props; + const { displayFailureAlert, children } = props; const registrationModeRef = React.useRef(registrationModeOff); @@ -108,7 +100,12 @@ dispatchActionPromise(updateUserAvatarActionTypes, promise); await promise; }, - [uploadSelectedMedia, updateUserAvatarCall, dispatchActionPromise], + [ + uploadSelectedMedia, + dispatchActionPromise, + updateUserAvatarCall, + displayFailureAlert, + ], ); const selectFromGalleryAndUpdateUserAvatar = React.useCallback(async () => { @@ -141,7 +138,7 @@ dispatchActionPromise(updateUserAvatarActionTypes, promise); await promise; }, - [updateUserAvatarCall, dispatchActionPromise], + [dispatchActionPromise, updateUserAvatarCall, displayFailureAlert], ); const setRegistrationMode = React.useCallback((mode: RegistrationMode) => { diff --git a/native/root.react.js b/native/root.react.js --- a/native/root.react.js +++ b/native/root.react.js @@ -8,7 +8,7 @@ import * as SplashScreen from 'expo-splash-screen'; import invariant from 'invariant'; import * as React from 'react'; -import { Platform, UIManager, StyleSheet } from 'react-native'; +import { Platform, UIManager, StyleSheet, Alert } from 'react-native'; import { GestureHandlerRootView } from 'react-native-gesture-handler'; import Orientation from 'react-native-orientation-locker'; import { @@ -71,6 +71,14 @@ SplashScreen.preventAutoHideAsync().catch(console.log); +const displayAvatarUpdateFailureAlert = () => + Alert.alert( + 'Couldn’t save avatar', + 'Please try again later', + [{ text: 'OK' }], + { cancelable: true }, + ); + function Root() { const navStateRef = React.useRef(); const navDispatchRef = React.useRef(); @@ -263,7 +271,9 @@ - +