Commit 768ed4a5 authored by JC Brand's avatar JC Brand

Replace lodash methods with built-ins, convert docstrings to JSDoc

parent ea22cdd7
...@@ -496,7 +496,7 @@ converse.plugins.add('converse-minimize', { ...@@ -496,7 +496,7 @@ converse.plugins.add('converse-minimize', {
}, },
addMultipleChats (items) { addMultipleChats (items) {
_.each(items, this.addChatView.bind(this)); items.forEach(item => this.addChatView(item));
this.toggleview.model.set({'num_minimized': this.keys().length}); this.toggleview.model.set({'num_minimized': this.keys().length});
this.render(); this.render();
}, },
......
...@@ -192,10 +192,14 @@ converse.plugins.add('converse-muc-views', { ...@@ -192,10 +192,14 @@ converse.plugins.add('converse-muc-views', {
})); }));
} }
/**
* Show/hide extra information about a groupchat in a listing.
* @function toggleRoomInfo
* @param { Event }
*/
function toggleRoomInfo (ev) { function toggleRoomInfo (ev) {
/* Show/hide extra information about a groupchat in a listing. */ const parent_el = u.ancestor(ev.target, '.room-item');
const parent_el = u.ancestor(ev.target, '.room-item'), const div_el = parent_el.querySelector('div.room-info');
div_el = parent_el.querySelector('div.room-info');
if (div_el) { if (div_el) {
u.slideIn(div_el).then(u.removeElement) u.slideIn(div_el).then(u.removeElement)
parent_el.querySelector('a.room-info').classList.remove('selected'); parent_el.querySelector('a.room-info').classList.remove('selected');
...@@ -203,7 +207,7 @@ converse.plugins.add('converse-muc-views', { ...@@ -203,7 +207,7 @@ converse.plugins.add('converse-muc-views', {
parent_el.insertAdjacentHTML('beforeend', tpl_spinner()); parent_el.insertAdjacentHTML('beforeend', tpl_spinner());
_converse.api.disco.info(ev.target.getAttribute('data-room-jid'), null) _converse.api.disco.info(ev.target.getAttribute('data-room-jid'), null)
.then(stanza => insertRoomInfo(parent_el, stanza)) .then(stanza => insertRoomInfo(parent_el, stanza))
.catch(_.partial(_converse.log, _, Strophe.LogLevel.ERROR)); .catch(e => _converse.log(e, Strophe.LogLevel.ERROR));
} }
} }
...@@ -1312,7 +1316,7 @@ converse.plugins.add('converse-muc-views', { ...@@ -1312,7 +1316,7 @@ converse.plugins.add('converse-muc-views', {
this.showSpinner(); this.showSpinner();
this.model.fetchRoomConfiguration() this.model.fetchRoomConfiguration()
.then(iq => this.renderConfigurationForm(iq)) .then(iq => this.renderConfigurationForm(iq))
.catch(_.partial(_converse.log, _, Strophe.LogLevel.ERROR)); .catch(e => _converse.log(e, Strophe.LogLevel.ERROR));
} else { } else {
this.closeForm(); this.closeForm();
} }
...@@ -2072,7 +2076,7 @@ converse.plugins.add('converse-muc-views', { ...@@ -2072,7 +2076,7 @@ converse.plugins.add('converse-muc-views', {
// Features could have been added before the controlbox was // Features could have been added before the controlbox was
// initialized. We're only interested in MUC // initialized. We're only interested in MUC
_converse.disco_entities.each(entity => featureAdded(entity.features.findWhere({'var': Strophe.NS.MUC }))); _converse.disco_entities.each(entity => featureAdded(entity.features.findWhere({'var': Strophe.NS.MUC })));
}).catch(_.partial(_converse.log, _, Strophe.LogLevel.ERROR)); }).catch(e => _converse.log(e, Strophe.LogLevel.ERROR));
} }
function fetchAndSetMUCDomain (controlboxview) { function fetchAndSetMUCDomain (controlboxview) {
...@@ -2124,7 +2128,7 @@ converse.plugins.add('converse-muc-views', { ...@@ -2124,7 +2128,7 @@ converse.plugins.add('converse-muc-views', {
return; return;
} }
fetchAndSetMUCDomain(view); fetchAndSetMUCDomain(view);
view.model.on('change:connected', _.partial(fetchAndSetMUCDomain, view)); view.model.on('change:connected', () => fetchAndSetMUCDomain(view));
}); });
/************************ END Event Handlers ************************/ /************************ END Event Handlers ************************/
......
...@@ -81,7 +81,7 @@ converse.plugins.add("converse-oauth", { ...@@ -81,7 +81,7 @@ converse.plugins.add("converse-oauth", {
'sync': function sync () {}, 'sync': function sync () {},
initialize () { initialize () {
_.each(_converse.user_settings.oauth_providers, (provider) => { _converse.user_settings.oauth_providers.forEach(provider => {
const item = new Backbone.Model(Object.assign(provider, { const item = new Backbone.Model(Object.assign(provider, {
'login_text': __('Log in with %1$s', provider.name) 'login_text': __('Log in with %1$s', provider.name)
})); }));
......
...@@ -1022,8 +1022,8 @@ converse.plugins.add('converse-omemo', { ...@@ -1022,8 +1022,8 @@ converse.plugins.add('converse-omemo', {
if (this._devices_promise === undefined) { if (this._devices_promise === undefined) {
this._devices_promise = new Promise(resolve => { this._devices_promise = new Promise(resolve => {
this.devices.fetch({ this.devices.fetch({
'success': _.flow(c => this.onDevicesFound(c), resolve), 'success': c => resolve(this.onDevicesFound(c)),
'error': _.flow(_.partial(_converse.log, _, Strophe.LogLevel.ERROR), resolve) 'error': e => { _converse.log(e, Strophe.LogLevel.ERROR); resolve(); }
}); });
}); });
} }
...@@ -1265,11 +1265,11 @@ converse.plugins.add('converse-omemo', { ...@@ -1265,11 +1265,11 @@ converse.plugins.add('converse-omemo', {
_converse.api.listen.on('userDetailsModalInitialized', (contact) => { _converse.api.listen.on('userDetailsModalInitialized', (contact) => {
const jid = contact.get('jid'); const jid = contact.get('jid');
_converse.generateFingerprints(jid).catch(_.partial(_converse.log, _, Strophe.LogLevel.ERROR)); _converse.generateFingerprints(jid).catch(e => _converse.log(e, Strophe.LogLevel.ERROR));
}); });
_converse.api.listen.on('profileModalInitialized', (contact) => { _converse.api.listen.on('profileModalInitialized', (contact) => {
_converse.generateFingerprints(_converse.bare_jid).catch(_.partial(_converse.log, _, Strophe.LogLevel.ERROR)); _converse.generateFingerprints(_converse.bare_jid).catch(e => _converse.log(e, Strophe.LogLevel.ERROR));
}); });
_converse.api.listen.on('afterTearDown', () => (delete _converse.omemo_store)); _converse.api.listen.on('afterTearDown', () => (delete _converse.omemo_store));
......
...@@ -142,10 +142,10 @@ converse.plugins.add('converse-register', { ...@@ -142,10 +142,10 @@ converse.plugins.add('converse-register', {
_converse.api.waitUntil('controlBoxInitialized').then(() => { _converse.api.waitUntil('controlBoxInitialized').then(() => {
const controlbox = _converse.chatboxes.get('controlbox') const controlbox = _converse.chatboxes.get('controlbox')
controlbox.set({'active-form': value}); controlbox.set({'active-form': value});
}).catch(_.partial(_converse.log, _, Strophe.LogLevel.FATAL)); }).catch(e => _converse.log(e, Strophe.LogLevel.FATAL));
} }
_converse.router.route('converse/login', _.partial(setActiveForm, 'login')); _converse.router.route('converse/login', () => setActiveForm('login'));
_converse.router.route('converse/register', _.partial(setActiveForm, 'register')); _converse.router.route('converse/register', () => setActiveForm('register'));
_converse.RegisterLinkView = Backbone.VDOMView.extend({ _converse.RegisterLinkView = Backbone.VDOMView.extend({
......
...@@ -536,6 +536,11 @@ converse.plugins.add('converse-rosterview', { ...@@ -536,6 +536,11 @@ converse.plugins.add('converse-rosterview', {
} }
}); });
/**
* @class
* @namespace _converse.RosterGroupView
* @memberOf _converse
*/
_converse.RosterGroupView = OrderedListView.extend({ _converse.RosterGroupView = OrderedListView.extend({
tagName: 'div', tagName: 'div',
className: 'roster-group hidden', className: 'roster-group hidden',
...@@ -655,6 +660,7 @@ converse.plugins.add('converse-rosterview', { ...@@ -655,6 +660,7 @@ converse.plugins.add('converse-rosterview', {
* If all contacts are filtered out (i.e. hidden), then the * If all contacts are filtered out (i.e. hidden), then the
* group must be filtered out as well. * group must be filtered out as well.
* @private * @private
* @method _converse.RosterGroupView#filter
* @param { string } q - The query to filter against * @param { string } q - The query to filter against
* @param { string } type * @param { string } type
*/ */
...@@ -728,6 +734,11 @@ converse.plugins.add('converse-rosterview', { ...@@ -728,6 +734,11 @@ converse.plugins.add('converse-rosterview', {
}); });
/**
* @class
* @namespace _converse.RosterView
* @memberOf _converse
*/
_converse.RosterView = OrderedListView.extend({ _converse.RosterView = OrderedListView.extend({
tagName: 'div', tagName: 'div',
id: 'converse-roster', id: 'converse-roster',
...@@ -830,27 +841,21 @@ converse.plugins.add('converse-rosterview', { ...@@ -830,27 +841,21 @@ converse.plugins.add('converse-rosterview', {
}, },
filter (query, type) { filter (query, type) {
// First we make sure the filter is restored to its const views = Object.values(this.getAll());
// original state // First ensure the filter is restored to its original state
_.each(this.getAll(), function (view) { views.forEach(v => (v.model.contacts.length > 0) && v.show().filter(''));
if (view.model.contacts.length > 0) {
view.show().filter('');
}
});
// Now we can filter // Now we can filter
query = query.toLowerCase(); query = query.toLowerCase();
if (type === 'groups') { if (type === 'groups') {
_.each(this.getAll(), function (view, idx) { views.forEach(view => {
if (!_.includes(view.model.get('name').toLowerCase(), query.toLowerCase())) { if (!view.model.get('name').toLowerCase().includes(query)) {
u.slideIn(view.el); u.slideIn(view.el);
} else if (view.model.contacts.length > 0) { } else if (view.model.contacts.length > 0) {
u.slideOut(view.el); u.slideOut(view.el);
} }
}); });
} else { } else {
_.each(this.getAll(), function (view) { views.forEach(v => v.filter(query, type));
view.filter(query, type);
});
} }
}, },
...@@ -893,10 +898,14 @@ converse.plugins.add('converse-rosterview', { ...@@ -893,10 +898,14 @@ converse.plugins.add('converse-rosterview', {
this.updateFilter(); this.updateFilter();
}, },
getGroup (name) { /**
/* Returns the group as specified by name. * Returns the group as specified by name.
* Creates the group if it doesn't exist. * Creates the group if it doesn't exist.
* @method _converse.RosterView#getGroup
* @private
* @param {string} name
*/ */
getGroup (name) {
const view = this.get(name); const view = this.get(name);
if (view) { if (view) {
return view.model; return view.model;
...@@ -913,13 +922,11 @@ converse.plugins.add('converse-rosterview', { ...@@ -913,13 +922,11 @@ converse.plugins.add('converse-rosterview', {
let groups; let groups;
if (_converse.roster_groups) { if (_converse.roster_groups) {
groups = contact.get('groups'); groups = contact.get('groups');
if (groups.length === 0) { groups = (groups.length === 0) ? [_converse.HEADER_UNGROUPED] : groups;
groups = [_converse.HEADER_UNGROUPED];
}
} else { } else {
groups = [_converse.HEADER_CURRENT_CONTACTS]; groups = [_converse.HEADER_CURRENT_CONTACTS];
} }
_.each(groups, _.bind(this.addContactToGroup, this, contact, _, options)); groups.forEach(g => this.addContactToGroup(contact, g, options));
}, },
addRosterContact (contact, options) { addRosterContact (contact, options) {
...@@ -965,7 +972,7 @@ converse.plugins.add('converse-rosterview', { ...@@ -965,7 +972,7 @@ converse.plugins.add('converse-rosterview', {
/* Place the rosterview inside the "Contacts" panel. */ /* Place the rosterview inside the "Contacts" panel. */
_converse.api.waitUntil('rosterViewInitialized') _converse.api.waitUntil('rosterViewInitialized')
.then(() => view.controlbox_pane.el.insertAdjacentElement('beforeEnd', _converse.rosterview.el)) .then(() => view.controlbox_pane.el.insertAdjacentElement('beforeEnd', _converse.rosterview.el))
.catch(_.partial(_converse.log, _, Strophe.LogLevel.FATAL)); .catch(e => _converse.log(e, Strophe.LogLevel.FATAL));
} }
insertRoster(); insertRoster();
view.model.on('change:connected', insertRoster); view.model.on('change:connected', insertRoster);
......
...@@ -290,7 +290,7 @@ converse.plugins.add('converse-bookmarks', { ...@@ -290,7 +290,7 @@ converse.plugins.add('converse-bookmarks', {
if (sizzle('event[xmlns="'+Strophe.NS.PUBSUB+'#event"] items[node="storage:bookmarks"]', message).length) { if (sizzle('event[xmlns="'+Strophe.NS.PUBSUB+'#event"] items[node="storage:bookmarks"]', message).length) {
_converse.api.waitUntil('bookmarksInitialized') _converse.api.waitUntil('bookmarksInitialized')
.then(() => _converse.bookmarks.createBookmarksFromStanza(message)) .then(() => _converse.bookmarks.createBookmarksFromStanza(message))
.catch(_.partial(_converse.log, _, Strophe.LogLevel.FATAL)); .catch(e => _converse.log(e, Strophe.LogLevel.FATAL));
} }
}, null, 'message', 'headline', null, _converse.bare_jid); }, null, 'message', 'headline', null, _converse.bare_jid);
......
...@@ -1461,7 +1461,7 @@ converse.plugins.add('converse-chatboxes', { ...@@ -1461,7 +1461,7 @@ converse.plugins.add('converse-chatboxes', {
} else if (_.isString(jids)) { } else if (_.isString(jids)) {
return _converse.chatboxes.getChatBox(jids); return _converse.chatboxes.getChatBox(jids);
} }
return jids.map(_.partial(_converse.chatboxes.getChatBox.bind(_converse.chatboxes), _, {}, true)); return jids.map(jid => _converse.chatboxes.getChatBox(jid, {}, true));
} }
} }
}); });
......
...@@ -1127,8 +1127,8 @@ _converse.initialize = async function (settings, callback) { ...@@ -1127,8 +1127,8 @@ _converse.initialize = async function (settings, callback) {
_converse.xmppstatus = new this.XMPPStatus({'id': id}); _converse.xmppstatus = new this.XMPPStatus({'id': id});
_converse.xmppstatus.browserStorage = new BrowserStorage.session(id); _converse.xmppstatus.browserStorage = new BrowserStorage.session(id);
_converse.xmppstatus.fetch({ _converse.xmppstatus.fetch({
'success': _.partial(_converse.onStatusInitialized, reconnecting), 'success': () => _converse.onStatusInitialized(reconnecting),
'error': _.partial(_converse.onStatusInitialized, reconnecting), 'error': () => _converse.onStatusInitialized(reconnecting),
'silent': true 'silent': true
}); });
} }
......
...@@ -154,9 +154,9 @@ converse.plugins.add('converse-disco', { ...@@ -154,9 +154,9 @@ converse.plugins.add('converse-disco', {
}, },
onDiscoItems (stanza) { onDiscoItems (stanza) {
_.each(sizzle(`query[xmlns="${Strophe.NS.DISCO_ITEMS}"] item`, stanza), (item) => { sizzle(`query[xmlns="${Strophe.NS.DISCO_ITEMS}"] item`, stanza).forEach(item => {
if (item.getAttribute("node")) { if (item.getAttribute("node")) {
// XXX: ignore nodes for now. // XXX: Ignore nodes for now.
// See: https://xmpp.org/extensions/xep-0030.html#items-nodes // See: https://xmpp.org/extensions/xep-0030.html#items-nodes
return; return;
} }
...@@ -191,9 +191,9 @@ converse.plugins.add('converse-disco', { ...@@ -191,9 +191,9 @@ converse.plugins.add('converse-disco', {
}); });
}); });
_.each(sizzle(`x[type="result"][xmlns="${Strophe.NS.XFORM}"]`, stanza), (form) => { sizzle(`x[type="result"][xmlns="${Strophe.NS.XFORM}"]`, stanza).forEach(form => {
const data = {}; const data = {};
_.each(form.querySelectorAll('field'), (field) => { sizzle('field', form).forEach(field => {
data[field.getAttribute('var')] = { data[field.getAttribute('var')] = {
'value': _.get(field.querySelector('value'), 'textContent'), 'value': _.get(field.querySelector('value'), 'textContent'),
'type': field.getAttribute('type') 'type': field.getAttribute('type')
...@@ -308,7 +308,7 @@ converse.plugins.add('converse-disco', { ...@@ -308,7 +308,7 @@ converse.plugins.add('converse-disco', {
iqresult.attrs({'to': from}); iqresult.attrs({'to': from});
} }
iqresult.c('query', attrs); iqresult.c('query', attrs);
_.each(plugin._identities, (identity) => { plugin._identities.forEach(identity => {
const attrs = { const attrs = {
'category': identity.category, 'category': identity.category,
'type': identity.type 'type': identity.type
...@@ -321,9 +321,7 @@ converse.plugins.add('converse-disco', { ...@@ -321,9 +321,7 @@ converse.plugins.add('converse-disco', {
} }
iqresult.c('identity', attrs).up(); iqresult.c('identity', attrs).up();
}); });
_.each(plugin._features, (feature) => { plugin._features(feature => iqresult.c('feature', {'var': feature}).up());
iqresult.c('feature', {'var': feature}).up();
});
_converse.api.send(iqresult.tree()); _converse.api.send(iqresult.tree());
return true; return true;
} }
...@@ -771,7 +769,7 @@ converse.plugins.add('converse-disco', { ...@@ -771,7 +769,7 @@ converse.plugins.add('converse-disco', {
* // The entity DOES NOT have this identity * // The entity DOES NOT have this identity
* } * }
* } * }
* ).catch(_.partial(_converse.log, _, Strophe.LogLevel.FATAL)); * ).catch(e => _converse.log(e, Strophe.LogLevel.FATAL));
*/ */
async getIdentity (category, type, jid) { async getIdentity (category, type, jid) {
const e = await _converse.api.disco.entities.get(jid, true); const e = await _converse.api.disco.entities.get(jid, true);
......
...@@ -486,7 +486,7 @@ converse.plugins.add('converse-muc', { ...@@ -486,7 +486,7 @@ converse.plugins.add('converse-muc', {
const storage = _converse.config.get('storage'); const storage = _converse.config.get('storage');
const id = `converse.muc-features-${_converse.bare_jid}-${this.get('jid')}`; const id = `converse.muc-features-${_converse.bare_jid}-${this.get('jid')}`;
this.features = new Backbone.Model( this.features = new Backbone.Model(
_.assign({id}, _.zipObject(converse.ROOM_FEATURES, _.map(converse.ROOM_FEATURES, _.stubFalse))) _.assign({id}, _.zipObject(converse.ROOM_FEATURES, converse.ROOM_FEATURES.map(_.stubFalse)))
); );
this.features.browserStorage = new BrowserStorage.session(id); this.features.browserStorage = new BrowserStorage.session(id);
}, },
...@@ -848,7 +848,7 @@ converse.plugins.add('converse-muc', { ...@@ -848,7 +848,7 @@ converse.plugins.add('converse-muc', {
const features = await _converse.api.disco.getFeatures(this.get('jid')); const features = await _converse.api.disco.getFeatures(this.get('jid'));
const attrs = Object.assign( const attrs = Object.assign(
_.zipObject(converse.ROOM_FEATURES, _.map(converse.ROOM_FEATURES, _.stubFalse)), _.zipObject(converse.ROOM_FEATURES, converse.ROOM_FEATURES.map(_.stubFalse)),
{'fetched': (new Date()).toISOString()} {'fetched': (new Date()).toISOString()}
); );
features.each(feature => { features.each(feature => {
...@@ -900,8 +900,8 @@ converse.plugins.add('converse-muc', { ...@@ -900,8 +900,8 @@ converse.plugins.add('converse-muc', {
* has return a response IQ. * has return a response IQ.
*/ */
saveConfiguration (form) { saveConfiguration (form) {
const inputs = form ? sizzle(':input:not([type=button]):not([type=submit])', form) : [], const inputs = form ? sizzle(':input:not([type=button]):not([type=submit])', form) : [];
configArray = _.map(inputs, u.webForm2xForm); const configArray = inputs.map(u.webForm2xForm);
return this.sendConfiguration(configArray); return this.sendConfiguration(configArray);
}, },
...@@ -1283,7 +1283,7 @@ converse.plugins.add('converse-muc', { ...@@ -1283,7 +1283,7 @@ converse.plugins.add('converse-muc', {
} }
const occupant = this.occupants.findOccupant(data); const occupant = this.occupants.findOccupant(data);
if (data.type === 'unavailable' && occupant) { if (data.type === 'unavailable' && occupant) {
if (!_.includes(data.states, converse.MUC_NICK_CHANGED_CODE) && !occupant.isMember()) { if (!data.states.includes(converse.MUC_NICK_CHANGED_CODE) && !occupant.isMember()) {
// We only destroy the occupant if this is not a nickname change operation. // We only destroy the occupant if this is not a nickname change operation.
// and if they're not on the member lists. // and if they're not on the member lists.
// Before destroying we set the new data, so // Before destroying we set the new data, so
...@@ -1575,7 +1575,7 @@ converse.plugins.add('converse-muc', { ...@@ -1575,7 +1575,7 @@ converse.plugins.add('converse-muc', {
}, },
handleDisconnection (stanza) { handleDisconnection (stanza) {
const is_self = !_.isNull(stanza.querySelector("status[code='110']")); const is_self = stanza.querySelector("status[code='110']") !== null;
const x = sizzle(`x[xmlns="${Strophe.NS.MUC_USER}"]`, stanza).pop(); const x = sizzle(`x[xmlns="${Strophe.NS.MUC_USER}"]`, stanza).pop();
if (!x) { if (!x) {
return; return;
...@@ -1831,7 +1831,7 @@ converse.plugins.add('converse-muc', { ...@@ -1831,7 +1831,7 @@ converse.plugins.add('converse-muc', {
const nick = this.get('nick'); const nick = this.get('nick');
if (message.get('references').length) { if (message.get('references').length) {
const mentions = message.get('references').filter(ref => (ref.type === 'mention')).map(ref => ref.value); const mentions = message.get('references').filter(ref => (ref.type === 'mention')).map(ref => ref.value);
return _.includes(mentions, nick); return mentions.includes(nick);
} else { } else {
return (new RegExp(`\\b${nick}\\b`)).test(message.get('message')); return (new RegExp(`\\b${nick}\\b`)).test(message.get('message'));
} }
...@@ -1894,7 +1894,7 @@ converse.plugins.add('converse-muc', { ...@@ -1894,7 +1894,7 @@ converse.plugins.add('converse-muc', {
} }
vcards.push(_converse.vcards.findWhere({'jid': this.get('from')})); vcards.push(_converse.vcards.findWhere({'jid': this.get('from')}));
_.forEach(_.filter(vcards, undefined), (vcard) => { vcards.filter(v => v).forEach(vcard => {
if (hash && vcard.get('image_hash') !== hash) { if (hash && vcard.get('image_hash') !== hash) {
_converse.api.vcard.update(vcard, true); _converse.api.vcard.update(vcard, true);
} }
...@@ -2175,7 +2175,7 @@ converse.plugins.add('converse-muc', { ...@@ -2175,7 +2175,7 @@ converse.plugins.add('converse-muc', {
} else if (_.isString(jids)) { } else if (_.isString(jids)) {
return createChatRoom(jids, attrs); return createChatRoom(jids, attrs);
} }
return _.map(jids, _.partial(createChatRoom, _, attrs)); return jids.map(jid => createChatRoom(jid, attrs));
}, },
/** /**
...@@ -2249,7 +2249,7 @@ converse.plugins.add('converse-muc', { ...@@ -2249,7 +2249,7 @@ converse.plugins.add('converse-muc', {
} }
return room; return room;
} else { } else {
return _.map(jids, jid => _converse.api.rooms.create(jid, attrs).maybeShow(force)); return jids.map(jid => _converse.api.rooms.create(jid, attrs).maybeShow(force));
} }
}, },
...@@ -2297,7 +2297,7 @@ converse.plugins.add('converse-muc', { ...@@ -2297,7 +2297,7 @@ converse.plugins.add('converse-muc', {
if (_.isString(jids)) { if (_.isString(jids)) {
return getChatRoom(jids, attrs); return getChatRoom(jids, attrs);
} }
return _.map(jids, _.partial(getChatRoom, _, attrs)); return jids.map(jid => getChatRoom(jid, attrs));
} }
} }
}); });
......
...@@ -519,7 +519,7 @@ converse.plugins.add('converse-roster', { ...@@ -519,7 +519,7 @@ converse.plugins.add('converse-roster', {
const iq = $iq({'type': 'set'}) const iq = $iq({'type': 'set'})
.c('query', {'xmlns': Strophe.NS.ROSTER}) .c('query', {'xmlns': Strophe.NS.ROSTER})
.c('item', { jid, name }); .c('item', { jid, name });
_.each(groups, group => iq.c('group').t(group).up()); groups.forEach(g => iq.c('group').t(g).up());
return _converse.api.sendIQ(iq); return _converse.api.sendIQ(iq);
}, },
......
...@@ -276,7 +276,7 @@ u.matchesSelector = function (el, selector) { ...@@ -276,7 +276,7 @@ u.matchesSelector = function (el, selector) {
* @param { String } selector - the selector they should be matched against * @param { String } selector - the selector they should be matched against
*/ */
u.queryChildren = function (el, selector) { u.queryChildren = function (el, selector) {
return _.filter(el.childNodes, _.partial(u.matchesSelector, _, selector)); return Array.from(el.childNodes).filter(el => u.matchesSelector(el, selector));
}; };
u.contains = function (attr, query) { u.contains = function (attr, query) {
...@@ -385,8 +385,7 @@ u.interpolate = function (string, o) { ...@@ -385,8 +385,7 @@ u.interpolate = function (string, o) {
* @private * @private
* @method u#onMultipleEvents * @method u#onMultipleEvents
* @param { Array } events: An array of objects, with keys `object` and * @param { Array } events: An array of objects, with keys `object` and
* `event`, representing the event name and the object it's * `event`, representing the event name and the object it's triggered upon.
* triggered upon.
* @param { Function } callback: The function to call once all events have * @param { Function } callback: The function to call once all events have
* been triggered. * been triggered.
*/ */
...@@ -400,7 +399,7 @@ u.onMultipleEvents = function (events=[], callback) { ...@@ -400,7 +399,7 @@ u.onMultipleEvents = function (events=[], callback) {
triggered = []; triggered = [];
} }
} }
_.each(events, (map) => map.object.on(map.event, handler)); events.forEach(e => e.object.on(e.event, handler));
}; };
u.safeSave = function (model, attributes) { u.safeSave = function (model, attributes) {
......
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