update
This commit is contained in:
@@ -1,9 +1,7 @@
|
||||
import { events } from "@/commands.gen";
|
||||
import { Spinner } from "@/components";
|
||||
import type { QueryClient } from "@tanstack/react-query";
|
||||
import { Outlet, createRootRouteWithContext } from "@tanstack/react-router";
|
||||
import type { OsType } from "@tauri-apps/plugin-os";
|
||||
import { useEffect } from "react";
|
||||
|
||||
interface RouterContext {
|
||||
queryClient: QueryClient;
|
||||
@@ -17,21 +15,6 @@ export const Route = createRootRouteWithContext<RouterContext>()({
|
||||
});
|
||||
|
||||
function Screen() {
|
||||
const { queryClient } = Route.useRouteContext();
|
||||
|
||||
useEffect(() => {
|
||||
const unlisten = events.negentropyEvent.listen(async (data) => {
|
||||
const queryKey = [data.payload.kind.toLowerCase()];
|
||||
console.info("invalidate: ", queryKey);
|
||||
|
||||
await queryClient.refetchQueries({ queryKey });
|
||||
});
|
||||
|
||||
return () => {
|
||||
unlisten.then((f) => f());
|
||||
};
|
||||
}, []);
|
||||
|
||||
return <Outlet />;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { events, commands } from "@/commands.gen";
|
||||
import { commands } from "@/commands.gen";
|
||||
import { Note, ReplyNote, Spinner } from "@/components";
|
||||
import { LumeEvent, useEvent } from "@/system";
|
||||
import type { EventPayload } from "@/types";
|
||||
@@ -91,7 +91,6 @@ function RootEvent() {
|
||||
}
|
||||
|
||||
function ReplyList() {
|
||||
const { label } = Route.useSearch();
|
||||
const { id } = Route.useParams();
|
||||
const { queryClient } = Route.useRouteContext();
|
||||
const { data, isLoading } = useQuery({
|
||||
@@ -179,28 +178,6 @@ function ReplyList() {
|
||||
refetchOnWindowFocus: false,
|
||||
});
|
||||
|
||||
useEffect(() => {
|
||||
events.subscription
|
||||
.emit({
|
||||
label: label || id,
|
||||
kind: "Subscribe",
|
||||
event_id: id,
|
||||
contacts: null,
|
||||
})
|
||||
.then(() => console.log("Subscribe: ", label));
|
||||
|
||||
return () => {
|
||||
events.subscription
|
||||
.emit({
|
||||
label: label || id,
|
||||
kind: "Unsubscribe",
|
||||
event_id: id,
|
||||
contacts: null,
|
||||
})
|
||||
.then(() => console.log("Unsubscribe: ", label));
|
||||
};
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
const unlisten = getCurrentWindow().listen<EventPayload>(
|
||||
"event",
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { events, commands } from "@/commands.gen";
|
||||
import { commands } from "@/commands.gen";
|
||||
import { toLumeEvents } from "@/commons";
|
||||
import { RepostNote, Spinner, TextNote } from "@/components";
|
||||
import type { LumeEvent } from "@/system";
|
||||
@@ -83,28 +83,6 @@ export function Screen() {
|
||||
[data],
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
events.subscription
|
||||
.emit({
|
||||
label: search.label as string,
|
||||
kind: "Subscribe",
|
||||
event_id: null,
|
||||
contacts,
|
||||
})
|
||||
.then(() => console.log("Subscribe: ", search.label));
|
||||
|
||||
return () => {
|
||||
events.subscription
|
||||
.emit({
|
||||
label: search.label as string,
|
||||
kind: "Unsubscribe",
|
||||
event_id: null,
|
||||
contacts,
|
||||
})
|
||||
.then(() => console.log("Unsubscribe: ", search.label));
|
||||
};
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
const unlisten = listen("synchronized", async () => {
|
||||
await queryClient.refetchQueries({
|
||||
|
||||
Reference in New Issue
Block a user