simplify some things
This commit is contained in:
@@ -1,22 +1,23 @@
|
|||||||
import React from 'react'
|
import React from 'react'
|
||||||
|
|
||||||
|
import {parseStarterPackHttpUri} from 'lib/strings/starter-pack'
|
||||||
import {useSetCurrentStarterPack} from 'state/preferences/starter-pack'
|
import {useSetCurrentStarterPack} from 'state/preferences/starter-pack'
|
||||||
|
|
||||||
export function useStarterPackEntry() {
|
export function useStarterPackEntry() {
|
||||||
const setCurrentStarterPack = useSetCurrentStarterPack()
|
const setCurrentStarterPack = useSetCurrentStarterPack()
|
||||||
|
|
||||||
React.useEffect(() => {
|
React.useEffect(() => {
|
||||||
const url = new URL(window.location.href)
|
const href = window.location.href
|
||||||
if (url.pathname.startsWith('/start/')) {
|
const parsed = parseStarterPackHttpUri(href)
|
||||||
const [_, _start, name, rkey] = url.pathname.split('/')
|
|
||||||
|
if (parsed) {
|
||||||
|
const url = new URL(href)
|
||||||
const isClip = url.searchParams.get('clip') === 'true'
|
const isClip = url.searchParams.get('clip') === 'true'
|
||||||
|
|
||||||
if (name && rkey) {
|
setCurrentStarterPack({
|
||||||
setCurrentStarterPack({
|
uri: href,
|
||||||
uri: window.location.href,
|
isClip,
|
||||||
isClip,
|
})
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}, [setCurrentStarterPack])
|
}, [setCurrentStarterPack])
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ import * as persisted from '#/state/persisted'
|
|||||||
type StateContext =
|
type StateContext =
|
||||||
| {
|
| {
|
||||||
uri: string
|
uri: string
|
||||||
cid?: string
|
|
||||||
initialFeed?: string
|
initialFeed?: string
|
||||||
isClip?: boolean
|
isClip?: boolean
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user