Fix management of selectedMessage in redux

This commit is contained in:
Fedor Indutny 2022-06-23 09:12:17 -07:00 committed by GitHub
parent 6ad091bfe3
commit 6b231346d9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 15 additions and 15 deletions

View file

@ -1726,6 +1726,14 @@ function messagesReset({
scrollToMessageId,
unboundedFetch,
}: MessageResetOptionsType): MessagesResetActionType {
for (const message of messages) {
strictAssert(
message.conversationId === conversationId,
`messagesReset(${conversationId}): invalid message conversationId ` +
`${message.conversationId}`
);
}
return {
type: 'MESSAGES_RESET',
payload: {
@ -2625,8 +2633,12 @@ export function reducer(
return {
...state,
selectedMessage: scrollToMessageId,
selectedMessageCounter: state.selectedMessageCounter + 1,
...(state.selectedConversationId === conversationId
? {
selectedMessage: scrollToMessageId,
selectedMessageCounter: state.selectedMessageCounter + 1,
}
: {}),
messagesLookup: {
...messagesLookup,
...lookup,
@ -3035,12 +3047,9 @@ export function reducer(
const nextState = {
...omit(state, 'contactSpoofingReview'),
selectedConversationId: id,
selectedMessage: messageId,
};
if (messageId) {
nextState.selectedMessage = messageId;
}
if (switchToAssociatedView && id) {
const conversation = getOwn(state.conversationLookup, id);
if (!conversation) {