remove uneeded passing of models to Data calls

pull/1530/head
Audric Ackermann 4 years ago
parent ad117fe4e5
commit 5f862e4c08
No known key found for this signature in database
GPG Key ID: 999F434D76324AD4

@ -285,9 +285,7 @@
if (conversation) {
conversation.removeMessage(id);
}
window.Signal.Data.removeMessage(id, {
Message: window.models.Message.MessageModel,
});
window.Signal.Data.removeMessage(id);
});
}
);
@ -305,9 +303,7 @@
window.log.info('Cleanup: starting...');
const results = await Promise.all([
window.Signal.Data.getOutgoingWithoutExpiresAt({
MessageCollection: window.models.Message.MessageCollection,
}),
window.Signal.Data.getOutgoingWithoutExpiresAt(),
]);
// Combine the models
@ -344,9 +340,7 @@
}
window.log.info(`Cleanup: Deleting unsent message ${sentAt}`);
await window.Signal.Data.removeMessage(message.id, {
Message: window.models.Message.MessageModel,
});
await window.Signal.Data.removeMessage(message.id);
})
);
window.log.info('Cleanup: complete');

@ -62,10 +62,7 @@
async onReceipt(receipt) {
try {
const messages = await window.Signal.Data.getMessagesBySentAt(
receipt.get('timestamp'),
{
MessageCollection: window.models.Message.MessageCollection,
}
receipt.get('timestamp')
);
const message = await this.getTargetMessage(

@ -16,9 +16,7 @@
async function destroyExpiredMessages() {
try {
window.log.info('destroyExpiredMessages: Loading messages...');
const messages = await window.Signal.Data.getExpiredMessages({
MessageCollection: window.models.Message.MessageCollection,
});
const messages = await window.Signal.Data.getExpiredMessages();
await Promise.all(
messages.map(async fromDB => {
@ -30,9 +28,7 @@
// We delete after the trigger to allow the conversation time to process
// the expiration before the message is removed from the database.
await window.Signal.Data.removeMessage(message.id, {
Message: window.models.Message.MessageModel,
});
await window.Signal.Data.removeMessage(message.id);
Whisper.events.trigger('messageExpired', {
conversationKey: message.attributes.conversationId,
@ -59,9 +55,7 @@
let timeout;
async function checkExpiringMessages() {
// Look up the next expiring message and set a timer to destroy it
const messages = await window.Signal.Data.getNextExpiringMessage({
MessageCollection: window.models.Message.MessageCollection,
});
const messages = await window.Signal.Data.getNextExpiringMessage();
const next = messages.at(0);
if (!next) {

@ -142,9 +142,7 @@ async function _runJob(job) {
);
}
const found = await getMessageById(messageId, {
Message: models.Message.MessageModel,
});
const found = await getMessageById(messageId);
if (!found) {
logger.error('_runJob: Source message not found, deleting job');
await _finishJob(null, id);
@ -226,9 +224,7 @@ async function _runJob(job) {
async function _finishJob(message, id) {
if (message) {
await saveMessage(message.attributes, {
Message: models.Message.MessageModel,
});
await saveMessage(message.attributes);
const conversation = message.getConversation();
if (conversation) {
message.commit();

@ -193,9 +193,7 @@ async function importConversationsFromJSON(conversations, options) {
}
);
// eslint-disable-next-line no-await-in-loop
await window.Signal.Data.saveConversation(migrated, {
Conversation: window.models.Conversation.ConversationModel,
});
await window.Signal.Data.saveConversation(migrated);
}
window.log.info(
@ -693,7 +691,6 @@ async function exportConversation(conversation, options = {}) {
{
limit: CHUNK_SIZE,
receivedAt: lastReceivedAt,
MessageCollection: window.models.Message.MessageCollection,
}
);
const messages = getPlainJS(collection);

@ -2019,9 +2019,7 @@ class LokiPublicChannelAPI {
payload.annotations[0].value.quote = quote;
// copied from model/message.js copyFromQuotedMessage
const collection = await Signal.Data.getMessagesBySentAt(quote.id, {
MessageCollection: window.models.Message.MessageCollection,
});
const collection = await Signal.Data.getMessagesBySentAt(quote.id);
const found = collection.find(item => {
const messageAuthor = item.getContact();

@ -62,10 +62,7 @@
async onReceipt(receipt) {
try {
const messages = await window.Signal.Data.getMessagesBySentAt(
receipt.get('timestamp'),
{
MessageCollection: window.models.Message.MessageCollection,
}
receipt.get('timestamp')
);
const message = await this.getTargetMessage(

@ -28,10 +28,7 @@
async onReceipt(receipt) {
try {
const messages = await window.Signal.Data.getMessagesBySentAt(
receipt.get('timestamp'),
{
MessageCollection: window.models.Message.MessageCollection,
}
receipt.get('timestamp')
);
const found = messages.find(

@ -495,9 +495,7 @@ describe('Backup', () => {
console.log('Backup test: Create models, save to db/disk');
const message = await upgradeMessageSchema(messageWithAttachments);
await window.Signal.Data.saveMessage(message, {
Message: window.models.Message.MessageModel,
});
await window.Signal.Data.saveMessage(message);
const conversation = {
active_at: 1524185933350,
@ -518,9 +516,7 @@ describe('Backup', () => {
version: 2,
};
console.log({ conversation });
await window.Signal.Data.saveConversation(conversation, {
Conversation: window.models.Conversation.ConversationModel,
});
await window.Signal.Data.saveConversation(conversation);
console.log(
'Backup test: Ensure that all attachments were saved to disk'
@ -579,9 +575,7 @@ describe('Backup', () => {
);
console.log('Backup test: Check messages');
const messageCollection = await window.Signal.Data.getAllMessages({
MessageCollection: window.models.Message.MessageCollection,
});
const messageCollection = await window.Signal.Data.getAllMessages();
assert.strictEqual(messageCollection.length, MESSAGE_COUNT);
const messageFromDB = removeId(messageCollection.at(0).attributes);
const expectedMessage = messageFromDB;

@ -234,9 +234,7 @@ Whisper.Fixtures = () => {
conversationCollection.saveAll = function thisNeeded() {
Promise.all(
this.map(async (convo) => {
await window.Signal.Data.saveConversation(convo.attributes, {
Conversation: window.models.Conversation.ConversationModel,
});
await window.Signal.Data.saveConversation(convo.attributes);
await Promise.all(
convo.messageCollection.map(async (message) => {

@ -560,14 +560,12 @@ function handleMessageChanged(
const updatedWithFirstMessageOfSeries = updateFirstMessageOfSeries(
sortedMessage
);
console.timeEnd('handleMessageChanged' + payload.id);
return {
...state,
messages: updatedWithFirstMessageOfSeries,
};
}
console.timeEnd('handleMessageChanged' + payload.id);
return state;
}
@ -577,7 +575,6 @@ function handleMessagesChanged(
action: MessagesChangedActionType
) {
const { payload } = action;
console.time('handleMessagesChanged' + payload.length);
payload.forEach(element => {
// tslint:disable-next-line: no-parameter-reassignment
@ -587,8 +584,6 @@ function handleMessagesChanged(
});
});
console.timeEnd('handleMessagesChanged' + payload.length);
return state;
}

Loading…
Cancel
Save