From 3e203bc458c7ae75fb25b879d298e89fe1bc2b73 Mon Sep 17 00:00:00 2001 From: Hailey Date: Mon, 17 Jun 2024 18:57:18 -0700 Subject: [PATCH] simplify some things --- src/components/hooks/useStarterPackEntry.ts | 19 ++++++++++--------- src/state/preferences/starter-pack.tsx | 1 - 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/components/hooks/useStarterPackEntry.ts b/src/components/hooks/useStarterPackEntry.ts index fd662df19a..dbe2c74862 100644 --- a/src/components/hooks/useStarterPackEntry.ts +++ b/src/components/hooks/useStarterPackEntry.ts @@ -1,22 +1,23 @@ import React from 'react' +import {parseStarterPackHttpUri} from 'lib/strings/starter-pack' import {useSetCurrentStarterPack} from 'state/preferences/starter-pack' export function useStarterPackEntry() { const setCurrentStarterPack = useSetCurrentStarterPack() React.useEffect(() => { - const url = new URL(window.location.href) - if (url.pathname.startsWith('/start/')) { - const [_, _start, name, rkey] = url.pathname.split('/') + const href = window.location.href + const parsed = parseStarterPackHttpUri(href) + + if (parsed) { + const url = new URL(href) const isClip = url.searchParams.get('clip') === 'true' - if (name && rkey) { - setCurrentStarterPack({ - uri: window.location.href, - isClip, - }) - } + setCurrentStarterPack({ + uri: href, + isClip, + }) } }, [setCurrentStarterPack]) diff --git a/src/state/preferences/starter-pack.tsx b/src/state/preferences/starter-pack.tsx index bbc4fc7948..583c2b65f8 100644 --- a/src/state/preferences/starter-pack.tsx +++ b/src/state/preferences/starter-pack.tsx @@ -5,7 +5,6 @@ import * as persisted from '#/state/persisted' type StateContext = | { uri: string - cid?: string initialFeed?: string isClip?: boolean }