Fix out of order edit message read syncs
This commit is contained in:
parent
cf28e2dc2c
commit
372d9c2198
4 changed files with 13 additions and 28 deletions
|
@ -34,9 +34,13 @@ import { strictAssert } from './assert';
|
|||
export async function modifyTargetMessage(
|
||||
message: MessageModel,
|
||||
conversation: ConversationModel,
|
||||
options?: { isFirstRun: boolean; skipEdits: boolean }
|
||||
options?: { isFirstRun: boolean; skipEdits: boolean; skipSave: boolean }
|
||||
): Promise<void> {
|
||||
const { isFirstRun = false, skipEdits = false } = options ?? {};
|
||||
const {
|
||||
isFirstRun = false,
|
||||
skipEdits = false,
|
||||
skipSave = false,
|
||||
} = options ?? {};
|
||||
|
||||
const logId = `modifyTargetMessage/${message.idForLogging()}`;
|
||||
const type = message.get('type');
|
||||
|
@ -111,13 +115,10 @@ export async function modifyTargetMessage(
|
|||
|
||||
const viewSyncs = ViewSyncs.forMessage(message);
|
||||
|
||||
log.info(`${logId}: ReadSync-1`, { length: readSyncs.length });
|
||||
|
||||
const isGroupStoryReply =
|
||||
isGroup(conversation.attributes) && message.get('storyId');
|
||||
|
||||
if (readSyncs.length !== 0 || viewSyncs.length !== 0) {
|
||||
log.info(`${logId}: ReadSync-2`);
|
||||
const markReadAt = Math.min(
|
||||
Date.now(),
|
||||
...readSyncs.map(sync => sync.readAt),
|
||||
|
@ -152,7 +153,6 @@ export async function modifyTargetMessage(
|
|||
});
|
||||
changed = true;
|
||||
|
||||
log.info(`${logId}: ReadSync-3`);
|
||||
message.setPendingMarkRead(
|
||||
Math.min(message.getPendingMarkRead() ?? Date.now(), markReadAt)
|
||||
);
|
||||
|
@ -161,12 +161,10 @@ export async function modifyTargetMessage(
|
|||
!isGroupStoryReply &&
|
||||
canConversationBeUnarchived(conversation.attributes)
|
||||
) {
|
||||
log.info(`${logId}: ReadSync-4`);
|
||||
conversation.setArchived(false);
|
||||
}
|
||||
|
||||
if (!isFirstRun && message.getPendingMarkRead()) {
|
||||
log.info(`${logId}: ReadSync-5`);
|
||||
const markReadAt = message.getPendingMarkRead();
|
||||
message.setPendingMarkRead(undefined);
|
||||
|
||||
|
@ -263,7 +261,7 @@ export async function modifyTargetMessage(
|
|||
);
|
||||
}
|
||||
|
||||
if (changed && !isFirstRun) {
|
||||
if (!skipSave && changed && !isFirstRun) {
|
||||
log.info(`${logId}: Changes in second run; saving.`);
|
||||
await window.Signal.Data.saveMessage(message.attributes, {
|
||||
ourAci,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue