clean up
This commit is contained in:
@@ -1,9 +1,9 @@
|
||||
import { isSSR } from '@utils/ssr';
|
||||
import { getActiveAccount } from '@utils/storage';
|
||||
|
||||
import { atom } from 'jotai';
|
||||
import { atomWithCache } from 'jotai-cache';
|
||||
|
||||
export const activeAccountAtom = atom(async () => {
|
||||
export const activeAccountAtom = atomWithCache(async () => {
|
||||
const response = isSSR ? {} : await getActiveAccount();
|
||||
return response;
|
||||
});
|
||||
|
||||
@@ -4,13 +4,18 @@ import { getAllNotes } from '@utils/storage';
|
||||
import { atom } from 'jotai';
|
||||
import { atomsWithQuery } from 'jotai-tanstack-query';
|
||||
|
||||
// usecase: notify user that connector has receive newer note
|
||||
// notify user that connector has receive newer note
|
||||
export const hasNewerNoteAtom = atom(false);
|
||||
// usecase: query notes from database
|
||||
// query notes from database
|
||||
export const [notesAtom] = atomsWithQuery(() => ({
|
||||
queryKey: ['notes'],
|
||||
queryFn: async ({ queryKey: [] }) => {
|
||||
const res = isSSR ? [] : await getAllNotes();
|
||||
return res;
|
||||
},
|
||||
refetchInterval: 1000000,
|
||||
refetchOnReconnect: true,
|
||||
refetchOnWindowFocus: true,
|
||||
refetchOnMount: true,
|
||||
keepPreviousData: false,
|
||||
}));
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import { isSSR } from '@utils/ssr';
|
||||
import { getAllRelays } from '@utils/storage';
|
||||
|
||||
import { atom } from 'jotai';
|
||||
import { atomWithCache } from 'jotai-cache';
|
||||
|
||||
export const relaysAtom = atom(async () => {
|
||||
export const relaysAtom = atomWithCache(async () => {
|
||||
const response = isSSR ? [] : await getAllRelays();
|
||||
return response;
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user