Wire up Message / Attachment migration functions on startup

Makes `migrationContext` obsolete.
This commit is contained in:
Daniel Gasienica 2018-03-26 10:17:45 -04:00
parent 867f73b80a
commit 0c06fff47b
5 changed files with 25 additions and 26 deletions

View file

@ -10,7 +10,7 @@
window.Whisper = window.Whisper || {};
const { Attachment, Message } = window.Signal.Types;
const { context: migrationContext } = window.Signal.Migrations;
const { upgradeMessageSchema, loadAttachmentData } = window.Signal.Migrations;
// TODO: Factor out private and group subclasses of Conversation
@ -618,7 +618,7 @@
now
);
const messageWithSchema = await Message.upgradeSchema({
const messageWithSchema = await upgradeMessageSchema({
type: 'outgoing',
body,
conversationId: this.id,
@ -627,7 +627,7 @@
received_at: now,
expireTimer: this.get('expireTimer'),
recipients: this.getRecipients(),
}, migrationContext);
});
const message = this.messageCollection.add(messageWithSchema);
if (this.isPrivate()) {
message.set({ destination: this.id });
@ -657,9 +657,8 @@
profileKey = storage.get('profileKey');
}
const loadData = Attachment.loadData(migrationContext.readAttachmentData);
const attachmentsWithData =
await Promise.all(messageWithSchema.attachments.map(loadData));
await Promise.all(messageWithSchema.attachments.map(loadAttachmentData));
message.send(sendFunction(
this.get('id'),
body,

View file

@ -5,7 +5,7 @@
window.Whisper = window.Whisper || {};
const { Attachment, Message: TypedMessage } = window.Signal.Types;
const { context: migrationContext } = window.Signal.Migrations;
const { deleteAttachmentData } = window.Signal.Migrations;
var Message = window.Whisper.Message = Backbone.Model.extend({
database : Whisper.Database,
@ -147,9 +147,7 @@
async onDestroy() {
this.revokeImageUrl();
const attachments = this.get('attachments');
const deleteData =
Attachment.deleteData(migrationContext.deleteAttachmentData);
await Promise.all(attachments.map(deleteData));
await Promise.all(attachments.map(deleteAttachmentData));
},
/* jshint ignore:end */
/* eslint-disable */