mirror of
https://github.com/signalapp/Signal-Desktop.git
synced 2026-05-08 08:58:38 +01:00
Trigger update events after attachments load
Mostly so we can ensure we're scrolled to the bottom when the conversation is loaded.
This commit is contained in:
@@ -18,6 +18,12 @@
|
||||
|
||||
var ImageView = Backbone.View.extend({
|
||||
tagName: 'img',
|
||||
events: {
|
||||
'load': 'update'
|
||||
},
|
||||
update: function() {
|
||||
this.$el.trigger('update');
|
||||
},
|
||||
render: function(dataUrl) {
|
||||
this.$el.attr('src', dataUrl);
|
||||
return this;
|
||||
@@ -27,6 +33,15 @@
|
||||
var MediaView = Backbone.View.extend({
|
||||
initialize: function() {
|
||||
this.$el.attr('controls', '');
|
||||
this.$el.on('loadeddata', function() {
|
||||
this.$el.trigger('update');
|
||||
}.bind(this));
|
||||
},
|
||||
events: {
|
||||
'loadeddata': 'update'
|
||||
},
|
||||
update: function() {
|
||||
this.$el.trigger('update');
|
||||
},
|
||||
render: function(dataUrl, contentType) {
|
||||
var $el = $('<source>');
|
||||
@@ -52,9 +67,9 @@
|
||||
default:
|
||||
throw 'Unsupported attachment type';
|
||||
}
|
||||
view.$el.appendTo(this.$el);
|
||||
var blob = new Blob([this.model.data], {type: this.model.contentType});
|
||||
view.render(window.URL.createObjectURL(blob), this.model.contentType);
|
||||
view.$el.appendTo(this.$el);
|
||||
return this;
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user