Bugfix. show method must be debounced per instance

Otherwise it gets debounced for multiple instances and certain chat boxes will
then not get shown.
This commit is contained in:
JC Brand 2016-03-09 10:53:39 +00:00
parent d893d9782a
commit 6eb08bd42f

View File

@ -2252,26 +2252,38 @@
return this;
},
show: _.debounce(function (focus) {
if (this.$el.is(':visible') && this.$el.css('opacity') === "1") {
if (focus) { this.focus(); }
return this;
show: function (focus) {
if (typeof this.debouncedShow === 'undefined') {
/* We wrap the method in a debouncer and set it on the
* instance, so that we have it debounced per instance.
* Debouncing it on the class-level is too broad.
*/
this.debouncedShow = _.debounce(function (focus) {
if (this.$el.is(':visible') && this.$el.css('opacity') === "1") {
if (focus) { this.focus(); }
return this;
}
this.initDragResize().setDimensions();
// We call trimChats before fading in, to avoid ugly transition
// effects.
converse.chatboxviews.trimChats(this);
this.$el.fadeIn(function () {
if (converse.connection.connected) {
// Without a connection, we haven't yet initialized
// localstorage
this.model.save();
}
this.setChatState(converse.ACTIVE);
this.scrollDown();
if (focus) {
this.focus();
}
}.bind(this));
}, 250, true);
}
this.initDragResize().setDimensions();
this.$el.fadeIn(function () {
if (converse.connection.connected) {
// Without a connection, we haven't yet initialized
// localstorage
this.model.save();
}
this.setChatState(converse.ACTIVE);
this.scrollDown();
if (focus) {
this.focus();
}
}.bind(this));
this.debouncedShow.apply(this, arguments);
return this;
}, 250, true),
},
scrollDownMessageHeight: function ($message) {
if (this.$content.is(':visible')) {