mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-03-17 23:13:51 +01:00
18 lines
545 B
TypeScript
18 lines
545 B
TypeScript
import type { CookieJar } from '@yaakapp-internal/models';
|
|
import { atom, useAtomValue } from 'jotai';
|
|
import { jotaiStore } from '../lib/jotai';
|
|
|
|
export const cookieJarsAtom = atom<CookieJar[] | undefined>();
|
|
|
|
export const sortedCookieJars = atom((get) => {
|
|
return get(cookieJarsAtom)?.sort((a, b) => a.name.localeCompare(b.name));
|
|
});
|
|
|
|
export function useCookieJars() {
|
|
return useAtomValue(sortedCookieJars);
|
|
}
|
|
|
|
export function getCookieJar(id: string | null) {
|
|
return jotaiStore.get(cookieJarsAtom)?.find((e) => e.id === id) ?? null;
|
|
}
|