Skip to content

Commit

Permalink
Regression: fix directory endpoint not listing teams (#26310)
Browse files Browse the repository at this point in the history
Co-authored-by: Matheus Barbosa Silva <[email protected]>
Co-authored-by: Guilherme Gazzo <[email protected]>
  • Loading branch information
3 people authored Jul 20, 2022
1 parent de983ec commit 1c8d000
Showing 1 changed file with 11 additions and 13 deletions.
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

0 comments on commit 1c8d000

Please sign in to comment.