Commit 6eb08bd4 authored by JC Brand's avatar JC Brand

Bugfix. show method must be debounced per instance

Otherwise it gets debounced for multiple instances and certain chat boxes will
then not get shown.
parent d893d978
......@@ -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')) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment