Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Regression: fix directory endpoint not listing teams #26310

Merged
merged 5 commits into from
Jul 20, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 11 additions & 13 deletions apps/meteor/server/methods/browseChannels.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ async function getChannelsAndGroups(user, canViewAnon, searchTerm, sort, paginat
};
}

const getChannelsCountForTeam = mem((teamId) => Promise.await(Rooms.findByTeamId(teamId, { projection: { _id: 1 } }).count()), {
const getChannelsCountForTeam = mem((teamId) => Rooms.findByTeamId(teamId, { projection: { _id: 1 } }).count(), {
maxAge: 2000,
});

Expand Down Expand Up @@ -142,20 +142,18 @@ async function getTeams(user, searchTerm, sort, pagination) {
},
},
);

const [rooms, total] = await Promise.all([
cursor
.map((room) => ({
...room,
roomsCount: getChannelsCountForTeam(room.teamId),
}))
.toArray(),
totalCount,
]);
const results = await Promise.all(
(
await cursor.toArray()
).map(async (room) => ({
...room,
roomsCount: await getChannelsCountForTeam(room.teamId),
})),
);

return {
total,
results: rooms,
total: await totalCount,
results,
};
}

Expand Down