Fix an issue where receiving a DM from a new user does not appear in the channel list (#6175)

This commit is contained in:
Daniel Espino García 2022-04-13 19:19:09 +02:00 committed by GitHub
parent 94b2a14313
commit 667716fd0f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 2 deletions

View file

@ -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);
}

View file

@ -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<string, number>, cId) => {
r[cId] = 0;
return r;
}, {});
const q = await database.get<ChannelMembershipModel>(CHANNEL_MEMBERSHIP).query(Q.where('channel_id', Q.oneOf(channelsId))).fetch();
return q.reduce((r: Record<string, number>, 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[]) => {