add entry hook for web
This commit is contained in:
@@ -39,6 +39,7 @@ import {ToastContainer} from 'view/com/util/Toast.web'
|
||||
import {Shell} from 'view/shell/index'
|
||||
import {ThemeProvider as Alf} from '#/alf'
|
||||
import {useColorModeTheme} from '#/alf/util/useColorModeTheme'
|
||||
import {useStarterPackEntry} from '#/components/hooks/useStarterPackEntry'
|
||||
import {Provider as PortalProvider} from '#/components/Portal'
|
||||
import {BackgroundNotificationPreferencesProvider} from '../modules/expo-background-notification-handler/src/BackgroundNotificationHandlerProvider'
|
||||
import I18nProvider from './locale/i18nProvider'
|
||||
@@ -51,6 +52,7 @@ function InnerApp() {
|
||||
const theme = useColorModeTheme()
|
||||
const {_} = useLingui()
|
||||
useIntentHandler()
|
||||
useStarterPackEntry()
|
||||
|
||||
// init
|
||||
useEffect(() => {
|
||||
|
||||
@@ -1,26 +0,0 @@
|
||||
import React from 'react'
|
||||
|
||||
interface IStarterPackEntryContext {
|
||||
isReady?: boolean
|
||||
starterPackId?: string
|
||||
}
|
||||
|
||||
const StarterPackEntryContext = React.createContext<IStarterPackEntryContext>({
|
||||
isReady: false,
|
||||
})
|
||||
export const useStarterPackEntry = () =>
|
||||
React.useContext(StarterPackEntryContext)
|
||||
|
||||
export function StarterPackEntryProvider() {
|
||||
const [state] = React.useState<IStarterPackEntryContext>({
|
||||
isReady: false,
|
||||
})
|
||||
|
||||
React.useEffect(() => {}, [])
|
||||
|
||||
return (
|
||||
<StarterPackEntryContext.Provider value={state}>
|
||||
{children}
|
||||
</StarterPackEntryContext.Provider>
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
import React from 'react'
|
||||
|
||||
import {useSetStarterPack} from 'state/preferences/starter-pack'
|
||||
|
||||
export function useStarterPackEntry() {
|
||||
const setStarterPack = useSetStarterPack()
|
||||
|
||||
React.useEffect(() => {
|
||||
const url = new URL(window.location.href)
|
||||
const pathParts = url.pathname.split('/')
|
||||
if (pathParts[0] === 'start' && pathParts.length === 2) {
|
||||
setStarterPack(pathParts[1])
|
||||
}
|
||||
}, [setStarterPack])
|
||||
}
|
||||
Reference in New Issue
Block a user