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