Bluesky app fork with some witchin' additions 💫

Fix Android crash by try/catch dialog open (#9335)

authored by samuel.fm and committed by

GitHub ec2c580a 215f97ba

+21 -2
+21 -2
src/components/Dialog/context.ts
··· 13 13 type DialogControlRefProps, 14 14 type DialogOuterProps, 15 15 } from '#/components/Dialog/types' 16 + import {IS_DEV} from '#/env' 16 17 import {BottomSheetSnapPoint} from '../../../modules/bottom-sheet/src/BottomSheet.types' 17 18 18 19 export const Context = createContext<DialogContextProps>({ ··· 50 51 id, 51 52 ref: control, 52 53 open: () => { 53 - control.current.open() 54 + if (control.current) { 55 + control.current.open() 56 + } else { 57 + if (IS_DEV) { 58 + console.warn( 59 + 'Attemped to open a dialog control that was not attached to a dialog!\n' + 60 + 'Please ensure that the Dialog is mounted when calling open/close', 61 + ) 62 + } 63 + } 54 64 }, 55 65 close: cb => { 56 - control.current.close(cb) 66 + if (control.current) { 67 + control.current.close(cb) 68 + } else { 69 + if (IS_DEV) { 70 + console.warn( 71 + 'Attemped to close a dialog control that was not attached to a dialog!\n' + 72 + 'Please ensure that the Dialog is mounted when calling open/close', 73 + ) 74 + } 75 + } 57 76 }, 58 77 }), 59 78 [id, control],