simplify logic to avoid reusing starter pack flowo n native

This commit is contained in:
Hailey
2024-06-17 21:04:28 -07:00
parent ffdc3dca69
commit f6a77cb561
4 changed files with 17 additions and 34 deletions
@@ -3,20 +3,20 @@ import React from 'react'
import {createStarterPackLinkFromAndroidReferrer} from 'lib/strings/starter-pack'
import {isAndroid} from 'platform/detection'
import {useSetCurrentStarterPack} from 'state/preferences/starter-pack'
import {useUsedStarterPacks} from 'state/preferences/used-starter-packs'
import {useHasCheckedForStarterPack} from 'state/preferences/used-starter-packs'
import SwissArmyKnife from '../../../modules/expo-bluesky-swiss-army'
import GooglePlayReferrer from '../../../modules/expo-google-play-referrer'
export function useStarterPackEntry() {
const [ready, setReady] = React.useState(false)
const setCurrentStarterPack = useSetCurrentStarterPack()
const usedStarterPacks = useUsedStarterPacks()
const hasRan = React.useRef(false)
const hasCheckedForStarterPack = useHasCheckedForStarterPack()
const setHasCheckedForStarterPack = useHasCheckedForStarterPack()
React.useEffect(() => {
if (ready || hasRan.current) return
if (ready || hasCheckedForStarterPack) return
hasRan.current = true
setHasCheckedForStarterPack(true)
;(async () => {
let uri: string | null | undefined
@@ -38,7 +38,12 @@ export function useStarterPackEntry() {
setReady(true)
})()
}, [ready, setCurrentStarterPack, usedStarterPacks])
}, [
ready,
setCurrentStarterPack,
setHasCheckedForStarterPack,
hasCheckedForStarterPack,
])
return ready
}