Files
lume/src/stores/note.tsx
2023-03-24 15:23:30 +07:00

17 lines
505 B
TypeScript

import { isSSR } from '@utils/ssr';
import { getAllNotes } from '@utils/storage';
import { atom } from 'jotai';
import { atomsWithQuery } from 'jotai-tanstack-query';
// usecase: notify user that connector has receive newer note
export const hasNewerNoteAtom = atom(false);
// usecase: query notes from database
export const [notesAtom] = atomsWithQuery(() => ({
queryKey: ['notes'],
queryFn: async ({ queryKey: [] }) => {
const res = isSSR ? [] : await getAllNotes();
return res;
},
}));