diff --git a/app/actions/websocket/channel.ts b/app/actions/websocket/channel.ts index f7814bb1e..6edc4013f 100644 --- a/app/actions/websocket/channel.ts +++ b/app/actions/websocket/channel.ts @@ -214,7 +214,7 @@ export async function handleDirectAddedEvent(serverUrl: string, msg: WebSocketMe } const models: Model[] = []; - const channelModels = await storeMyChannelsForTeam(serverUrl, '', directChannels, memberships); + const channelModels = await storeMyChannelsForTeam(serverUrl, '', directChannels, memberships, true); if (channelModels.models?.length) { models.push(...channelModels.models); } diff --git a/app/queries/servers/channel.ts b/app/queries/servers/channel.ts index 754220d20..cc75653f5 100644 --- a/app/queries/servers/channel.ts +++ b/app/queries/servers/channel.ts @@ -314,6 +314,10 @@ export const queryUsersOnChannel = (database: Database, channelId: string) => { }; export const getMembersCountByChannelsId = async (database: Database, channelsId: string[]) => { + const result = channelsId.reduce((r: Record, cId) => { + r[cId] = 0; + return r; + }, {}); const q = await database.get(CHANNEL_MEMBERSHIP).query(Q.where('channel_id', Q.oneOf(channelsId))).fetch(); return q.reduce((r: Record, m) => { if (r[m.channelId]) { @@ -323,7 +327,7 @@ export const getMembersCountByChannelsId = async (database: Database, channelsId r[m.channelId] = 1; return r; - }, {}); + }, result); }; export const queryChannelsByTypes = (database: Database, channelTypes: ChannelType[]) => {