Remove refs to MessageModel in conversations.ts

This commit is contained in:
Fedor Indutny 2024-07-25 16:29:49 -07:00 committed by GitHub
parent 2550af9c91
commit cc6ff0b554
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
17 changed files with 312 additions and 357 deletions

View file

@ -307,20 +307,17 @@ export async function sendStoryMessage(
// * Save the message model
// * Add the message to the conversation
await Promise.all(
distributionListMessages.map(messageAttributes => {
const model = new window.Whisper.Message(messageAttributes);
const message = window.MessageCache.__DEPRECATED$register(
model.id,
model,
distributionListMessages.map(message => {
window.MessageCache.__DEPRECATED$register(
message.id,
new window.Whisper.Message(message),
'sendStoryMessage'
);
void ourConversation.addSingleMessage(model, { isJustSent: true });
void ourConversation.addSingleMessage(message, { isJustSent: true });
log.info(
`stories.sendStoryMessage: saving message ${messageAttributes.timestamp}`
);
return DataWriter.saveMessage(message.attributes, {
log.info(`stories.sendStoryMessage: saving message ${message.timestamp}`);
return DataWriter.saveMessage(message, {
forceSave: true,
ourAci: window.textsecure.storage.user.getCheckedAci(),
});
@ -362,20 +359,21 @@ export async function sendStoryMessage(
timestamp: messageAttributes.timestamp,
},
async jobToInsert => {
const model = new window.Whisper.Message(messageAttributes);
const message = window.MessageCache.__DEPRECATED$register(
model.id,
model,
window.MessageCache.__DEPRECATED$register(
messageAttributes.id,
new window.Whisper.Message(messageAttributes),
'sendStoryMessage'
);
const conversation = message.getConversation();
void conversation?.addSingleMessage(model, { isJustSent: true });
const conversation =
window.ConversationController.get(conversationId);
void conversation?.addSingleMessage(messageAttributes, {
isJustSent: true,
});
log.info(
`stories.sendStoryMessage: saving message ${messageAttributes.timestamp}`
);
await DataWriter.saveMessage(message.attributes, {
await DataWriter.saveMessage(messageAttributes, {
forceSave: true,
jobToInsert,
ourAci: window.textsecure.storage.user.getCheckedAci(),