update
This commit is contained in:
@@ -1,7 +1,11 @@
|
||||
import type { RichEvent } from "@/commands.gen";
|
||||
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 { nip19 } from "nostr-tools";
|
||||
import { useEffect } from "react";
|
||||
|
||||
interface RouterContext {
|
||||
queryClient: QueryClient;
|
||||
@@ -15,6 +19,25 @@ export const Route = createRootRouteWithContext<RouterContext>()({
|
||||
});
|
||||
|
||||
function Screen() {
|
||||
const { queryClient } = Route.useRouteContext();
|
||||
|
||||
useEffect(() => {
|
||||
const unlisten = listen<RichEvent>("event", async (data) => {
|
||||
const event = JSON.parse(data.payload.raw);
|
||||
|
||||
if (event.kind === 0) {
|
||||
const npub = nip19.npubEncode(event.pubkey);
|
||||
await queryClient.invalidateQueries({
|
||||
queryKey: ["profile", npub, event.pubkey],
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
return () => {
|
||||
unlisten.then((f) => f());
|
||||
};
|
||||
}, []);
|
||||
|
||||
return <Outlet />;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user