diff --git a/README.md b/README.md index 102e366..fec4886 100644 --- a/README.md +++ b/README.md @@ -1,7 +1 @@ -# Tauri + React + Typescript - -This template should help get you started developing with Tauri, React and Typescript in Vite. - -## Recommended IDE Setup - -- [VS Code](https://code.visualstudio.com/) + [Tauri](https://marketplace.visualstudio.com/items?itemName=tauri-apps.tauri-vscode) + [rust-analyzer](https://marketplace.visualstudio.com/items?itemName=rust-lang.rust-analyzer) +A direct message nostr client diff --git a/src/main.tsx b/src/main.tsx index 2d7679f..16644ea 100644 --- a/src/main.tsx +++ b/src/main.tsx @@ -13,10 +13,7 @@ const platform = type(); const queryClient = new QueryClient(); const chatManager = new LRUCache({ max: 3, - dispose: async (v, _) => { - console.log("disconnect: ", v); - await commands.disconnectInboxRelays(v); - }, + dispose: async (v, _) => await commands.disconnectInboxRelays(v), }); const router = createRouter({ diff --git a/src/routes/$account.chats.$id.lazy.tsx b/src/routes/$account.chats.$id.lazy.tsx index 15453cc..f666c11 100644 --- a/src/routes/$account.chats.$id.lazy.tsx +++ b/src/routes/$account.chats.$id.lazy.tsx @@ -14,7 +14,6 @@ import { type Dispatch, type SetStateAction, useCallback, - useLayoutEffect, useRef, useState, useTransition, @@ -106,7 +105,6 @@ function List() { const queryClient = useQueryClient(); const scrollRef = useRef(null); const ref = useRef(null); - const isPrepend = useRef(false); const shouldStickToBottom = useRef(true); const renderItem = useCallback( @@ -146,28 +144,6 @@ function List() { [data], ); - useEffect(() => { - const unlisten = listen(`sync_chat_${id}`, async (data) => { - const raw = data.payload.events; - const events: NostrEvent[] = raw.map((item) => JSON.parse(item)); - const chats: NostrEvent[] = await queryClient.getQueryData(["chats", id]); - - if (chats?.length) { - const newEvents = [...events, ...chats]; - const dedup = newEvents.filter( - (obj1, i, arr) => arr.findIndex((obj2) => obj2.id === obj1.id) === i, - ); - await queryClient.setQueryData(["chats", id], dedup); - } else { - await queryClient.setQueryData(["chats", id], events); - } - }); - - return () => { - unlisten.then((f) => f()); - }; - }, []); - useEffect(() => { const unlisten = listen("event", async (data) => { const event: NostrEvent = JSON.parse(data.payload.event); @@ -190,7 +166,7 @@ function List() { return () => { unlisten.then((f) => f()); }; - }, []); + }, [account, id]); useEffect(() => { if (!data?.length) return; @@ -202,10 +178,6 @@ function List() { }); }, [data]); - useLayoutEffect(() => { - isPrepend.current = false; - }); - return ( { if (!ref.current) return; shouldStickToBottom.current =