diff --git a/ts/background.ts b/ts/background.ts index edf90b7f03c9..f5fadea707b0 100644 --- a/ts/background.ts +++ b/ts/background.ts @@ -1891,6 +1891,10 @@ export async function startApp(): Promise { } } + // When true - we are running the very first storage and contact sync after + // linking. + let isInitialSync = false; + let connectCount = 0; let connecting = false; async function connect(firstRun?: boolean) { @@ -1904,6 +1908,9 @@ export async function startApp(): Promise { try { connecting = true; + // Reset the flag and update it below if needed + isInitialSync = false; + log.info('connect', { firstRun, connectCount }); if (reconnectTimer) { @@ -2145,6 +2152,7 @@ export async function startApp(): Promise { const contactSyncComplete = waitForEvent('contactSync:complete'); log.info('firstRun: requesting initial sync'); + isInitialSync = true; // Request configuration, block, GV1 sync messages, contacts // (only avatars and inboxPosition),and Storage Service sync. @@ -2176,6 +2184,9 @@ export async function startApp(): Promise { ); } + log.info('firstRun: initial sync complete'); + isInitialSync = false; + // Switch to inbox view even if contact sync is still running if ( window.reduxStore.getState().app.appView === AppViewType.Installer @@ -2641,6 +2652,7 @@ export async function startApp(): Promise { undefined, { fromSync: true, + isInitialSync, } ); } diff --git a/ts/models/conversations.ts b/ts/models/conversations.ts index f6422d409d7d..6fcfe0941b2c 100644 --- a/ts/models/conversations.ts +++ b/ts/models/conversations.ts @@ -4460,7 +4460,15 @@ export class ConversationModel extends window.Backbone providedExpireTimer: number | undefined, providedSource?: unknown, initiatingMessage?: MessageModel, - options: { fromSync?: unknown; fromGroupUpdate?: unknown } = {} + { + fromSync = false, + isInitialSync = false, + fromGroupUpdate = false, + }: { + fromSync?: boolean; + isInitialSync?: boolean; + fromGroupUpdate?: boolean; + } = {} ): Promise { const isSetByOther = providedSource || initiatingMessage; @@ -4490,8 +4498,6 @@ export class ConversationModel extends window.Backbone return false; } - window._.defaults(options, { fromSync: false, fromGroupUpdate: false }); - if (!expireTimer) { expireTimer = undefined; } @@ -4548,14 +4554,14 @@ export class ConversationModel extends window.Backbone expirationTimerUpdate: { expireTimer, source, - fromSync: options.fromSync, - fromGroupUpdate: options.fromGroupUpdate, + fromSync, + fromGroupUpdate, }, flags: Proto.DataMessage.Flags.EXPIRATION_TIMER_UPDATE, - readStatus: ReadStatus.Unread, + readStatus: isInitialSync ? ReadStatus.Read : ReadStatus.Unread, received_at_ms: receivedAtMS, received_at: receivedAt, - seenStatus: SeenStatus.Unseen, + seenStatus: isInitialSync ? SeenStatus.Seen : SeenStatus.Unseen, sent_at: sentAt, type: 'timer-notification', // TODO: DESKTOP-722