mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-04-21 08:21:19 +02:00
Cookie Support (#19)
This commit is contained in:
22
src-web/hooks/useActiveCookieJar.ts
Normal file
22
src-web/hooks/useActiveCookieJar.ts
Normal file
@@ -0,0 +1,22 @@
|
||||
import { NAMESPACE_GLOBAL } from '../lib/keyValueStore';
|
||||
import { useActiveWorkspaceId } from './useActiveWorkspaceId';
|
||||
import { useCookieJars } from './useCookieJars';
|
||||
import { useKeyValue } from './useKeyValue';
|
||||
|
||||
export function useActiveCookieJar() {
|
||||
const workspaceId = useActiveWorkspaceId();
|
||||
const cookieJars = useCookieJars();
|
||||
|
||||
const kv = useKeyValue<string | null>({
|
||||
namespace: NAMESPACE_GLOBAL,
|
||||
key: ['activeCookieJar', workspaceId ?? 'n/a'],
|
||||
defaultValue: null,
|
||||
});
|
||||
|
||||
const activeCookieJar = cookieJars.find((cookieJar) => cookieJar.id === kv.value);
|
||||
|
||||
return {
|
||||
activeCookieJar: activeCookieJar ?? null,
|
||||
setActiveCookieJarId: kv.set,
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user