Skip to content

Commit c836eb4

Browse files
committed
disco: Import individual lodash methods
1 parent 762717d commit c836eb4

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

src/headless/converse-disco.js

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,12 @@
88
* @description
99
* Converse plugin which add support for XEP-0030: Service Discovery
1010
*/
11+
import { get, isEmpty, isObject } from "lodash";
1112
import converse from "./converse-core";
1213
import log from "./log";
1314
import sizzle from "sizzle";
1415

15-
const { Backbone, Strophe, $iq, utils, _ } = converse.env;
16+
const { Backbone, Strophe, $iq, utils } = converse.env;
1617

1718
converse.plugins.add('converse-disco', {
1819

@@ -174,7 +175,7 @@ converse.plugins.add('converse-disco', {
174175
},
175176

176177
async queryForItems () {
177-
if (_.isEmpty(this.identities.where({'category': 'server'}))) {
178+
if (isEmpty(this.identities.where({'category': 'server'}))) {
178179
// Don't fetch features and items if this is not a
179180
// server or a conference component.
180181
return;
@@ -196,7 +197,7 @@ converse.plugins.add('converse-disco', {
196197
const data = {};
197198
sizzle('field', form).forEach(field => {
198199
data[field.getAttribute('var')] = {
199-
'value': _.get(field.querySelector('value'), 'textContent'),
200+
'value': get(field.querySelector('value'), 'textContent'),
200201
'type': field.getAttribute('type')
201202
};
202203
});
@@ -217,7 +218,7 @@ converse.plugins.add('converse-disco', {
217218
sizzle('x[type="result"][xmlns="jabber:x:data"] field', stanza).forEach(field => {
218219
this.fields.create({
219220
'var': field.getAttribute('var'),
220-
'value': _.get(field.querySelector('value'), 'textContent'),
221+
'value': get(field.querySelector('value'), 'textContent'),
221222
'from': stanza.getAttribute('from')
222223
});
223224
});
@@ -660,12 +661,9 @@ converse.plugins.add('converse-disco', {
660661
return;
661662
}
662663
entity = await entity.waitUntilFeaturesDiscovered;
663-
const promises = _.concat(
664-
entity.items.map(item => item.hasFeature(feature)),
665-
entity.hasFeature(feature)
666-
);
664+
const promises = [...entity.items.map(i => i.hasFeature(feature)), entity.hasFeature(feature)];
667665
const result = await Promise.all(promises);
668-
return _.filter(result, _.isObject);
666+
return result.filter(isObject);
669667
}
670668
},
671669

0 commit comments

Comments
 (0)