diff --git a/native/avatars/edit-thread-avatar-provider.react.js b/native/avatars/edit-thread-avatar-provider.react.js --- a/native/avatars/edit-thread-avatar-provider.react.js +++ b/native/avatars/edit-thread-avatar-provider.react.js @@ -1,7 +1,6 @@ // @flow import * as React from 'react'; -import { Alert } from 'react-native'; import { changeThreadSettings, @@ -41,19 +40,12 @@ const EditThreadAvatarContext: React.Context = React.createContext(); -const displayFailureAlert = () => - Alert.alert( - 'Couldn’t save avatar', - 'Please try again later', - [{ text: 'OK' }], - { cancelable: true }, - ); - type Props = { + +displayFailureAlert: () => mixed, +children: React.Node, }; function EditThreadAvatarProvider(props: Props): React.Node { - const { children } = props; + const { displayFailureAlert, children } = props; const navContext = React.useContext(NavContext); const activeThreadID = React.useMemo( @@ -133,6 +125,7 @@ [ changeThreadSettingsCall, dispatchActionPromise, + displayFailureAlert, updateThreadAvatarMediaUploadInProgress, uploadSelectedMedia, ], @@ -171,7 +164,7 @@ }); await promise; }, - [changeThreadSettingsCall, dispatchActionPromise], + [changeThreadSettingsCall, dispatchActionPromise, displayFailureAlert], ); const context = React.useMemo( 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(); @@ -264,7 +272,11 @@ - +