mirror of
https://github.com/Blah-IM/Weblah.git
synced 2025-08-21 03:22:40 +00:00
refactor: update to new room info protocol
This commit is contained in:
parent
48f9c32918
commit
f34ad89b79
2 changed files with 25 additions and 9 deletions
|
@ -91,12 +91,17 @@ export class BlahChatServerConnection {
|
|||
await this.apiCall('POST', `/room/${room}/item`, payload);
|
||||
}
|
||||
|
||||
async fetchRoom(
|
||||
roomId: string
|
||||
): Promise<{ room: BlahRoomInfo; messages: BlahSignedPayload<BlahMessage>[] }> {
|
||||
const [room, messages]: [BlahRoomInfo, [number, BlahSignedPayload<BlahMessage>][]] =
|
||||
await this.apiCall('GET', `/room/${roomId}/item`);
|
||||
return { room, messages: messages.toSorted(([a], [b]) => a - b).map(([, message]) => message) };
|
||||
async fetchRoomInfo(roomId: string): Promise<BlahRoomInfo> {
|
||||
const room: BlahRoomInfo = await this.apiCall('GET', `/room/${roomId}`);
|
||||
return room;
|
||||
}
|
||||
|
||||
async fetchRoomHistory(roomId: string): Promise<BlahSignedPayload<BlahMessage>[]> {
|
||||
const { items }: { items: BlahSignedPayload<BlahMessage>[] } = await this.apiCall(
|
||||
'GET',
|
||||
`/room/${roomId}/item`
|
||||
);
|
||||
return items;
|
||||
}
|
||||
|
||||
private createEventSource(roomId: string): EventSource {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue