This commit is contained in:
Gregory Schier
2024-12-20 23:49:48 -08:00
committed by GitHub
parent 51a11b6495
commit ecabe9b6ef
83 changed files with 511 additions and 551 deletions

View File

@@ -1,6 +1,5 @@
import { useSearch } from '@tanstack/react-router';
import { getRouteApi, useSearch } from '@tanstack/react-router';
import { useCallback, useEffect, useMemo } from 'react';
import { Route } from '../routes/workspaces/$workspaceId';
import { useCookieJars } from './useCookieJars';
export const QUERY_COOKIE_JAR_ID = 'cookie_jar_id';
@@ -39,13 +38,18 @@ export function useEnsureActiveCookieJar() {
}, [activeCookieJarId, cookieJars, setActiveCookieJarId]);
}
const routeApi = getRouteApi('/workspaces/$workspaceId/');
function useActiveCookieJarId() {
// NOTE: This query param is accessed from Rust side, so do not change
const navigate = Route.useNavigate();
const { cookieJarId: id } = useSearch({ strict: false });
const navigate = routeApi.useNavigate();
const setId = useCallback(
(id: string) => navigate({ search: (prev) => ({ ...prev, cookieJarId: id }) }),
(id: string) =>
navigate({
search: (prev) => ({ ...prev, cookieJarId: id }),
}),
[navigate],
);