Update sendStateByConversationId after merge
This commit is contained in:
parent
da9e657211
commit
99fd03078e
3 changed files with 240 additions and 11 deletions
|
@ -16,6 +16,7 @@ import { isNotNil } from '../util/isNotNil';
|
|||
import { map } from '../util/iterables';
|
||||
import { softAssert, strictAssert } from '../util/assert';
|
||||
import { isStory } from '../messages/helpers';
|
||||
import type { SendStateByConversationId } from '../messages/MessageSendState';
|
||||
import { getStoryDataFromMessageAttributes } from './storyLoader';
|
||||
|
||||
const MAX_THROTTLED_REDUX_UPDATERS = 200;
|
||||
|
@ -95,13 +96,42 @@ export class MessageCache {
|
|||
conversationId: string;
|
||||
obsoleteId: string;
|
||||
}): void {
|
||||
const updateSendState = (
|
||||
sendState?: SendStateByConversationId
|
||||
): SendStateByConversationId | undefined => {
|
||||
if (!sendState?.[obsoleteId]) {
|
||||
return sendState;
|
||||
}
|
||||
const { [obsoleteId]: obsoleteSendState, ...rest } = sendState;
|
||||
return {
|
||||
[conversationId]: obsoleteSendState,
|
||||
...rest,
|
||||
};
|
||||
};
|
||||
|
||||
for (const [messageId, messageAttributes] of this.state.messages) {
|
||||
if (messageAttributes.conversationId !== obsoleteId) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const editHistory = messageAttributes.editHistory?.map(history => {
|
||||
return {
|
||||
...history,
|
||||
sendStateByConversationId: updateSendState(
|
||||
history.sendStateByConversationId
|
||||
),
|
||||
};
|
||||
});
|
||||
|
||||
this.setAttributes({
|
||||
messageId,
|
||||
messageAttributes: { conversationId },
|
||||
messageAttributes: {
|
||||
conversationId,
|
||||
sendStateByConversationId: updateSendState(
|
||||
messageAttributes.sendStateByConversationId
|
||||
),
|
||||
editHistory,
|
||||
},
|
||||
skipSaveToDatabase: true,
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue