Move intent handler to a child of InnerApp (#5695)
This commit is contained in:
@@ -14,7 +14,6 @@ import * as SplashScreen from 'expo-splash-screen'
|
|||||||
import {msg} from '@lingui/macro'
|
import {msg} from '@lingui/macro'
|
||||||
import {useLingui} from '@lingui/react'
|
import {useLingui} from '@lingui/react'
|
||||||
|
|
||||||
import {useIntentHandler} from '#/lib/hooks/useIntentHandler'
|
|
||||||
import {QueryProvider} from '#/lib/react-query'
|
import {QueryProvider} from '#/lib/react-query'
|
||||||
import {
|
import {
|
||||||
initialize,
|
initialize,
|
||||||
@@ -85,7 +84,6 @@ function InnerApp() {
|
|||||||
const theme = useColorModeTheme()
|
const theme = useColorModeTheme()
|
||||||
const {_} = useLingui()
|
const {_} = useLingui()
|
||||||
|
|
||||||
useIntentHandler()
|
|
||||||
const hasCheckedReferrer = useStarterPackEntry()
|
const hasCheckedReferrer = useStarterPackEntry()
|
||||||
|
|
||||||
// init
|
// init
|
||||||
|
|||||||
@@ -13,6 +13,9 @@ type IntentType = 'compose' | 'verify-email'
|
|||||||
|
|
||||||
const VALID_IMAGE_REGEX = /^[\w.:\-_/]+\|\d+(\.\d+)?\|\d+(\.\d+)?$/
|
const VALID_IMAGE_REGEX = /^[\w.:\-_/]+\|\d+(\.\d+)?\|\d+(\.\d+)?$/
|
||||||
|
|
||||||
|
// This needs to stay outside of react to persist between account switches
|
||||||
|
let previousIntentUrl = ''
|
||||||
|
|
||||||
export function useIntentHandler() {
|
export function useIntentHandler() {
|
||||||
const incomingUrl = Linking.useURL()
|
const incomingUrl = Linking.useURL()
|
||||||
const composeIntent = useComposeIntent()
|
const composeIntent = useComposeIntent()
|
||||||
@@ -68,7 +71,13 @@ export function useIntentHandler() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (incomingUrl) handleIncomingURL(incomingUrl)
|
if (incomingUrl) {
|
||||||
|
if (previousIntentUrl === incomingUrl) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
handleIncomingURL(incomingUrl)
|
||||||
|
previousIntentUrl = incomingUrl
|
||||||
|
}
|
||||||
}, [incomingUrl, composeIntent, verifyEmailIntent])
|
}, [incomingUrl, composeIntent, verifyEmailIntent])
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ import {StatusBar} from 'expo-status-bar'
|
|||||||
import {useNavigation, useNavigationState} from '@react-navigation/native'
|
import {useNavigation, useNavigationState} from '@react-navigation/native'
|
||||||
|
|
||||||
import {useDedupe} from '#/lib/hooks/useDedupe'
|
import {useDedupe} from '#/lib/hooks/useDedupe'
|
||||||
|
import {useIntentHandler} from '#/lib/hooks/useIntentHandler'
|
||||||
import {useNotificationsHandler} from '#/lib/hooks/useNotificationHandler'
|
import {useNotificationsHandler} from '#/lib/hooks/useNotificationHandler'
|
||||||
import {usePalette} from '#/lib/hooks/usePalette'
|
import {usePalette} from '#/lib/hooks/usePalette'
|
||||||
import {useNotificationsRegistration} from '#/lib/notifications/notifications'
|
import {useNotificationsRegistration} from '#/lib/notifications/notifications'
|
||||||
@@ -129,6 +130,8 @@ export const Shell: React.FC = function ShellImpl() {
|
|||||||
const {fullyExpandedCount} = useDialogStateControlContext()
|
const {fullyExpandedCount} = useDialogStateControlContext()
|
||||||
const pal = usePalette('default')
|
const pal = usePalette('default')
|
||||||
const theme = useTheme()
|
const theme = useTheme()
|
||||||
|
useIntentHandler()
|
||||||
|
|
||||||
React.useEffect(() => {
|
React.useEffect(() => {
|
||||||
if (isAndroid) {
|
if (isAndroid) {
|
||||||
NavigationBar.setBackgroundColorAsync(theme.palette.default.background)
|
NavigationBar.setBackgroundColorAsync(theme.palette.default.background)
|
||||||
|
|||||||
Reference in New Issue
Block a user