mirror of
https://github.com/signalapp/Signal-Desktop.git
synced 2025-12-24 12:19:41 +00:00
ConversationController: Send changes to redux only if conversation in lookups
This commit is contained in:
@@ -261,6 +261,21 @@ export class ConversationController {
|
||||
conversation: ConversationModel,
|
||||
previousAttributes: ConversationAttributesType
|
||||
): void {
|
||||
if (!this.#_initialFetchComplete) {
|
||||
log.warn(
|
||||
`conversationChanged: Initial fetch is incomplete; ignoring change from ${conversation.idForLogging()}`
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
const existing = this.get(conversation.id);
|
||||
if (!existing) {
|
||||
log.warn(
|
||||
`conversationChanged: Rejecting change from ${conversation.idForLogging()}, not in lookups`
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
// eslint-disable-next-line no-param-reassign
|
||||
conversation.cachedProps = undefined;
|
||||
|
||||
|
||||
@@ -1537,7 +1537,12 @@ function markConversationRead(
|
||||
): ThunkAction<void, RootStateType, unknown, NoopActionType> {
|
||||
return async dispatch => {
|
||||
const model = window.ConversationController.get(conversationId);
|
||||
strictAssert(model, 'Conversation must be found');
|
||||
if (!model) {
|
||||
log.error(
|
||||
'markConversationRead: Conversation not found, returning early'
|
||||
);
|
||||
return;
|
||||
}
|
||||
model.setMarkedUnread(false);
|
||||
|
||||
const lastMessage = await DataReader.getLastConversationMessage({
|
||||
@@ -4865,7 +4870,10 @@ function onConversationOpened(
|
||||
const promises: Array<Promise<void>> = [];
|
||||
const conversation = window.ConversationController.get(conversationId);
|
||||
if (!conversation) {
|
||||
throw new Error('onConversationOpened: Conversation not found');
|
||||
log.error(
|
||||
`onConversationOpened: Conversation with id ${conversationId} not found`
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
const logId = `onConversationOpened(${conversation.idForLogging()})`;
|
||||
|
||||
@@ -92,7 +92,7 @@ import { countAllChatFoldersMutedStats } from '../../util/countMutedStats.std.js
|
||||
|
||||
const { isNumber, pick } = lodash;
|
||||
|
||||
const log = createLogger('conversations');
|
||||
const log = createLogger('selectors/conversations');
|
||||
|
||||
export type ConversationWithStoriesType = ConversationType & {
|
||||
hasStories?: HasStories;
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
// SPDX-License-Identifier: AGPL-3.0-only
|
||||
import React, { memo, useEffect, useRef } from 'react';
|
||||
import { useSelector } from 'react-redux';
|
||||
|
||||
import { createLogger } from '../../logging/log.std.js';
|
||||
import { ChatsTab } from '../../components/ChatsTab.dom.js';
|
||||
import type { SmartConversationViewProps } from './ConversationView.preload.js';
|
||||
import { SmartConversationView } from './ConversationView.preload.js';
|
||||
@@ -14,7 +16,6 @@ import { usePrevious } from '../../hooks/usePrevious.std.js';
|
||||
import { TargetedMessageSource } from '../ducks/conversationsEnums.std.js';
|
||||
import { useConversationsActions } from '../ducks/conversations.preload.js';
|
||||
import { useToastActions } from '../ducks/toast.preload.js';
|
||||
import { strictAssert } from '../../util/assert.std.js';
|
||||
import { isStagingServer } from '../../util/isStagingServer.dom.js';
|
||||
import { ToastType } from '../../types/Toast.dom.js';
|
||||
import { getNavTabsCollapsed } from '../selectors/items.dom.js';
|
||||
@@ -28,6 +29,8 @@ import {
|
||||
getTargetedMessageSource,
|
||||
} from '../selectors/conversations.dom.js';
|
||||
|
||||
const log = createLogger('smart/ChatsTab');
|
||||
|
||||
function renderConversationView(props: SmartConversationViewProps) {
|
||||
return <SmartConversationView {...props} />;
|
||||
}
|
||||
@@ -100,7 +103,10 @@ export const SmartChatsTab = memo(function SmartChatsTab() {
|
||||
const conversation = window.ConversationController.get(
|
||||
selectedConversationId
|
||||
);
|
||||
strictAssert(conversation, 'Conversation must be found');
|
||||
if (!conversation) {
|
||||
log.error('Conversation not found, returning early');
|
||||
return;
|
||||
}
|
||||
conversation.setMarkedUnread(false);
|
||||
}
|
||||
}, [prevConversationId, selectedConversationId]);
|
||||
|
||||
Reference in New Issue
Block a user