Message loading

This commit is contained in:
2026-01-09 20:50:45 +01:00
parent 8df66a2a94
commit dad1e3f04a
3 changed files with 18 additions and 0 deletions
+1
View File
@@ -53,6 +53,7 @@ export default function DMs() {
app.privateMessages, app.privateMessages,
{ {
onIndicator: addIndicator, onIndicator: addIndicator,
setServer: () => targetNode.current?.loadInitialMessages(id),
}, },
targetNode targetNode
); );
+3
View File
@@ -14,6 +14,7 @@ import SidebarChannels from "./SidebarChannels";
import DMItem from "./DMItem"; import DMItem from "./DMItem";
import { useEffectOnceWhenReady } from "@/hooks/use-once"; import { useEffectOnceWhenReady } from "@/hooks/use-once";
import { getNode, useNullNode } from "@/hooks/use-node"; import { getNode, useNullNode } from "@/hooks/use-node";
import { ClientMessage } from "@/types/protocol";
export default function AppLayout({ export default function AppLayout({
children, children,
@@ -56,6 +57,8 @@ export default function AppLayout({
if (onNewMessage) onNewMessage(m); if (onNewMessage) onNewMessage(m);
}, },
setServer: () =>
chatWith && app.node.current?.loadInitialMessages(chatWith),
}, },
node node
); );
+14
View File
@@ -74,6 +74,20 @@ export class NodeClient {
await this.readyPromise; await this.readyPromise;
} }
loadInitialMessages(channelId: string) {
this.waitUntilReady().then(() => {
this.socket?.send(
JSON.stringify({
type: "load_chunk",
params: {
channel_id: channelId,
chunk_id: 0,
},
})
);
});
}
private async handleMessage(e: MessageEvent, authToken: string) { private async handleMessage(e: MessageEvent, authToken: string) {
// Voice packet // Voice packet
if (e.data instanceof Blob) { if (e.data instanceof Blob) {