Deduplicate message_changed redux actions

This commit is contained in:
trevor-signal 2023-10-25 16:44:50 -04:00 committed by GitHub
parent 8bb355f971
commit cfe15b929b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 32 deletions

View file

@ -14,6 +14,8 @@ import { getSenderIdentifier } from '../util/getSenderIdentifier';
import { isNotNil } from '../util/isNotNil';
import { map } from '../util/iterables';
import { softAssert, strictAssert } from '../util/assert';
import { isStory } from '../messages/helpers';
import { getStoryDataFromMessageAttributes } from './storyLoader';
export class MessageCache {
private state = {
@ -197,6 +199,21 @@ export class MessageCache {
this.markModelStale(nextMessageAttributes);
if (window.reduxActions) {
if (isStory(nextMessageAttributes)) {
const storyData = getStoryDataFromMessageAttributes({
...nextMessageAttributes,
});
if (!storyData) {
return;
}
window.reduxActions.stories.storyChanged(storyData);
// We don't want messageChanged to run
return;
}
window.reduxActions.conversations.messageChanged(
messageId,
nextMessageAttributes.conversationId,