Clean up model fetching and loading states

This commit is contained in:
Gregory Schier
2025-01-20 13:44:11 -08:00
parent 0453e84d38
commit 8ad7ac0bef
42 changed files with 180 additions and 247 deletions

View File

@@ -1,8 +1,13 @@
import type { HttpRequest } from '@yaakapp-internal/models';
import { atom, useAtomValue } from 'jotai';
import type {HttpRequest} from '@yaakapp-internal/models';
import {atom, useAtomValue} from 'jotai';
import {jotaiStore} from "../lib/jotai";
export const httpRequestsAtom = atom<HttpRequest[]>([]);
export function useHttpRequests() {
return useAtomValue(httpRequestsAtom);
return useAtomValue(httpRequestsAtom);
}
export function getHttpRequest(id: string) {
return jotaiStore.get(httpRequestsAtom).find(r => r.id === id) ?? null;
}