Skip to content

Commit

Permalink
fix user name
Browse files Browse the repository at this point in the history
  • Loading branch information
ratik21 committed Oct 13, 2023
1 parent 864d756 commit 9ab4b1b
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 7 deletions.
12 changes: 7 additions & 5 deletions src/store/channels-list/saga.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -428,15 +428,17 @@ describe('channels list saga', () => {
});

describe(otherUserJoinedChannel, () => {
it('adds the user to the otherMember list', async () => {
it('finds the zOS user and adds the user to the otherMember list', async () => {
const existingMembers = [
{ userId: 'user-1', matrixId: 'user-1' },
{ userId: 'user-2', matrixId: 'user-2' },
] as any;
const initialState = new StoreBuilder().withConversationList({
id: 'conversation-id',
otherMembers: existingMembers,
});
const initialState = new StoreBuilder()
.withConversationList({
id: 'conversation-id',
otherMembers: existingMembers,
})
.withUsers({ userId: 'new-user', matrixId: 'new-user', firstName: 'Jane', lastName: 'doe' });

const { storeState } = await expectSaga(otherUserJoinedChannel, 'conversation-id', {
userId: 'new-user',
Expand Down
13 changes: 11 additions & 2 deletions src/store/channels-list/saga.ts
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,10 @@ export function* createOptimisticConversation(userIds: string[], name: string =
}

export function* receiveCreatedConversation(conversation, optimisticConversation = { id: '', optimisticId: '' }) {
if (!conversation) {
return;
}

const existingConversationsList = yield select(rawConversationsList());
const listWithoutOptimistic = existingConversationsList.filter((id) => id !== optimisticConversation.id);

Expand Down Expand Up @@ -409,12 +413,17 @@ export function* otherUserJoinedChannel(roomId: string, user: User) {
return;
}

// TODO: Fetch user from zOS if we don't know about them yet
if (user.userId === user.matrixId) {
user = yield select(userByMatrixId, user.matrixId);
}

if (!channel.otherMembers.includes(user.userId)) {
const otherMembers = [...channel.otherMembers, user];
yield put(
receiveChannel({
id: channel.id,
otherMembers: [...channel.otherMembers, user],
isOneOnOne: otherMembers.length === 1,
otherMembers,
})
);
}
Expand Down

0 comments on commit 9ab4b1b

Please sign in to comment.