fix: thread not reload after reply

This commit is contained in:
reya
2024-11-02 08:26:46 +07:00
parent f346282c3c
commit 26a6ec954c
5 changed files with 58 additions and 43 deletions
+10 -1
View File
@@ -183,7 +183,6 @@ function ReplyList() {
"event",
async (data) => {
const event = LumeEvent.from(data.payload.raw, data.payload.parsed);
console.log(event);
await queryClient.setQueryData(
["replies", id],
@@ -200,6 +199,16 @@ function ReplyList() {
};
}, []);
useEffect(() => {
const unlisten = getCurrentWindow().listen(id, async () => {
await queryClient.invalidateQueries({ queryKey: ["replies", id] });
});
return () => {
unlisten.then((f) => f());
};
}, []);
return (
<div className="px-3">
<div className="flex items-center text-sm font-semibold h-14 text-neutral-600 dark:text-white/30">
@@ -0,0 +1,9 @@
import { commands } from "@/commands.gen";
import { createFileRoute } from "@tanstack/react-router";
export const Route = createFileRoute("/columns/_layout/events/$id")({
beforeLoad: async () => {
const accounts = await commands.getAccounts();
return { accounts };
},
});
+2 -3
View File
@@ -8,6 +8,7 @@ import type { Metadata } from "@/types";
import { CaretDown } from "@phosphor-icons/react";
import { createLazyFileRoute, useAwaited } from "@tanstack/react-router";
import { Menu, MenuItem } from "@tauri-apps/api/menu";
import { getCurrentWindow } from "@tauri-apps/api/window";
import { message } from "@tauri-apps/plugin-dialog";
import {
useCallback,
@@ -170,9 +171,7 @@ function Screen() {
setText("");
setIsPublish(true);
await queryClient.invalidateQueries({
queryKey: ["replies", reply_to],
});
await getCurrentWindow().emit(reply_to, {});
} else {
setError(res.error);
}