fix: remove dead code
This commit is contained in:
@@ -1,7 +1 @@
|
|||||||
# Tauri + React + Typescript
|
A direct message nostr client
|
||||||
|
|
||||||
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)
|
|
||||||
|
|||||||
@@ -13,10 +13,7 @@ const platform = type();
|
|||||||
const queryClient = new QueryClient();
|
const queryClient = new QueryClient();
|
||||||
const chatManager = new LRUCache<string, string>({
|
const chatManager = new LRUCache<string, string>({
|
||||||
max: 3,
|
max: 3,
|
||||||
dispose: async (v, _) => {
|
dispose: async (v, _) => await commands.disconnectInboxRelays(v),
|
||||||
console.log("disconnect: ", v);
|
|
||||||
await commands.disconnectInboxRelays(v);
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
|
|
||||||
const router = createRouter({
|
const router = createRouter({
|
||||||
|
|||||||
@@ -14,7 +14,6 @@ import {
|
|||||||
type Dispatch,
|
type Dispatch,
|
||||||
type SetStateAction,
|
type SetStateAction,
|
||||||
useCallback,
|
useCallback,
|
||||||
useLayoutEffect,
|
|
||||||
useRef,
|
useRef,
|
||||||
useState,
|
useState,
|
||||||
useTransition,
|
useTransition,
|
||||||
@@ -106,7 +105,6 @@ function List() {
|
|||||||
const queryClient = useQueryClient();
|
const queryClient = useQueryClient();
|
||||||
const scrollRef = useRef<HTMLDivElement>(null);
|
const scrollRef = useRef<HTMLDivElement>(null);
|
||||||
const ref = useRef<VirtualizerHandle>(null);
|
const ref = useRef<VirtualizerHandle>(null);
|
||||||
const isPrepend = useRef(false);
|
|
||||||
const shouldStickToBottom = useRef(true);
|
const shouldStickToBottom = useRef(true);
|
||||||
|
|
||||||
const renderItem = useCallback(
|
const renderItem = useCallback(
|
||||||
@@ -146,28 +144,6 @@ function List() {
|
|||||||
[data],
|
[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(() => {
|
useEffect(() => {
|
||||||
const unlisten = listen<EventPayload>("event", async (data) => {
|
const unlisten = listen<EventPayload>("event", async (data) => {
|
||||||
const event: NostrEvent = JSON.parse(data.payload.event);
|
const event: NostrEvent = JSON.parse(data.payload.event);
|
||||||
@@ -190,7 +166,7 @@ function List() {
|
|||||||
return () => {
|
return () => {
|
||||||
unlisten.then((f) => f());
|
unlisten.then((f) => f());
|
||||||
};
|
};
|
||||||
}, []);
|
}, [account, id]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!data?.length) return;
|
if (!data?.length) return;
|
||||||
@@ -202,10 +178,6 @@ function List() {
|
|||||||
});
|
});
|
||||||
}, [data]);
|
}, [data]);
|
||||||
|
|
||||||
useLayoutEffect(() => {
|
|
||||||
isPrepend.current = false;
|
|
||||||
});
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ScrollArea.Root
|
<ScrollArea.Root
|
||||||
type={"scroll"}
|
type={"scroll"}
|
||||||
@@ -219,7 +191,7 @@ function List() {
|
|||||||
<Virtualizer
|
<Virtualizer
|
||||||
scrollRef={scrollRef}
|
scrollRef={scrollRef}
|
||||||
ref={ref}
|
ref={ref}
|
||||||
shift={isPrepend.current}
|
shift={true}
|
||||||
onScroll={(offset) => {
|
onScroll={(offset) => {
|
||||||
if (!ref.current) return;
|
if (!ref.current) return;
|
||||||
shouldStickToBottom.current =
|
shouldStickToBottom.current =
|
||||||
|
|||||||
Reference in New Issue
Block a user