Replace MessageController with MessageCache
This commit is contained in:
parent
ba1a8aad09
commit
7d35216fda
73 changed files with 2237 additions and 1229 deletions
|
@ -3,13 +3,13 @@
|
|||
|
||||
import * as log from '../logging/log';
|
||||
import type { MessageAttributesType } from '../model-types.d';
|
||||
import type { MessageModel } from '../models/messages';
|
||||
import * as Errors from '../types/errors';
|
||||
import type { MessageModel } from '../models/messages';
|
||||
|
||||
export async function getMessageById(
|
||||
export async function __DEPRECATED$getMessageById(
|
||||
messageId: string
|
||||
): Promise<MessageModel | undefined> {
|
||||
const message = window.MessageController.getById(messageId);
|
||||
const message = window.MessageCache.__DEPRECATED$getById(messageId);
|
||||
if (message) {
|
||||
return message;
|
||||
}
|
||||
|
@ -28,5 +28,9 @@ export async function getMessageById(
|
|||
return undefined;
|
||||
}
|
||||
|
||||
return window.MessageController.register(found.id, found);
|
||||
return window.MessageCache.__DEPRECATED$register(
|
||||
found.id,
|
||||
found,
|
||||
'__DEPRECATED$getMessageById'
|
||||
);
|
||||
}
|
||||
|
|
|
@ -13,7 +13,7 @@ export async function getMessagesById(
|
|||
const messageIdsToLookUpInDatabase: Array<string> = [];
|
||||
|
||||
for (const messageId of messageIds) {
|
||||
const message = window.MessageController.getById(messageId);
|
||||
const message = window.MessageCache.__DEPRECATED$getById(messageId);
|
||||
if (message) {
|
||||
messagesFromMemory.push(message);
|
||||
} else {
|
||||
|
@ -39,7 +39,11 @@ export async function getMessagesById(
|
|||
// We use `window.Whisper.Message` instead of `MessageModel` here to avoid a circular
|
||||
// import.
|
||||
const message = new window.Whisper.Message(rawMessage);
|
||||
return window.MessageController.register(message.id, message);
|
||||
return window.MessageCache.__DEPRECATED$register(
|
||||
message.id,
|
||||
message,
|
||||
'getMessagesById'
|
||||
);
|
||||
});
|
||||
|
||||
return [...messagesFromMemory, ...messagesFromDatabase];
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue