Replace MessageController with MessageCache

This commit is contained in:
Josh Perez 2023-10-03 20:12:57 -04:00 committed by GitHub
parent ba1a8aad09
commit 7d35216fda
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
73 changed files with 2237 additions and 1229 deletions

View file

@ -25,7 +25,7 @@ export function cleanupMessageFromMemory(message: MessageAttributesType): void {
const parentConversation = window.ConversationController.get(conversationId);
parentConversation?.debouncedUpdateLastMessage();
window.MessageController.unregister(id);
window.MessageCache.__DEPRECATED$unregister(id);
}
async function cleanupStoryReplies(
@ -72,9 +72,10 @@ async function cleanupStoryReplies(
// Cleanup all group replies
await Promise.all(
replies.map(reply => {
const replyMessageModel = window.MessageController.register(
const replyMessageModel = window.MessageCache.__DEPRECATED$register(
reply.id,
reply
reply,
'cleanupStoryReplies/group'
);
return replyMessageModel.eraseContents();
})
@ -83,7 +84,11 @@ async function cleanupStoryReplies(
// Refresh the storyReplyContext data for 1:1 conversations
await Promise.all(
replies.map(async reply => {
const model = window.MessageController.register(reply.id, reply);
const model = window.MessageCache.__DEPRECATED$register(
reply.id,
reply,
'cleanupStoryReplies/1:1'
);
model.unset('storyReplyContext');
await model.hydrateStoryContext(story, { shouldSave: true });
})