Changeset View
Changeset View
Standalone View
Standalone View
native/avatars/edit-thread-avatar.react.js
Show All 24 Lines | function EditThreadAvatar(props: Props): React.Node { | ||||
const styles = useStyles(unboundStyles); | const styles = useStyles(unboundStyles); | ||||
const { threadInfo, disabled } = props; | const { threadInfo, disabled } = props; | ||||
const editThreadAvatarContext = React.useContext(EditThreadAvatarContext); | const editThreadAvatarContext = React.useContext(EditThreadAvatarContext); | ||||
invariant(editThreadAvatarContext, 'editThreadAvatarContext should be set'); | invariant(editThreadAvatarContext, 'editThreadAvatarContext should be set'); | ||||
const { | const { | ||||
threadAvatarSaveInProgress, | threadAvatarSaveInProgress, | ||||
selectFromGalleryAndUpdateThreadAvatar, | selectFromGalleryAndUpdateThreadAvatar, | ||||
removeThreadAvatar, | setThreadAvatar, | ||||
} = editThreadAvatarContext; | } = editThreadAvatarContext; | ||||
const { navigate } = useNavigation(); | const { navigate } = useNavigation(); | ||||
const navigateToThreadEmojiAvatarCreation = React.useCallback(() => { | const navigateToThreadEmojiAvatarCreation = React.useCallback(() => { | ||||
navigate<'EmojiThreadAvatarCreation'>({ | navigate<'EmojiThreadAvatarCreation'>({ | ||||
name: EmojiThreadAvatarCreationRouteName, | name: EmojiThreadAvatarCreationRouteName, | ||||
params: { | params: { | ||||
Show All 11 Lines | function EditThreadAvatar(props: Props): React.Node { | ||||
const navigateToCamera = React.useCallback(() => { | const navigateToCamera = React.useCallback(() => { | ||||
navigate<'ThreadAvatarCameraModal'>({ | navigate<'ThreadAvatarCameraModal'>({ | ||||
name: ThreadAvatarCameraModalRouteName, | name: ThreadAvatarCameraModalRouteName, | ||||
params: { threadID: threadInfo.id }, | params: { threadID: threadInfo.id }, | ||||
}); | }); | ||||
}, [navigate, threadInfo.id]); | }, [navigate, threadInfo.id]); | ||||
const removeAvatar = React.useCallback( | const removeAvatar = React.useCallback( | ||||
() => removeThreadAvatar(threadInfo.id), | () => setThreadAvatar(threadInfo.id, { type: 'remove' }), | ||||
[removeThreadAvatar, threadInfo.id], | [setThreadAvatar, threadInfo.id], | ||||
); | ); | ||||
const actionSheetConfig = React.useMemo(() => { | const actionSheetConfig = React.useMemo(() => { | ||||
const configOptions = [ | const configOptions = [ | ||||
{ id: 'emoji', onPress: navigateToThreadEmojiAvatarCreation }, | { id: 'emoji', onPress: navigateToThreadEmojiAvatarCreation }, | ||||
{ id: 'image', onPress: selectFromGallery }, | { id: 'image', onPress: selectFromGallery }, | ||||
{ id: 'camera', onPress: navigateToCamera }, | { id: 'camera', onPress: navigateToCamera }, | ||||
]; | ]; | ||||
▲ Show 20 Lines • Show All 47 Lines • Show Last 20 Lines |