Frontend support for ReplayableErrors

Eventually we'll store errors on the message model, and this change will
let us render and process them.
This commit is contained in:
lilia 2014-12-18 20:06:45 -08:00
parent 4a401f07f3
commit e68720f07f

View file

@ -38,6 +38,20 @@
}
});
var ErrorView = Backbone.View.extend({
className: 'error',
events: {
'click' : 'replay'
},
replay: function() {
new window.textsecure.ReplayableError(this.model).replay();
},
render: function() {
this.$el.text(this.model.message);
return this;
}
});
window.Whisper = window.Whisper || {};
Whisper.MessageView = Backbone.View.extend({
@ -71,6 +85,15 @@
})
);
var errors = this.model.get('errors');
if (errors && errors.length) {
this.$el.find('.message').append(
errors.map(function(error) {
return new ErrorView({model: error}).render().el;
})
);
}
return this;
}