Skip to content

Commit

Permalink
refactor(chat-saga): mark room as read on perform validation (#2754)
Browse files Browse the repository at this point in the history
  • Loading branch information
domw30 authored Mar 7, 2025
1 parent 7f70e33 commit cffa9cf
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
8 changes: 4 additions & 4 deletions src/store/chat/saga.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ describe(performValidateActiveConversation, () => {
.call(getRoomIdForAlias, '#' + alias)
.not.call(apiJoinRoom, conversationId)
.put(rawSetActiveConversationId(conversationId))
.spawn(markConversationAsRead, conversationId)
.call(markConversationAsRead, conversationId)
.run();

expect(storeState.chat.activeConversationId).toBe(conversationId);
Expand Down Expand Up @@ -170,7 +170,7 @@ describe(performValidateActiveConversation, () => {
[matchers.call.fn(markConversationAsRead), undefined],
])
.put(rawSetActiveConversationId('social-channel'))
.spawn(markConversationAsRead, 'social-channel')
.call(markConversationAsRead, 'social-channel')
.not.call(openFirstConversation)
.run();
});
Expand All @@ -193,7 +193,7 @@ describe(performValidateActiveConversation, () => {
[matchers.call.fn(getHistory), history],
])
.put(rawSetActiveConversationId('convo-1'))
.spawn(markConversationAsRead, 'convo-1')
.call(markConversationAsRead, 'convo-1')
.run();
});

Expand Down Expand Up @@ -229,7 +229,7 @@ describe(performValidateActiveConversation, () => {
},
])
.not.put(rawSetActiveConversationId('convo-1'))
.not.spawn(markConversationAsRead, 'convo-1')
.call(markConversationAsRead, 'convo-1')
.run();
});
});
Expand Down
5 changes: 3 additions & 2 deletions src/store/chat/saga.ts
Original file line number Diff line number Diff line change
Expand Up @@ -217,9 +217,10 @@ export function* performValidateActiveConversation(activeConversationId: string)
// check if path has changed before setting active conversation
if (currentPathNow === originalPath) {
yield put(rawSetActiveConversationId(conversationId));
// Mark conversation as read, now that it has been set as active
yield spawn(markConversationAsRead, conversationId);
}

// Mark conversation as read, now that it has been set as active
yield call(markConversationAsRead, conversationId);
}

export function* closeErrorDialog() {
Expand Down

0 comments on commit cffa9cf

Please sign in to comment.