Hydrate redux before updating conversations' last messages after import
This commit is contained in:
parent
e27b99aa61
commit
af4718dbfe
3 changed files with 41 additions and 19 deletions
|
@ -2,7 +2,7 @@
|
|||
// SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
import { partition } from 'lodash';
|
||||
import * as log from '../logging/log';
|
||||
import * as logger from '../logging/log';
|
||||
import { isLongMessage } from '../types/MIME';
|
||||
import { getMessageIdForLogging } from './idForLogging';
|
||||
import {
|
||||
|
@ -50,14 +50,15 @@ function getAttachmentSignatureSafe(
|
|||
try {
|
||||
return getAttachmentSignature(attachment);
|
||||
} catch {
|
||||
log.warn(
|
||||
'queueAttachmentDownloads: attachment was missing digest',
|
||||
attachment.blurHash
|
||||
);
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
|
||||
function getLogger(source: AttachmentDownloadSource) {
|
||||
const verbose = source !== AttachmentDownloadSource.BACKUP_IMPORT;
|
||||
const log = verbose ? logger : { ...logger, info: () => null };
|
||||
return log;
|
||||
}
|
||||
// Receive logic
|
||||
// NOTE: If you're changing any logic in this function that deals with the
|
||||
// count then you'll also have to modify ./hasAttachmentsDownloads
|
||||
|
@ -79,10 +80,7 @@ export async function queueAttachmentDownloads(
|
|||
let bodyAttachment;
|
||||
|
||||
const idLog = `queueAttachmentDownloads(${idForLogging}})`;
|
||||
|
||||
log.info(
|
||||
`${idLog}: Queueing ${attachmentsToQueue.length} attachment downloads`
|
||||
);
|
||||
const log = getLogger(source);
|
||||
|
||||
const [longMessageAttachments, normalAttachments] = partition(
|
||||
attachmentsToQueue,
|
||||
|
@ -328,12 +326,12 @@ export async function queueAttachmentDownloads(
|
|||
);
|
||||
}
|
||||
|
||||
log.info(`${idLog}: Queued ${count} total attachment downloads`);
|
||||
|
||||
if (count <= 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
log.info(`${idLog}: Queued ${count} total attachment downloads`);
|
||||
|
||||
return {
|
||||
attachments,
|
||||
bodyAttachment,
|
||||
|
@ -367,6 +365,7 @@ async function queueNormalAttachments({
|
|||
attachments: Array<AttachmentType>;
|
||||
count: number;
|
||||
}> {
|
||||
const log = getLogger(source);
|
||||
// Look through "otherAttachments" which can either be attachments in the
|
||||
// edit history or the message's attachments and see if any of the attachments
|
||||
// are the same. If they are let's replace it so that we don't download more
|
||||
|
@ -465,6 +464,7 @@ async function queuePreviews({
|
|||
urgency: AttachmentDownloadUrgency;
|
||||
source: AttachmentDownloadSource;
|
||||
}): Promise<{ preview: Array<LinkPreviewType>; count: number }> {
|
||||
const log = getLogger(source);
|
||||
// Similar to queueNormalAttachments' logic for detecting same attachments
|
||||
// except here we also pick by link preview URL.
|
||||
const previewSignatures: Map<string, LinkPreviewType> = new Map();
|
||||
|
@ -560,6 +560,7 @@ async function queueQuoteAttachments({
|
|||
urgency: AttachmentDownloadUrgency;
|
||||
source: AttachmentDownloadSource;
|
||||
}): Promise<{ quote?: QuotedMessageType; count: number }> {
|
||||
const log = getLogger(source);
|
||||
let count = 0;
|
||||
if (!quote) {
|
||||
return { quote, count };
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue