@corva/chat-core 0.1.13 → 0.1.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +21 -26
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -4518,34 +4518,29 @@ function createChannelsAPI(http) {
|
|
|
4518
4518
|
async function getRooms(serverId) {
|
|
4519
4519
|
try {
|
|
4520
4520
|
const channelMap = /* @__PURE__ */ new Map();
|
|
4521
|
-
|
|
4522
|
-
|
|
4523
|
-
const server = await http.request(
|
|
4524
|
-
`/servers/${serverId}?include_channels=true`
|
|
4525
|
-
);
|
|
4526
|
-
const channelsPayload = server?.channels;
|
|
4527
|
-
if (Array.isArray(channelsPayload) && channelsPayload.length > 0) {
|
|
4528
|
-
channelsPayload.forEach((channel) => {
|
|
4529
|
-
if (channel?._id && channel.channel_type === CHANNEL_TYPES.TEXT_CHANNEL) {
|
|
4530
|
-
channelMap.set(channel._id, channel);
|
|
4531
|
-
}
|
|
4532
|
-
});
|
|
4533
|
-
}
|
|
4534
|
-
} catch (e) {
|
|
4521
|
+
const [serverChannels, dms] = await Promise.all([
|
|
4522
|
+
serverId ? http.request(`/servers/${serverId}?include_channels=true`).then((server) => server?.channels).catch((e) => {
|
|
4535
4523
|
console.error("Failed to fetch channels:", e);
|
|
4536
|
-
|
|
4524
|
+
return void 0;
|
|
4525
|
+
}) : void 0,
|
|
4526
|
+
http.request("/users/dms").catch((e) => {
|
|
4527
|
+
console.error("Failed to fetch DMs:", e);
|
|
4528
|
+
return void 0;
|
|
4529
|
+
})
|
|
4530
|
+
]);
|
|
4531
|
+
if (Array.isArray(serverChannels)) {
|
|
4532
|
+
serverChannels.forEach((channel) => {
|
|
4533
|
+
if (channel?._id && channel.channel_type === CHANNEL_TYPES.TEXT_CHANNEL) {
|
|
4534
|
+
channelMap.set(channel._id, channel);
|
|
4535
|
+
}
|
|
4536
|
+
});
|
|
4537
4537
|
}
|
|
4538
|
-
|
|
4539
|
-
|
|
4540
|
-
|
|
4541
|
-
|
|
4542
|
-
|
|
4543
|
-
|
|
4544
|
-
}
|
|
4545
|
-
});
|
|
4546
|
-
}
|
|
4547
|
-
} catch (e) {
|
|
4548
|
-
console.error("Failed to fetch DMs:", e);
|
|
4538
|
+
if (Array.isArray(dms)) {
|
|
4539
|
+
dms.forEach((channel) => {
|
|
4540
|
+
if (channel?._id) {
|
|
4541
|
+
channelMap.set(channel._id, channel);
|
|
4542
|
+
}
|
|
4543
|
+
});
|
|
4549
4544
|
}
|
|
4550
4545
|
const rooms = [];
|
|
4551
4546
|
channelMap.forEach((channel) => {
|