Commit cd3cc412 authored by JC Brand's avatar JC Brand

Move updateOnlineCount to controlbox, where it belongs.

parent 6d766f68
...@@ -323,9 +323,7 @@ ...@@ -323,9 +323,7 @@
onControlBoxToggleHidden: function () { onControlBoxToggleHidden: function () {
this.$el.show('fast', function () { this.$el.show('fast', function () {
if (converse.rosterview) { converse.controlboxtoggle.updateOnlineCount();
converse.rosterview.updateOnlineCount();
}
utils.refreshWebkit(); utils.refreshWebkit();
converse.emit('controlBoxOpened', this); converse.emit('controlBoxOpened', this);
}.bind(this)); }.bind(this));
...@@ -680,6 +678,12 @@ ...@@ -680,6 +678,12 @@
initialize: function () { initialize: function () {
this.render(); this.render();
converse.on('initialized', function () {
converse.roster.on("add", this.updateOnlineCount, this);
converse.roster.on('change', this.updateOnlineCount, this);
converse.roster.on("destroy", this.updateOnlineCount, this);
converse.roster.on("remove", this.updateOnlineCount, this);
}.bind(this));
}, },
render: function () { render: function () {
...@@ -696,6 +700,14 @@ ...@@ -696,6 +700,14 @@
return this; return this;
}, },
updateOnlineCount: function () {
var $count = this.$('#online-count');
$count.text('('+converse.roster.getNumOnlineContacts()+')');
if (!$count.is(':visible')) {
$count.show();
}
},
hide: function (callback) { hide: function (callback) {
this.$el.fadeOut('fast', callback); this.$el.fadeOut('fast', callback);
}, },
......
...@@ -226,7 +226,6 @@ ...@@ -226,7 +226,6 @@
* Debounced so that it doesn't get called for every * Debounced so that it doesn't get called for every
* contact fetched from browser storage. * contact fetched from browser storage.
*/ */
converse.log('updateFilter called!!!!!!');
var type = this.filter_view.model.get('filter_type'); var type = this.filter_view.model.get('filter_type');
if (type === 'state') { if (type === 'state') {
this.filter(this.filter_view.model.get('chat_state'), type); this.filter(this.filter_view.model.get('chat_state'), type);
...@@ -244,16 +243,7 @@ ...@@ -244,16 +243,7 @@
delete this.presence_ref; delete this.presence_ref;
}, },
updateOnlineCount: function () {
var $count = $('#online-count');
$count.text('('+converse.roster.getNumOnlineContacts()+')');
if (!$count.is(':visible')) {
$count.show();
}
},
update: _.debounce(function () { update: _.debounce(function () {
this.updateOnlineCount();
if (this.$roster.parent().length === 0) { if (this.$roster.parent().length === 0) {
this.$el.append(this.$roster.show()); this.$el.append(this.$roster.show());
} }
......
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