Don't crash when closing dialogs
This commit is contained in:
@@ -2,6 +2,7 @@ import React from 'react'
|
||||
import * as Linking from 'expo-linking'
|
||||
|
||||
import {logEvent} from '#/lib/statsig/statsig'
|
||||
import {logger} from '#/logger'
|
||||
import {isNative} from '#/platform/detection'
|
||||
import {useSession} from '#/state/session'
|
||||
import {useComposerControls} from '#/state/shell'
|
||||
@@ -73,6 +74,9 @@ export function useIntentHandler() {
|
||||
|
||||
if (incomingUrl) {
|
||||
if (previousIntentUrl === incomingUrl) {
|
||||
logger.debug(`useIntentHandler: ignoring duplicate incoming URL`, {
|
||||
incomingUrl,
|
||||
})
|
||||
return
|
||||
}
|
||||
handleIncomingURL(incomingUrl)
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
import React from 'react'
|
||||
|
||||
import {isWeb} from '#/platform/detection'
|
||||
import {DialogControlRefProps} from '#/components/Dialog'
|
||||
import {type DialogControlRefProps} from '#/components/Dialog'
|
||||
import {Provider as GlobalDialogsProvider} from '#/components/dialogs/Context'
|
||||
import {BottomSheetNativeComponent} from '../../../modules/bottom-sheet'
|
||||
|
||||
interface IDialogContext {
|
||||
/**
|
||||
@@ -53,17 +51,15 @@ export function Provider({children}: React.PropsWithChildren<{}>) {
|
||||
const openDialogs = React.useRef<Set<string>>(new Set())
|
||||
|
||||
const closeAllDialogs = React.useCallback(() => {
|
||||
if (isWeb) {
|
||||
openDialogs.current.forEach(id => {
|
||||
const dialog = activeDialogs.current.get(id)
|
||||
if (dialog) dialog.current.close()
|
||||
})
|
||||
openDialogs.current.forEach(id => {
|
||||
const dialog = activeDialogs.current.get(id)
|
||||
if (dialog) {
|
||||
dialog.current.close()
|
||||
openDialogs.current.delete(id)
|
||||
}
|
||||
})
|
||||
|
||||
return openDialogs.current.size > 0
|
||||
} else {
|
||||
BottomSheetNativeComponent.dismissAll()
|
||||
return false
|
||||
}
|
||||
return openDialogs.current.size > 0
|
||||
}, [])
|
||||
|
||||
const setDialogIsOpen = React.useCallback((id: string, isOpen: boolean) => {
|
||||
|
||||
Reference in New Issue
Block a user