From 1bb84e3b0fd81c58f19826e836c7b4556a4a4a3d Mon Sep 17 00:00:00 2001 From: ajnart Date: Tue, 1 Aug 2023 19:19:27 +0900 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20Add=20cache=20back?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 3 ++ src/pages/_app.tsx | 85 ++++++++++++++++++------------- src/pages/manage/boards/index.tsx | 6 --- src/pages/user/preferences.tsx | 1 + yarn.lock | 48 +++++++++++++++++ 5 files changed, 101 insertions(+), 42 deletions(-) diff --git a/package.json b/package.json index cbba32e4c..0b4afbf28 100644 --- a/package.json +++ b/package.json @@ -44,8 +44,11 @@ "@nivo/core": "^0.83.0", "@nivo/line": "^0.83.0", "@prisma/client": "^5.0.0", + "@react-native-async-storage/async-storage": "^1.18.1", "@t3-oss/env-nextjs": "^0.6.0", "@tabler/icons-react": "^2.18.0", + "@tanstack/query-async-storage-persister": "^4.27.1", + "@tanstack/query-sync-storage-persister": "^4.27.1", "@tanstack/react-query": "^4.2.1", "@tanstack/react-query-devtools": "^4.24.4", "@tanstack/react-query-persist-client": "^4.28.0", diff --git a/src/pages/_app.tsx b/src/pages/_app.tsx index 3bfcd9a71..2a06bed07 100644 --- a/src/pages/_app.tsx +++ b/src/pages/_app.tsx @@ -1,7 +1,10 @@ import { ColorScheme as MantineColorScheme, MantineProvider, MantineTheme } from '@mantine/core'; import { ModalsProvider } from '@mantine/modals'; import { Notifications } from '@mantine/notifications'; +import AsyncStorage from '@react-native-async-storage/async-storage'; +import { createAsyncStoragePersister } from '@tanstack/query-async-storage-persister'; import { ReactQueryDevtools } from '@tanstack/react-query-devtools'; +import { PersistQueryClientProvider } from '@tanstack/react-query-persist-client'; import Consola from 'consola'; import { getCookie, setCookie } from 'cookies-next'; import 'flag-icons/css/flag-icons.min.css'; @@ -16,6 +19,7 @@ import 'video.js/dist/video-js.css'; import { env } from '~/env.js'; import { ColorSchemeProvider } from '~/hooks/use-colorscheme'; import { modals } from '~/modals/modals'; +import { queryClient } from '~/tools/server/configurations/tanstack/queryClient.tool'; import { ConfigType } from '~/types/config'; import { api } from '~/utils/api'; import { colorSchemeParser } from '~/validations/user'; @@ -65,6 +69,10 @@ function App( const { setInitialPackageAttributes } = usePackageAttributesStore(); + const asyncStoragePersister = createAsyncStoragePersister({ + storage: AsyncStorage, + }); + useEffect(() => { setInitialPackageAttributes(props.pageProps.packageAttributes); }, []); @@ -75,44 +83,49 @@ function App( - - {(colorScheme) => ( - - + + {(colorScheme) => ( + + - - - - - - - - - )} - - + primaryColor, + primaryShade, + colorScheme, + }} + withGlobalStyles + withNormalizeCSS + > + + + + + + + + + )} + + + ); diff --git a/src/pages/manage/boards/index.tsx b/src/pages/manage/boards/index.tsx index 6fbce4280..bdf7c054c 100644 --- a/src/pages/manage/boards/index.tsx +++ b/src/pages/manage/boards/index.tsx @@ -22,12 +22,6 @@ import { api } from '~/utils/api'; const BoardsPage = () => { const { data } = api.config.all.useQuery(); - const context = api.useContext(); - const { mutateAsync: deletionMutationAsync } = api.config.delete.useMutation({ - onSettled: () => { - void context.config.all.invalidate(); - }, - }); const [deletingDashboards, { append, filter }] = useListState([]); diff --git a/src/pages/user/preferences.tsx b/src/pages/user/preferences.tsx index 0a014f6f9..3205d290a 100644 --- a/src/pages/user/preferences.tsx +++ b/src/pages/user/preferences.tsx @@ -93,6 +93,7 @@ const SettingsComponent = ({