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 @@ -22,8 +22,6 @@ useServerCall, } from 'lib/utils/action-utils.js'; -import { activeThreadSelector } from '../navigation/nav-selectors.js'; -import { NavContext } from '../navigation/navigation-context.js'; import { useSelector } from '../redux/redux-utils.js'; export type EditThreadAvatarContextType = { @@ -48,6 +46,7 @@ +useUploadSelectedMedia: ( setProcessingOrUploadInProgress?: (inProgress: boolean) => mixed, ) => (selection: NativeMediaSelection) => Promise, + +activeThreadID: string, +children: React.Node, }; function EditThreadAvatarProvider(props: Props): React.Node { @@ -55,15 +54,10 @@ displayFailureAlert, selectFromGallery, useUploadSelectedMedia, + activeThreadID, children, } = props; - const navContext = React.useContext(NavContext); - const activeThreadID = React.useMemo( - () => activeThreadSelector(navContext) ?? '', - [navContext], - ); - const updateThreadAvatarLoadingStatus: LoadingStatus = useSelector( createLoadingStatusSelector( changeThreadSettingsActionTypes, diff --git a/native/avatars/native-edit-thread-avatar-provider.react.js b/native/avatars/native-edit-thread-avatar-provider.react.js new file mode 100644 --- /dev/null +++ b/native/avatars/native-edit-thread-avatar-provider.react.js @@ -0,0 +1,43 @@ +// @flow + +import * as React from 'react'; +import { Alert } from 'react-native'; + +import { selectFromGallery, useUploadSelectedMedia } from './avatar-hooks.js'; +import { EditThreadAvatarProvider } from './edit-thread-avatar-provider.react.js'; +import { activeThreadSelector } from '../navigation/nav-selectors.js'; +import { NavContext } from '../navigation/navigation-context.js'; + +const displayAvatarUpdateFailureAlert = () => + Alert.alert( + 'Couldn’t save avatar', + 'Please try again later', + [{ text: 'OK' }], + { cancelable: true }, + ); + +type Props = { + +children: React.Node, +}; +function NativeEditThreadAvatarProvider(props: Props): React.Node { + const { children } = props; + + const navContext = React.useContext(NavContext); + const activeThreadID = React.useMemo( + () => activeThreadSelector(navContext) ?? '', + [navContext], + ); + + return ( + + {children} + + ); +} + +export default NativeEditThreadAvatarProvider; 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, Alert } from 'react-native'; +import { Platform, UIManager, StyleSheet } from 'react-native'; import { GestureHandlerRootView } from 'react-native-gesture-handler'; import Orientation from 'react-native-orientation-locker'; import { @@ -23,11 +23,7 @@ import { actionLogger } from 'lib/utils/action-logger.js'; import { RegistrationContextProvider } from './account/registration/registration-context-provider.react.js'; -import { - selectFromGallery, - useUploadSelectedMedia, -} from './avatars/avatar-hooks.js'; -import { EditThreadAvatarProvider } from './avatars/edit-thread-avatar-provider.react.js'; +import NativeEditThreadAvatarProvider from './avatars/native-edit-thread-avatar-provider.react.js'; import NativeEditUserAvatarProvider from './avatars/native-edit-user-avatar-provider.react.js'; import ChatContextProvider from './chat/chat-context-provider.react.js'; import { FeatureFlagsProvider } from './components/feature-flags-provider.react.js'; @@ -75,14 +71,6 @@ 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(); @@ -276,13 +264,7 @@ - + @@ -306,7 +288,7 @@ - +