Skip to content

Commit

Permalink
fix: prevent TypeError in mapToZeroUsers by ensuring non-null values (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
domw30 authored Oct 11, 2023
1 parent 45ffb91 commit 260066c
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/store/channels-list/saga.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export function* mapToZeroUsers(channels: any[]) {

let allMatrixIds = [];
for (const channel of channels) {
const matrixIds = channel.otherMembers.map((u) => u.matrixId);
const matrixIds = (channel.otherMembers || []).filter((u) => u).map((u) => u.matrixId);
allMatrixIds = union(allMatrixIds, matrixIds);
}

Expand All @@ -52,8 +52,12 @@ export function* mapToZeroUsers(channels: any[]) {
for (const user of zeroUsers) {
zeroUsersMap[user.matrixId] = user;
}

const currentUser = yield select(currentUserSelector());
zeroUsersMap[currentUser.matrixId] = currentUser;

if (currentUser && currentUser.matrixId) {
zeroUsersMap[currentUser.matrixId] = currentUser;
}

mapOtherMembersOfChannel(channels, zeroUsersMap);
mapChannelMessages(channels, zeroUsersMap);
Expand Down

0 comments on commit 260066c

Please sign in to comment.