From b36f5479fb62cb94b171d72a33f5d9d7b9c760a0 Mon Sep 17 00:00:00 2001 From: Jack Zhuang <50353452+hotlong@users.noreply.github.com> Date: Wed, 25 Dec 2024 13:09:54 +0800 Subject: [PATCH] rooms: add rooms api --- .../liveblocks/src/components/Provider.tsx | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/packages/@steedos-widgets/liveblocks/src/components/Provider.tsx b/packages/@steedos-widgets/liveblocks/src/components/Provider.tsx index 0eda61d8d..b82299c10 100644 --- a/packages/@steedos-widgets/liveblocks/src/components/Provider.tsx +++ b/packages/@steedos-widgets/liveblocks/src/components/Provider.tsx @@ -46,6 +46,24 @@ export const AmisRoomsProvider = (props: any) => { return result; }} + // Get rooms' info from their ID + resolveRoomsInfo={async ({ roomIds }) => { + const searchParams = new URLSearchParams( + roomIds.map((roomId) => ["roomIds", roomId]) + ); + const response = await fetch(`${fixedBaseUrl}/v2/c/rooms?${searchParams}`, { + headers: { + "Authorization": `Bearer ${token}` + } + }); + + if (!response.ok) { + throw new Error("Problem resolving rooms info"); + } + + const roomsInfo = await response.json(); + return roomsInfo; + }} // Get users' info from their ID resolveUsers={async ({ userIds }) => { const searchParams = new URLSearchParams(