handle used URLs nicely
This commit is contained in:
@@ -102,6 +102,7 @@ export function StepFinished() {
|
|||||||
initialFeed: 'following',
|
initialFeed: 'following',
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
console.log('ADDING PACK')
|
||||||
addUsedStarterPack(makeStarterPackLink(starterPack))
|
addUsedStarterPack(makeStarterPackLink(starterPack))
|
||||||
}
|
}
|
||||||
})(),
|
})(),
|
||||||
|
|||||||
@@ -287,6 +287,20 @@ function LandingScreenInner({
|
|||||||
)}
|
)}
|
||||||
</View>
|
</View>
|
||||||
</View>
|
</View>
|
||||||
|
<Button
|
||||||
|
label={_(msg`Signup without a starter pack`)}
|
||||||
|
variant="ghost"
|
||||||
|
color="secondary"
|
||||||
|
size="medium"
|
||||||
|
style={[a.mt_2xl]}
|
||||||
|
onPress={() => {
|
||||||
|
setCurrentStarterPack(undefined)
|
||||||
|
setScreenState(LoggedOutScreenState.S_CreateAccount)
|
||||||
|
}}>
|
||||||
|
<ButtonText>
|
||||||
|
<Trans>Signup without a starter pack</Trans>
|
||||||
|
</ButtonText>
|
||||||
|
</Button>
|
||||||
</ScrollView>
|
</ScrollView>
|
||||||
<AppClipOverlay
|
<AppClipOverlay
|
||||||
visible={appClipOverlayVisible}
|
visible={appClipOverlayVisible}
|
||||||
|
|||||||
@@ -16,7 +16,9 @@ const stateContext = React.createContext<StateContext>(undefined)
|
|||||||
const setContext = React.createContext<SetContext>((_: StateContext) => {})
|
const setContext = React.createContext<SetContext>((_: StateContext) => {})
|
||||||
|
|
||||||
export function Provider({children}: {children: React.ReactNode}) {
|
export function Provider({children}: {children: React.ReactNode}) {
|
||||||
const [state, setState] = React.useState<StateContext>()
|
const [state, setState] = React.useState<StateContext>(() =>
|
||||||
|
persisted.get('currentStarterPack'),
|
||||||
|
)
|
||||||
|
|
||||||
const setStateWrapped = (v: StateContext) => {
|
const setStateWrapped = (v: StateContext) => {
|
||||||
setState(v)
|
setState(v)
|
||||||
|
|||||||
@@ -9,9 +9,12 @@ const stateContext = React.createContext<StateContext>([])
|
|||||||
const setContext = React.createContext<SetContext>((_: string) => {})
|
const setContext = React.createContext<SetContext>((_: string) => {})
|
||||||
|
|
||||||
export function Provider({children}: {children: React.ReactNode}) {
|
export function Provider({children}: {children: React.ReactNode}) {
|
||||||
const [state, setState] = React.useState<StateContext>([])
|
const [state, setState] = React.useState<StateContext>(() =>
|
||||||
|
persisted.get('usedStarterPacks'),
|
||||||
|
)
|
||||||
|
|
||||||
const setStateWrapped = (v: string) => {
|
const setStateWrapped = (v: string) => {
|
||||||
|
console.log('ADDING!!!', v)
|
||||||
persisted.write('usedStarterPacks', [...(state ? state : []), v])
|
persisted.write('usedStarterPacks', [...(state ? state : []), v])
|
||||||
setState(prev => [...(prev ? prev : []), v])
|
setState(prev => [...(prev ? prev : []), v])
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ import {
|
|||||||
useCurrentStarterPack,
|
useCurrentStarterPack,
|
||||||
useSetCurrentStarterPack,
|
useSetCurrentStarterPack,
|
||||||
} from 'state/preferences/starter-pack'
|
} from 'state/preferences/starter-pack'
|
||||||
|
import {useUsedStarterPacks} from 'state/preferences/used-starter-packs'
|
||||||
import {useLoggedOutViewControls} from 'state/shell/logged-out'
|
import {useLoggedOutViewControls} from 'state/shell/logged-out'
|
||||||
import {FeedPage} from 'view/com/feeds/FeedPage'
|
import {FeedPage} from 'view/com/feeds/FeedPage'
|
||||||
import {Pager, PagerRef, RenderTabBarFnProps} from 'view/com/pager/Pager'
|
import {Pager, PagerRef, RenderTabBarFnProps} from 'view/com/pager/Pager'
|
||||||
@@ -41,18 +42,27 @@ export function HomeScreen(props: Props) {
|
|||||||
const {data: pinnedFeedInfos, isLoading: isPinnedFeedsLoading} =
|
const {data: pinnedFeedInfos, isLoading: isPinnedFeedsLoading} =
|
||||||
usePinnedFeedsInfos()
|
usePinnedFeedsInfos()
|
||||||
const currentStarterPack = useCurrentStarterPack()
|
const currentStarterPack = useCurrentStarterPack()
|
||||||
|
const usedStarterPacks = useUsedStarterPacks()
|
||||||
const {setShowLoggedOut, requestSwitchToAccount} = useLoggedOutViewControls()
|
const {setShowLoggedOut, requestSwitchToAccount} = useLoggedOutViewControls()
|
||||||
|
|
||||||
React.useEffect(() => {
|
React.useEffect(() => {
|
||||||
if (currentStarterPack && !currentStarterPack?.initialFeed) {
|
if (currentStarterPack && !currentStarterPack?.initialFeed) {
|
||||||
setShowLoggedOut(true)
|
// In test environments, the URL won't start with `https://bsky.app`, so we want to find it by the route
|
||||||
requestSwitchToAccount({requestedAccount: 'starterpack'})
|
try {
|
||||||
|
const route = new URL(currentStarterPack.uri).pathname
|
||||||
|
const foundIndex = usedStarterPacks?.findIndex(p => p.includes(route))
|
||||||
|
if (foundIndex === -1) {
|
||||||
|
setShowLoggedOut(true)
|
||||||
|
requestSwitchToAccount({requestedAccount: 'starterpack'})
|
||||||
|
}
|
||||||
|
} catch {}
|
||||||
}
|
}
|
||||||
}, [
|
}, [
|
||||||
setShowLoggedOut,
|
setShowLoggedOut,
|
||||||
requestSwitchToAccount,
|
requestSwitchToAccount,
|
||||||
currentStarterPack?.initialFeed,
|
currentStarterPack?.initialFeed,
|
||||||
currentStarterPack,
|
currentStarterPack,
|
||||||
|
usedStarterPacks,
|
||||||
])
|
])
|
||||||
|
|
||||||
if (preferences && pinnedFeedInfos && !isPinnedFeedsLoading) {
|
if (preferences && pinnedFeedInfos && !isPinnedFeedsLoading) {
|
||||||
@@ -103,6 +113,10 @@ function HomeScreenReady({
|
|||||||
const lastPagerReportedIndexRef = React.useRef(selectedIndex)
|
const lastPagerReportedIndexRef = React.useRef(selectedIndex)
|
||||||
React.useLayoutEffect(() => {
|
React.useLayoutEffect(() => {
|
||||||
let initialIndex = selectedIndex
|
let initialIndex = selectedIndex
|
||||||
|
console.log(
|
||||||
|
'currentStarterPack.initialFeed',
|
||||||
|
currentStarterPack?.initialFeed,
|
||||||
|
)
|
||||||
if (currentStarterPack?.initialFeed) {
|
if (currentStarterPack?.initialFeed) {
|
||||||
if (currentStarterPack.initialFeed === 'following') {
|
if (currentStarterPack.initialFeed === 'following') {
|
||||||
initialIndex = 1
|
initialIndex = 1
|
||||||
|
|||||||
Reference in New Issue
Block a user