Remove outgoing message attachment caches
Co-authored-by: trevor-signal <131492920+trevor-signal@users.noreply.github.com>
This commit is contained in:
parent
12eaea43b6
commit
bafebbdbd1
3 changed files with 4 additions and 55 deletions
|
@ -889,9 +889,7 @@ async function uploadMessagePreviews({
|
||||||
targetTimestamp,
|
targetTimestamp,
|
||||||
});
|
});
|
||||||
|
|
||||||
const loadedPreviews =
|
const loadedPreviews = await loadPreviewData(startingPreview);
|
||||||
message.cachedOutgoingPreviewData ||
|
|
||||||
(await loadPreviewData(startingPreview));
|
|
||||||
|
|
||||||
if (!loadedPreviews) {
|
if (!loadedPreviews) {
|
||||||
return undefined;
|
return undefined;
|
||||||
|
@ -973,9 +971,7 @@ async function uploadMessageSticker(
|
||||||
// See uploadMessageQuote for comment on how we do caching for these
|
// See uploadMessageQuote for comment on how we do caching for these
|
||||||
// attachments.
|
// attachments.
|
||||||
const startingSticker = message.get('sticker');
|
const startingSticker = message.get('sticker');
|
||||||
const stickerWithData =
|
const stickerWithData = await loadStickerData(startingSticker);
|
||||||
message.cachedOutgoingStickerData ||
|
|
||||||
(await loadStickerData(startingSticker));
|
|
||||||
|
|
||||||
if (!stickerWithData) {
|
if (!stickerWithData) {
|
||||||
return undefined;
|
return undefined;
|
||||||
|
@ -1019,9 +1015,7 @@ async function uploadMessageContacts(
|
||||||
|
|
||||||
// See uploadMessageQuote for comment on how we do caching for these
|
// See uploadMessageQuote for comment on how we do caching for these
|
||||||
// attachments.
|
// attachments.
|
||||||
const contacts =
|
const contacts = await loadContactData(message.get('contact'));
|
||||||
message.cachedOutgoingContactData ||
|
|
||||||
(await loadContactData(message.get('contact')));
|
|
||||||
|
|
||||||
if (!contacts) {
|
if (!contacts) {
|
||||||
return undefined;
|
return undefined;
|
||||||
|
|
|
@ -3956,26 +3956,6 @@ export class ConversationModel extends window.Backbone
|
||||||
model,
|
model,
|
||||||
'enqueueMessageForSend'
|
'enqueueMessageForSend'
|
||||||
);
|
);
|
||||||
message.cachedOutgoingContactData = contact;
|
|
||||||
|
|
||||||
// Attach path to preview images so that sendNormalMessage can use them to
|
|
||||||
// update digests on attachments.
|
|
||||||
if (preview) {
|
|
||||||
message.cachedOutgoingPreviewData = preview.map((item, index) => {
|
|
||||||
if (!item.image) {
|
|
||||||
return item;
|
|
||||||
}
|
|
||||||
|
|
||||||
return {
|
|
||||||
...item,
|
|
||||||
image: {
|
|
||||||
...item.image,
|
|
||||||
path: attributes.preview?.at(index)?.image?.path,
|
|
||||||
},
|
|
||||||
};
|
|
||||||
});
|
|
||||||
}
|
|
||||||
message.cachedOutgoingStickerData = sticker;
|
|
||||||
|
|
||||||
const dbStart = Date.now();
|
const dbStart = Date.now();
|
||||||
|
|
||||||
|
|
|
@ -109,10 +109,7 @@ import {
|
||||||
NotificationType,
|
NotificationType,
|
||||||
notificationService,
|
notificationService,
|
||||||
} from '../services/notifications';
|
} from '../services/notifications';
|
||||||
import type {
|
import type { LinkPreviewType } from '../types/message/LinkPreviews';
|
||||||
LinkPreviewType,
|
|
||||||
LinkPreviewWithHydratedData,
|
|
||||||
} from '../types/message/LinkPreviews';
|
|
||||||
import * as log from '../logging/log';
|
import * as log from '../logging/log';
|
||||||
import { cleanupMessage, deleteMessageData } from '../util/cleanup';
|
import { cleanupMessage, deleteMessageData } from '../util/cleanup';
|
||||||
import {
|
import {
|
||||||
|
@ -130,11 +127,9 @@ import { queueAttachmentDownloads } from '../util/queueAttachmentDownloads';
|
||||||
import { findStoryMessages } from '../util/findStoryMessage';
|
import { findStoryMessages } from '../util/findStoryMessage';
|
||||||
import type { ConversationQueueJobData } from '../jobs/conversationJobQueue';
|
import type { ConversationQueueJobData } from '../jobs/conversationJobQueue';
|
||||||
import { shouldDownloadStory } from '../util/shouldDownloadStory';
|
import { shouldDownloadStory } from '../util/shouldDownloadStory';
|
||||||
import type { EmbeddedContactWithHydratedAvatar } from '../types/EmbeddedContact';
|
|
||||||
import { SeenStatus } from '../MessageSeenStatus';
|
import { SeenStatus } from '../MessageSeenStatus';
|
||||||
import { isNewReactionReplacingPrevious } from '../reactions/util';
|
import { isNewReactionReplacingPrevious } from '../reactions/util';
|
||||||
import { parseBoostBadgeListFromServer } from '../badges/parseBadgesFromServer';
|
import { parseBoostBadgeListFromServer } from '../badges/parseBadgesFromServer';
|
||||||
import type { StickerWithHydratedData } from '../types/Stickers';
|
|
||||||
|
|
||||||
import {
|
import {
|
||||||
addToAttachmentDownloadQueue,
|
addToAttachmentDownloadQueue,
|
||||||
|
@ -188,12 +183,6 @@ export class MessageModel extends window.Backbone.Model<MessageAttributesType> {
|
||||||
|
|
||||||
syncPromise?: Promise<CallbackResultType | void>;
|
syncPromise?: Promise<CallbackResultType | void>;
|
||||||
|
|
||||||
cachedOutgoingContactData?: Array<EmbeddedContactWithHydratedAvatar>;
|
|
||||||
|
|
||||||
cachedOutgoingPreviewData?: Array<LinkPreviewWithHydratedData>;
|
|
||||||
|
|
||||||
cachedOutgoingStickerData?: StickerWithHydratedData;
|
|
||||||
|
|
||||||
public registerLocations: Set<string>;
|
public registerLocations: Set<string>;
|
||||||
|
|
||||||
constructor(attributes: MessageAttributesType) {
|
constructor(attributes: MessageAttributesType) {
|
||||||
|
@ -847,11 +836,6 @@ export class MessageModel extends window.Backbone.Model<MessageAttributesType> {
|
||||||
this.set(attributesToUpdate);
|
this.set(attributesToUpdate);
|
||||||
}
|
}
|
||||||
|
|
||||||
// We aren't trying to send this message anymore, so we'll delete these caches
|
|
||||||
delete this.cachedOutgoingContactData;
|
|
||||||
delete this.cachedOutgoingPreviewData;
|
|
||||||
delete this.cachedOutgoingStickerData;
|
|
||||||
|
|
||||||
this.notifyStorySendFailed();
|
this.notifyStorySendFailed();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1121,15 +1105,6 @@ export class MessageModel extends window.Backbone.Model<MessageAttributesType> {
|
||||||
|
|
||||||
await Promise.all(promises);
|
await Promise.all(promises);
|
||||||
|
|
||||||
const isTotalSuccess: boolean =
|
|
||||||
result.success && !this.get('errors')?.length;
|
|
||||||
|
|
||||||
if (isTotalSuccess) {
|
|
||||||
delete this.cachedOutgoingContactData;
|
|
||||||
delete this.cachedOutgoingPreviewData;
|
|
||||||
delete this.cachedOutgoingStickerData;
|
|
||||||
}
|
|
||||||
|
|
||||||
updateLeftPane();
|
updateLeftPane();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue