fix: remove dead code

This commit is contained in:
reya
2024-08-07 14:19:59 +07:00
parent 9120c96994
commit 6d93c1e4d2
3 changed files with 4 additions and 41 deletions

View File

@@ -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

View File

@@ -13,10 +13,7 @@ const platform = type();
const queryClient = new QueryClient();
const chatManager = new LRUCache<string, string>({
max: 3,
dispose: async (v, _) => {
console.log("disconnect: ", v);
await commands.disconnectInboxRelays(v);
},
dispose: async (v, _) => await commands.disconnectInboxRelays(v),
});
const router = createRouter({

View File

@@ -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<HTMLDivElement>(null);
const ref = useRef<VirtualizerHandle>(null);
const isPrepend = useRef(false);
const shouldStickToBottom = useRef(true);
const renderItem = useCallback(
@@ -146,28 +144,6 @@ function List() {
[data],
);
useEffect(() => {
const unlisten = listen<ChatPayload>(`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<EventPayload>("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 (
<ScrollArea.Root
type={"scroll"}
@@ -219,7 +191,7 @@ function List() {
<Virtualizer
scrollRef={scrollRef}
ref={ref}
shift={isPrepend.current}
shift={true}
onScroll={(offset) => {
if (!ref.current) return;
shouldStickToBottom.current =