Importation automatique d'un train depuis Rail Planner par partage de l'URL d'un trajet
This commit is contained in:
@ -8,6 +8,8 @@ import { isAuthValid } from '@/utils/features/auth/authSlice'
|
||||
import { ChallengeAction, ChallengeActionPayload } from '@/utils/features/challengeActions/challengeActionsSlice'
|
||||
import { Challenge } from '@/utils/features/challenges/challengesSlice'
|
||||
import { useQuery } from '@tanstack/react-query'
|
||||
import { router } from 'expo-router'
|
||||
import { useShareIntentContext } from 'expo-share-intent'
|
||||
import { ReactNode, useEffect } from 'react'
|
||||
|
||||
export default function GameProvider({ children }: { children: ReactNode }) {
|
||||
@ -108,6 +110,16 @@ export default function GameProvider({ children }: { children: ReactNode }) {
|
||||
}
|
||||
}, [game.currentRunner, challengeActions])
|
||||
|
||||
const { hasShareIntent, shareIntent, resetShareIntent } = useShareIntentContext()
|
||||
useEffect(() => {
|
||||
console.log(hasShareIntent, shareIntent)
|
||||
if (hasShareIntent) {
|
||||
if (!shareIntent.text || !shareIntent.text.includes("eurailapp.com/share"))
|
||||
return resetShareIntent()
|
||||
router.replace('/train')
|
||||
}
|
||||
}, [hasShareIntent])
|
||||
|
||||
return <>
|
||||
{children}
|
||||
</>
|
||||
|
Reference in New Issue
Block a user