mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-03-18 07:23:51 +01:00
23 lines
726 B
TypeScript
23 lines
726 B
TypeScript
import { useQuery } from '@tanstack/react-query';
|
|
import type { CookieJar } from '@yaakapp/api';
|
|
import { invokeCmd } from '../lib/tauri';
|
|
import { useActiveWorkspace } from './useActiveWorkspace';
|
|
|
|
export function cookieJarsQueryKey({ workspaceId }: { workspaceId: string }) {
|
|
return ['cookie_jars', { workspaceId }];
|
|
}
|
|
|
|
export function useCookieJars() {
|
|
const workspace = useActiveWorkspace();
|
|
return useQuery({
|
|
enabled: workspace != null,
|
|
queryKey: cookieJarsQueryKey({ workspaceId: workspace?.id ?? 'n/a' }),
|
|
queryFn: async () => {
|
|
if (workspace == null) return [];
|
|
return (await invokeCmd('cmd_list_cookie_jars', {
|
|
workspaceId: workspace.id,
|
|
})) as CookieJar[];
|
|
},
|
|
});
|
|
}
|