mirror of https://git.lenooby09.tech/LeNooby09/social-app.git
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

fix dialog back button for android (#3428)

* fix types

* remove unused async

* add try/catch

authored by hailey.at and committed by

GitHub cd29dba7 c80dcc56

+38 -22
+36 -15
src/components/Dialog/index.web.tsx
··· 1 1 import React, {useImperativeHandle} from 'react' 2 - import {View, TouchableWithoutFeedback} from 'react-native' 3 - import {FocusScope} from '@tamagui/focus-scope' 4 - import Animated, {FadeInDown, FadeIn} from 'react-native-reanimated' 2 + import {TouchableWithoutFeedback, View} from 'react-native' 3 + import Animated, {FadeIn, FadeInDown} from 'react-native-reanimated' 5 4 import {msg} from '@lingui/macro' 6 5 import {useLingui} from '@lingui/react' 7 - 8 - import {useTheme, atoms as a, useBreakpoints, web, flatten} from '#/alf' 9 - import {Portal} from '#/components/Portal' 6 + import {FocusScope} from '@tamagui/focus-scope' 10 7 11 - import {DialogOuterProps, DialogInnerProps} from '#/components/Dialog/types' 12 - import {Context} from '#/components/Dialog/context' 8 + import {logger} from '#/logger' 9 + import {useDialogStateControlContext} from '#/state/dialogs' 10 + import {atoms as a, flatten, useBreakpoints, useTheme, web} from '#/alf' 13 11 import {Button, ButtonIcon} from '#/components/Button' 12 + import {Context} from '#/components/Dialog/context' 13 + import { 14 + DialogControlProps, 15 + DialogInnerProps, 16 + DialogOuterProps, 17 + } from '#/components/Dialog/types' 14 18 import {TimesLarge_Stroke2_Corner0_Rounded as X} from '#/components/icons/Times' 15 - import {useDialogStateControlContext} from '#/state/dialogs' 19 + import {Portal} from '#/components/Portal' 16 20 17 - export {useDialogControl, useDialogContext} from '#/components/Dialog/context' 21 + export {useDialogContext, useDialogControl} from '#/components/Dialog/context' 18 22 export * from '#/components/Dialog/types' 19 23 export {Input} from '#/components/forms/TextField' 20 24 ··· 37 41 setDialogIsOpen(control.id, true) 38 42 }, [setIsOpen, setDialogIsOpen, control.id]) 39 43 40 - const close = React.useCallback(async () => { 44 + const onCloseInner = React.useCallback(async () => { 41 45 setIsVisible(false) 42 46 await new Promise(resolve => setTimeout(resolve, 150)) 43 47 setIsOpen(false) 44 48 setIsVisible(true) 45 49 setDialogIsOpen(control.id, false) 46 50 onClose?.() 47 - }, [onClose, setIsOpen, setDialogIsOpen, control.id]) 51 + }, [control.id, onClose, setDialogIsOpen]) 52 + 53 + const close = React.useCallback<DialogControlProps['close']>( 54 + cb => { 55 + try { 56 + if (cb && typeof cb === 'function') { 57 + cb() 58 + } 59 + } catch (e: any) { 60 + logger.error(`Dialog closeCallback failed`, { 61 + message: e.message, 62 + }) 63 + } finally { 64 + onCloseInner() 65 + } 66 + }, 67 + [onCloseInner], 68 + ) 48 69 49 70 useImperativeHandle( 50 71 control.ref, ··· 52 73 open, 53 74 close, 54 75 }), 55 - [open, close], 76 + [close, open], 56 77 ) 57 78 58 79 React.useEffect(() => { ··· 65 86 document.addEventListener('keydown', handler) 66 87 67 88 return () => document.removeEventListener('keydown', handler) 68 - }, [isOpen, close]) 89 + }, [close, isOpen]) 69 90 70 91 const context = React.useMemo( 71 92 () => ({ ··· 82 103 <TouchableWithoutFeedback 83 104 accessibilityHint={undefined} 84 105 accessibilityLabel={_(msg`Close active dialog`)} 85 - onPress={close}> 106 + onPress={onCloseInner}> 86 107 <View 87 108 style={[ 88 109 web(a.fixed),
+1 -2
src/components/Prompt.tsx
··· 135 135 const {gtMobile} = useBreakpoints() 136 136 const {close} = Dialog.useDialogContext() 137 137 const handleOnPress = React.useCallback(() => { 138 - close() 139 - onPress() 138 + close(onPress) 140 139 }, [close, onPress]) 141 140 142 141 return (
+1 -5
src/view/com/composer/Composer.tsx
··· 508 508 title={_(msg`Discard draft?`)} 509 509 description={_(msg`Are you sure you'd like to discard this draft?`)} 510 510 onConfirm={() => { 511 - if (isWeb) { 512 - onClose() 513 - } else { 514 - discardPromptControl.close(onClose) 515 - } 511 + discardPromptControl.close(onClose) 516 512 }} 517 513 confirmButtonCta={_(msg`Discard`)} 518 514 confirmButtonColor="negative"