Importation automatique d'un train depuis Rail Planner par partage de l'URL d'un trajet

This commit is contained in:
2024-12-16 17:52:08 +01:00
parent 71b7df0008
commit b726305a44
6 changed files with 74 additions and 51 deletions

View File

@ -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}
</>