From ac7fb25e47338c048da43659154c2c4b75bd3f1e Mon Sep 17 00:00:00 2001 From: Leo dev Date: Mon, 22 Dec 2025 20:55:22 +0100 Subject: [PATCH] DM messages fix --- src/app/chat/[id]/page.tsx | 17 +++++++++++++---- src/app/chat/page.tsx | 2 +- src/components/app/AppLayout.tsx | 6 +----- src/components/app/SidebarDMs.tsx | 2 +- src/components/channel/MessageBox.tsx | 7 +------ src/hooks/use-app.ts | 1 - 6 files changed, 17 insertions(+), 18 deletions(-) diff --git a/src/app/chat/[id]/page.tsx b/src/app/chat/[id]/page.tsx index db6891e..e42dafe 100644 --- a/src/app/chat/[id]/page.tsx +++ b/src/app/chat/[id]/page.tsx @@ -22,13 +22,17 @@ export default function DMs() { auth({ id: target.node_address, wsRef: targetNode, - addMessage: app.addMessage, - deleteMessage: app.deleteMessage, - editMessage: app.editMessage, + messageStore: app.privateMessages, }); } connectTargetNode(); + + app.setCurrentChannel({ + id: id, + name: target?.display_name || id, + kind: "text", + }); }, [target]); return loading || target ? ( @@ -37,16 +41,21 @@ export default function DMs() { app={app} channelName={target?.display_name || id} channelIcon={target?.avatar_url || "_"} - messages={app.privateMessages.filter( + messages={app.privateMessages.messages.filter( (m) => (m.channel_id === id && m.from === app.profile?.id) || (m.from === id && m.channel_id === app.profile?.id) )} sendRequest={(req) => { + console.log("Sending request: ", req); switch (req.type) { case "send_message": targetNode.current?.send(JSON.stringify(req)); break; + case "load_chunk": + targetNode.current?.send(JSON.stringify(req)); + app.node.current?.send(JSON.stringify(req)); + break; default: app.node.current?.send(JSON.stringify(req)); break; diff --git a/src/app/chat/page.tsx b/src/app/chat/page.tsx index 18b5c7c..38d0569 100644 --- a/src/app/chat/page.tsx +++ b/src/app/chat/page.tsx @@ -52,7 +52,7 @@ export default function ChatHub() { channels: [], }, ]; - const recentActivity = app.privateMessages.slice(0, 3); + const recentActivity = app.privateMessages.messages.slice(0, 3); return ( diff --git a/src/components/app/AppLayout.tsx b/src/components/app/AppLayout.tsx index e5edecd..77de524 100644 --- a/src/components/app/AppLayout.tsx +++ b/src/components/app/AppLayout.tsx @@ -50,11 +50,7 @@ export default function AppLayout({ if (onNewMessage) onNewMessage(m); }, - lastMessage: app.privateMessages?.[app.privateMessages.length - 1]?.id, - - addMessage: app.addMessage, - deleteMessage: app.deleteMessage, - editMessage: app.editMessage, + messageStore: app.privateMessages, }); app.setProfiles((prev) => { diff --git a/src/components/app/SidebarDMs.tsx b/src/components/app/SidebarDMs.tsx index 90a41ab..ecee3d3 100644 --- a/src/components/app/SidebarDMs.tsx +++ b/src/components/app/SidebarDMs.tsx @@ -44,7 +44,7 @@ export default function SidebarDMs({ app }: { app: App }) { ); }; load(); - }, [query, app.privateMessages, app.profile]); + }, [query, app.privateMessages.messages, app.profile]); return (
diff --git a/src/components/channel/MessageBox.tsx b/src/components/channel/MessageBox.tsx index 26999d0..7ade402 100644 --- a/src/components/channel/MessageBox.tsx +++ b/src/components/channel/MessageBox.tsx @@ -402,12 +402,7 @@ export default function MessageBox({ - diff --git a/src/hooks/use-app.ts b/src/hooks/use-app.ts index 213de1d..141ada0 100644 --- a/src/hooks/use-app.ts +++ b/src/hooks/use-app.ts @@ -60,7 +60,6 @@ export default function useApp(): App { const onResponse = (res: Response) => { setProfiles((prev) => { - console.log("test"); prev[id] = res.data as UserProfile; return prev; });