Ensure that messages are in redux when scrolling

Co-authored-by: Fedor Indutny <79877362+indutny-signal@users.noreply.github.com>
This commit is contained in:
automated-signal 2021-06-24 10:40:14 -07:00 committed by GitHub
parent 8e3a71d651
commit af85b61e9b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 15 additions and 1 deletions

View File

@ -30,6 +30,7 @@ import {
isOutgoing,
isTapToView,
} from '../state/selectors/message';
import { getMessagesByConversation } from '../state/selectors/conversations';
import { ConversationDetailsMembershipList } from '../components/conversation/conversation-details/ConversationDetailsMembershipList';
import { showSafetyNumberChangeDialog } from '../shims/showSafetyNumberChangeDialog';
@ -1142,7 +1143,20 @@ Whisper.ConversationView = Whisper.View.extend({
throw new Error(`scrollToMessage: failed to load message ${messageId}`);
}
const isInMemory = Boolean(window.MessageController.getById(messageId));
const state = window.reduxStore.getState();
let isInMemory = true;
if (!window.MessageController.getById(messageId)) {
isInMemory = false;
}
// Message might be in memory, but not in the redux anymore because
// we call `messageReset()` in `loadAndScroll()`.
const messagesByConversation = getMessagesByConversation(state)[model.id];
if (!messagesByConversation?.messageIds.includes(messageId)) {
isInMemory = false;
}
if (isInMemory) {
const { scrollToMessage } = window.reduxActions.conversations;