Initialize schema version during Message construction

This commit is contained in:
Daniel Gasienica 2018-03-16 18:35:27 -04:00
parent 9a540d6d18
commit e3dbeba963

View file

@ -5,10 +5,16 @@
'use strict'; 'use strict';
window.Whisper = window.Whisper || {}; window.Whisper = window.Whisper || {};
const { Message: TypedMessage } = window.Signal.Types;
var Message = window.Whisper.Message = Backbone.Model.extend({ var Message = window.Whisper.Message = Backbone.Model.extend({
database : Whisper.Database, database : Whisper.Database,
storeName : 'messages', storeName : 'messages',
initialize: function() { initialize: function(attributes) {
if (_.isObject(attributes)) {
this.set(TypedMessage.initializeSchemaVersion(attributes));
}
this.on('change:attachments', this.updateImageUrl); this.on('change:attachments', this.updateImageUrl);
this.on('destroy', this.revokeImageUrl); this.on('destroy', this.revokeImageUrl);
this.on('change:expirationStartTimestamp', this.setToExpire); this.on('change:expirationStartTimestamp', this.setToExpire);