Remove outgoing message attachment caches
This commit is contained in:
parent
012e771fc2
commit
72a55da2b2
3 changed files with 4 additions and 55 deletions
|
@ -889,9 +889,7 @@ async function uploadMessagePreviews({
|
|||
targetTimestamp,
|
||||
});
|
||||
|
||||
const loadedPreviews =
|
||||
message.cachedOutgoingPreviewData ||
|
||||
(await loadPreviewData(startingPreview));
|
||||
const loadedPreviews = await loadPreviewData(startingPreview);
|
||||
|
||||
if (!loadedPreviews) {
|
||||
return undefined;
|
||||
|
@ -973,9 +971,7 @@ async function uploadMessageSticker(
|
|||
// See uploadMessageQuote for comment on how we do caching for these
|
||||
// attachments.
|
||||
const startingSticker = message.get('sticker');
|
||||
const stickerWithData =
|
||||
message.cachedOutgoingStickerData ||
|
||||
(await loadStickerData(startingSticker));
|
||||
const stickerWithData = await loadStickerData(startingSticker);
|
||||
|
||||
if (!stickerWithData) {
|
||||
return undefined;
|
||||
|
@ -1019,9 +1015,7 @@ async function uploadMessageContacts(
|
|||
|
||||
// See uploadMessageQuote for comment on how we do caching for these
|
||||
// attachments.
|
||||
const contacts =
|
||||
message.cachedOutgoingContactData ||
|
||||
(await loadContactData(message.get('contact')));
|
||||
const contacts = await loadContactData(message.get('contact'));
|
||||
|
||||
if (!contacts) {
|
||||
return undefined;
|
||||
|
|
|
@ -3956,26 +3956,6 @@ export class ConversationModel extends window.Backbone
|
|||
model,
|
||||
'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();
|
||||
|
||||
|
|
|
@ -109,10 +109,7 @@ import {
|
|||
NotificationType,
|
||||
notificationService,
|
||||
} from '../services/notifications';
|
||||
import type {
|
||||
LinkPreviewType,
|
||||
LinkPreviewWithHydratedData,
|
||||
} from '../types/message/LinkPreviews';
|
||||
import type { LinkPreviewType } from '../types/message/LinkPreviews';
|
||||
import * as log from '../logging/log';
|
||||
import { cleanupMessage, deleteMessageData } from '../util/cleanup';
|
||||
import {
|
||||
|
@ -130,11 +127,9 @@ import { queueAttachmentDownloads } from '../util/queueAttachmentDownloads';
|
|||
import { findStoryMessages } from '../util/findStoryMessage';
|
||||
import type { ConversationQueueJobData } from '../jobs/conversationJobQueue';
|
||||
import { shouldDownloadStory } from '../util/shouldDownloadStory';
|
||||
import type { EmbeddedContactWithHydratedAvatar } from '../types/EmbeddedContact';
|
||||
import { SeenStatus } from '../MessageSeenStatus';
|
||||
import { isNewReactionReplacingPrevious } from '../reactions/util';
|
||||
import { parseBoostBadgeListFromServer } from '../badges/parseBadgesFromServer';
|
||||
import type { StickerWithHydratedData } from '../types/Stickers';
|
||||
|
||||
import {
|
||||
addToAttachmentDownloadQueue,
|
||||
|
@ -188,12 +183,6 @@ export class MessageModel extends window.Backbone.Model<MessageAttributesType> {
|
|||
|
||||
syncPromise?: Promise<CallbackResultType | void>;
|
||||
|
||||
cachedOutgoingContactData?: Array<EmbeddedContactWithHydratedAvatar>;
|
||||
|
||||
cachedOutgoingPreviewData?: Array<LinkPreviewWithHydratedData>;
|
||||
|
||||
cachedOutgoingStickerData?: StickerWithHydratedData;
|
||||
|
||||
public registerLocations: Set<string>;
|
||||
|
||||
constructor(attributes: MessageAttributesType) {
|
||||
|
@ -847,11 +836,6 @@ export class MessageModel extends window.Backbone.Model<MessageAttributesType> {
|
|||
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();
|
||||
}
|
||||
|
||||
|
@ -1121,15 +1105,6 @@ export class MessageModel extends window.Backbone.Model<MessageAttributesType> {
|
|||
|
||||
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();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue