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) { }).then(function (contacts) {
expect($roster.find('dd:visible').eq(0).text().trim()).toBe('Candice van der Knijff'); 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').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 = _converse.rosterview.$('.roster-filter');
$filter.val("an"); $filter.val("an");
$filter.trigger('keydown'); $filter.trigger('keydown');
@ -204,7 +204,7 @@
return $roster.find('dt:visible').length === 1; return $roster.find('dt:visible').length === 1;
}, 500); }, 500);
}).then(function () { }).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); expect($roster.find('dd:visible').length).toBe(3);
// Check that all contacts under the group are shown // Check that all contacts under the group are shown
expect($roster.find('dt:visible').nextUntil('dt', 'dd:hidden').length).toBe(0); 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 */ /* Get the roster from the XMPP server */
var iq = $iq({type: 'get', 'id': _converse.connection.getUniqueId('roster')}) var iq = $iq({type: 'get', 'id': _converse.connection.getUniqueId('roster')})
.c('query', {xmlns: Strophe.NS.ROSTER}); .c('query', {xmlns: Strophe.NS.ROSTER});
var that = this;
return _converse.connection.sendIQ(iq, function () { return _converse.connection.sendIQ(iq, function () {
this.onReceivedFromServer.apply(this, arguments); that.onReceivedFromServer.apply(that, arguments);
callback.apply(this, arguments); callback.apply(that, arguments);
}.bind(this)); });
}, },
onReceivedFromServer: function (iq) { onReceivedFromServer: function (iq) {

View File

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