Fixes #850. .where method doesn't match numbers.

This commit is contained in:
JC Brand 2017-04-21 17:52:54 +02:00
parent 1936e28275
commit f3373c44fd
3 changed files with 14 additions and 13 deletions

View File

@ -151,7 +151,7 @@
}).then(function (contacts) {
expect($roster.find('dd:visible').eq(0).text().trim()).toBe('Candice van der Knijff');
expect($roster.find('dt:visible').length).toBe(1);
expect($roster.find('dt:visible').eq(0).text()).toBe('colleagues');
expect(_.trim($roster.find('dt:visible').eq(0).text())).toBe('colleagues');
$filter = _converse.rosterview.$('.roster-filter');
$filter.val("an");
$filter.trigger('keydown');
@ -204,7 +204,7 @@
return $roster.find('dt:visible').length === 1;
}, 500);
}).then(function () {
expect($roster.find('dt:visible').eq(0).text()).toBe('colleagues');
expect(_.trim($roster.find('dt:visible').eq(0).text())).toBe('colleagues');
expect($roster.find('dd:visible').length).toBe(3);
// Check that all contacts under the group are shown
expect($roster.find('dt:visible').nextUntil('dt', 'dd:hidden').length).toBe(0);

View File

@ -1146,10 +1146,11 @@
/* Get the roster from the XMPP server */
var iq = $iq({type: 'get', 'id': _converse.connection.getUniqueId('roster')})
.c('query', {xmlns: Strophe.NS.ROSTER});
var that = this;
return _converse.connection.sendIQ(iq, function () {
this.onReceivedFromServer.apply(this, arguments);
callback.apply(this, arguments);
}.bind(this));
that.onReceivedFromServer.apply(that, arguments);
callback.apply(that, arguments);
});
},
onReceivedFromServer: function (iq) {

View File

@ -32,6 +32,7 @@
b64_sha1 = converse.env.b64_sha1,
_ = converse.env._;
converse.plugins.add('converse-rosterview', {
overrides: {
@ -643,7 +644,7 @@
// would simplify things by not having to check whether the
// group is collapsed or not.
var name = this.$el.prevAll('dt:first').data('group');
var group = _converse.rosterview.model.where({'name': name})[0];
var group = _.head(_converse.rosterview.model.where({'name': name.toString()}));
if (group.get('state') === _converse.CLOSED) {
return true;
}
@ -742,13 +743,12 @@
render: function () {
this.el.setAttribute('data-group', this.model.get('name'));
this.$el.html(
$(tpl_group_header({
label_group: this.model.get('name'),
desc_group_toggle: this.model.get('description'),
toggle_state: this.model.get('state')
}))
);
var html = tpl_group_header({
label_group: this.model.get('name'),
desc_group_toggle: this.model.get('description'),
toggle_state: this.model.get('state')
});
this.el.innerHTML = html;
return this;
},