Message loading
This commit is contained in:
@@ -53,6 +53,7 @@ export default function DMs() {
|
||||
app.privateMessages,
|
||||
{
|
||||
onIndicator: addIndicator,
|
||||
setServer: () => targetNode.current?.loadInitialMessages(id),
|
||||
},
|
||||
targetNode
|
||||
);
|
||||
|
||||
@@ -14,6 +14,7 @@ import SidebarChannels from "./SidebarChannels";
|
||||
import DMItem from "./DMItem";
|
||||
import { useEffectOnceWhenReady } from "@/hooks/use-once";
|
||||
import { getNode, useNullNode } from "@/hooks/use-node";
|
||||
import { ClientMessage } from "@/types/protocol";
|
||||
|
||||
export default function AppLayout({
|
||||
children,
|
||||
@@ -56,6 +57,8 @@ export default function AppLayout({
|
||||
|
||||
if (onNewMessage) onNewMessage(m);
|
||||
},
|
||||
setServer: () =>
|
||||
chatWith && app.node.current?.loadInitialMessages(chatWith),
|
||||
},
|
||||
node
|
||||
);
|
||||
|
||||
@@ -74,6 +74,20 @@ export class NodeClient {
|
||||
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) {
|
||||
// Voice packet
|
||||
if (e.data instanceof Blob) {
|
||||
|
||||
Reference in New Issue
Block a user