feat: use negentropy as much as possible

This commit is contained in:
2024-10-08 10:36:31 +07:00
parent 8c6aea8050
commit d2b5ae0507
12 changed files with 202 additions and 209 deletions

View File

@@ -3,6 +3,7 @@ import { appSettings } from "@/commons";
import { Spinner } from "@/components";
import type { QueryClient } from "@tanstack/react-query";
import { Outlet, createRootRouteWithContext } from "@tanstack/react-router";
import { listen } from "@tauri-apps/api/event";
import type { OsType } from "@tauri-apps/plugin-os";
import { useEffect } from "react";
@@ -17,6 +18,8 @@ export const Route = createRootRouteWithContext<RouterContext>()({
});
function Screen() {
const { queryClient } = Route.useRouteContext();
useEffect(() => {
const unlisten = events.newSettings.listen((data) => {
appSettings.setState((state) => {
@@ -29,6 +32,16 @@ function Screen() {
};
}, []);
useEffect(() => {
const unlisten = listen("synchronized", async () => {
await queryClient.invalidateQueries();
});
return () => {
unlisten.then((f) => f());
};
}, []);
return <Outlet />;
}