handle landing on start link

This commit is contained in:
Hailey
2024-06-13 14:12:40 -07:00
parent 740a8ea1b4
commit b4e220ede9
5 changed files with 25 additions and 6 deletions
+2
View File
@@ -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(() => {
+7 -2
View File
@@ -6,16 +6,21 @@ export function useStarterPackEntry() {
const setUsedStarterPack = useSetUsedStarterPack()
React.useEffect(() => {
const url = new URL(window.href)
const url = new URL(window.location.href)
if (url.href.startsWith('https://bsky.app/start/')) {
if (url.pathname.startsWith('/start/')) {
console.log('yes sp')
const [_, _start, name, rkey] = url.pathname.split('/')
console.log()
if (name && rkey) {
setUsedStarterPack({
uri: window.href,
})
}
} else {
console.log('no sp')
}
}, [setUsedStarterPack])
+1 -1
View File
@@ -1,7 +1,7 @@
import {Router} from 'lib/routes/router'
export const router = new Router({
Home: '/',
Home: ['/', '/start/:name/:rkey'],
Search: '/search',
Feeds: '/feeds',
Notifications: '/notifications',
+4 -3
View File
@@ -17,7 +17,6 @@ import {
useLoggedOutViewControls,
} from '#/state/shell/logged-out'
import {useSetMinimalShellMode} from '#/state/shell/minimal-mode'
import {IS_DEV, IS_TESTFLIGHT} from 'lib/app-info'
import {NavigationProp} from 'lib/routes/types'
import {useUsedStarterPack} from 'state/preferences/starter-pack'
import {ErrorBoundary} from '#/view/com/util/ErrorBoundary'
@@ -48,8 +47,6 @@ export function LoggedOut({onDismiss}: {onDismiss?: () => void}) {
? requestedAccountSwitchTo === 'new'
? ScreenState.S_CreateAccount
: ScreenState.S_Login
: usedStarterPack?.uri && (IS_TESTFLIGHT || IS_DEV)
? ScreenState.S_StarterPack
: ScreenState.S_LoginOrCreateAccount,
)
const {isMobile} = useWebMediaQueries()
@@ -62,6 +59,10 @@ export function LoggedOut({onDismiss}: {onDismiss?: () => void}) {
setMinimalShellMode(true)
}, [screen, setMinimalShellMode])
React.useEffect(() => {
setScreenState(ScreenState.S_StarterPack)
}, [usedStarterPack?.uri])
const onPressDismiss = React.useCallback(() => {
if (onDismiss) {
onDismiss()
+11
View File
@@ -26,6 +26,7 @@ import {
useSetUsedStarterPack,
useUsedStarterPack,
} from 'state/preferences/starter-pack'
import {useLoggedOutViewControls} from 'state/shell/logged-out'
import {FeedPage} from 'view/com/feeds/FeedPage'
import {Pager, PagerRef, RenderTabBarFnProps} from 'view/com/pager/Pager'
import {CustomFeedEmptyState} from 'view/com/posts/CustomFeedEmptyState'
@@ -39,6 +40,16 @@ export function HomeScreen(props: Props) {
const {data: preferences} = usePreferencesQuery()
const {data: pinnedFeedInfos, isLoading: isPinnedFeedsLoading} =
usePinnedFeedsInfos()
const usedStarterPack = useUsedStarterPack()
const setUsedStarterPack = useSetUsedStarterPack()
const {setShowLoggedOut} = useLoggedOutViewControls()
React.useEffect(() => {
if (usedStarterPack && !usedStarterPack.initialFeed) {
setShowLoggedOut(true)
}
}, [usedStarterPack, setUsedStarterPack, setShowLoggedOut])
if (preferences && pinnedFeedInfos && !isPinnedFeedsLoading) {
return (
<HomeScreenReady