aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/client/atoms/noteTypes.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/client/atoms/noteTypes.ts')
-rw-r--r--src/client/atoms/noteTypes.ts15
1 files changed, 9 insertions, 6 deletions
diff --git a/src/client/atoms/noteTypes.ts b/src/client/atoms/noteTypes.ts
index adc9d44..fb99b14 100644
--- a/src/client/atoms/noteTypes.ts
+++ b/src/client/atoms/noteTypes.ts
@@ -1,5 +1,5 @@
+import { atomWithSuspenseQuery } from "jotai-tanstack-query";
import { apiClient } from "../api/client";
-import { createReloadableAtom } from "./utils";
export interface NoteType {
id: string;
@@ -15,8 +15,11 @@ export interface NoteType {
// NoteTypes List - Suspense-compatible
// =====================
-export const noteTypesAtom = createReloadableAtom(async () => {
- const res = await apiClient.rpc.api["note-types"].$get();
- const data = await apiClient.handleResponse<{ noteTypes: NoteType[] }>(res);
- return data.noteTypes;
-});
+export const noteTypesAtom = atomWithSuspenseQuery(() => ({
+ queryKey: ["noteTypes"],
+ queryFn: async () => {
+ const res = await apiClient.rpc.api["note-types"].$get();
+ const data = await apiClient.handleResponse<{ noteTypes: NoteType[] }>(res);
+ return data.noteTypes;
+ },
+}));