Skip to content

Commit 5f2111a

Browse files
committed
perf: parallelize getChannels
1 parent 2961491 commit 5f2111a

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

package/src/store/apis/getChannels.ts

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,16 @@ export const getChannels = async ({
2525
currentUserId: string;
2626
}): Promise<Omit<ChannelAPIResponse, 'duration'>[]> => {
2727
SqliteClient.logger?.('info', 'getChannels', { channelIds, currentUserId });
28-
const channels = await selectChannels({ channelIds });
2928

30-
const cidVsMembers = await getMembers({ channelIds });
31-
const cidVsReads = await getReads({ channelIds });
32-
const cidVsMessages = await getChannelMessages({
33-
channelIds,
34-
currentUserId,
35-
});
29+
const [channels, cidVsMembers, cidVsReads, cidVsMessages] = await Promise.all([
30+
selectChannels({ channelIds }),
31+
getMembers({ channelIds }),
32+
getReads({ channelIds }),
33+
getChannelMessages({
34+
channelIds,
35+
currentUserId,
36+
}),
37+
]);
3638

3739
// Enrich the channels with state
3840
return channels.map((c) => ({

0 commit comments

Comments
 (0)