diff --git a/pkgs/clan-app/ui/src/hooks/clan.ts b/pkgs/clan-app/ui/src/hooks/clan.ts index d2ef9715a..4930d7e6e 100644 --- a/pkgs/clan-app/ui/src/hooks/clan.ts +++ b/pkgs/clan-app/ui/src/hooks/clan.ts @@ -28,30 +28,4 @@ export const clanURIParam = (params: Params) => { return window.atob(params.clanURI); }; -export function useClanURI(opts: { force: true }): string; -export function useClanURI(opts: { force: boolean }): string | null; -export function useClanURI( - opts: { force: boolean } = { force: false }, -): string | null { - const maybe = () => { - const params = useParams(); - if (!params.clanURI) { - return null; - } - const clanURI = clanURIParam(params); - if (!clanURI) { - throw new Error( - "Could not decode clan URI from params: " + params.clanURI, - ); - } - return clanURI; - }; - - const uri = maybe(); - if (!uri && opts.force) { - throw new Error( - "ClanURI is not set. Use this function only within contexts, where clanURI is guaranteed to have been set.", - ); - } - return uri; -} +export const useClanURI = () => clanURIParam(useParams()); diff --git a/pkgs/clan-app/ui/src/routes/Clan/Clan.tsx b/pkgs/clan-app/ui/src/routes/Clan/Clan.tsx index cd47110a4..ba345f659 100644 --- a/pkgs/clan-app/ui/src/routes/Clan/Clan.tsx +++ b/pkgs/clan-app/ui/src/routes/Clan/Clan.tsx @@ -90,7 +90,7 @@ const MockCreateMachine = (props: MockProps) => { }; const ClanSceneController = () => { - const clanURI = useClanURI({ force: true }); + const clanURI = useClanURI(); const [dialogHandlers, setDialogHandlers] = createSignal<{ resolve: ({ id }: { id: string }) => void; @@ -191,7 +191,7 @@ const ClanSceneController = () => { cubesQuery={query} onCreate={onCreate} sceneStore={() => { - const clanURI = useClanURI({ force: true }); + const clanURI = useClanURI(); return store.sceneData?.[clanURI]; }} setMachinePos={(machineId: string, pos: [number, number]) => {