diff --git a/.eslintrc.json b/.eslintrc.json index 521cfa696..50215e4a1 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -23,7 +23,7 @@ "ignoreMethods": [ "assign", "every", "keys", "find", "endsWith", "startsWith", "filter", "reduce", "isArray", "create", "map", "replace", "some", "toLower", - "split", "trim", "forEach", "toUpperCase", "includes" + "split", "trim", "forEach", "toUpperCase", "includes", "values" ] }], "lodash/prefer-invoke-map": "off", diff --git a/dist/converse.js b/dist/converse.js index 6af8d742b..6b6f48ba8 100644 --- a/dist/converse.js +++ b/dist/converse.js @@ -59849,8 +59849,6 @@ _converse_headless_converse_core__WEBPACK_IMPORTED_MODULE_4__["default"].plugins }, render() { - const that = this; - if (!this.mayBeShown()) { u.hideElement(this.el); return this; @@ -59861,13 +59859,7 @@ _converse_headless_converse_core__WEBPACK_IMPORTED_MODULE_4__["default"].plugins requesting = this.model.get('requesting'), subscription = this.model.get('subscription'); const classes_to_remove = ['current-xmpp-contact', 'pending-xmpp-contact', 'requesting-xmpp-contact'].concat(Object.keys(STATUSES)); - - _.each(classes_to_remove, function (cls) { - if (_.includes(that.el.className, cls)) { - that.el.classList.remove(cls); - } - }); - + classes_to_remove.forEach(c => u.removeClass(c, this.el)); this.el.classList.add(show); this.el.setAttribute('data-status', show); this.highlight(); @@ -60090,11 +60082,9 @@ _converse_headless_converse_core__WEBPACK_IMPORTED_MODULE_4__["default"].plugins show() { u.showElement(this.el); - _.each(this.getAll(), contact_view => { - if (contact_view.mayBeShown() && this.model.get('state') === _converse.OPENED) { - u.showElement(contact_view.el); - } - }); + if (this.model.get('state') === _converse.OPENED) { + Object.values(this.getAll()).filter(v => v.mayBeShown()).forEach(v => u.showElement(v.el)); + } return this; }, diff --git a/src/converse-rosterview.js b/src/converse-rosterview.js index e2d2caa52..dc0a620fe 100644 --- a/src/converse-rosterview.js +++ b/src/converse-rosterview.js @@ -402,7 +402,6 @@ converse.plugins.add('converse-rosterview', { }, render () { - const that = this; if (!this.mayBeShown()) { u.hideElement(this.el); return this; @@ -417,13 +416,8 @@ converse.plugins.add('converse-rosterview', { 'pending-xmpp-contact', 'requesting-xmpp-contact' ].concat(Object.keys(STATUSES)); + classes_to_remove.forEach(c => u.removeClass(c, this.el)); - _.each(classes_to_remove, - function (cls) { - if (_.includes(that.el.className, cls)) { - that.el.classList.remove(cls); - } - }); this.el.classList.add(show); this.el.setAttribute('data-status', show); this.highlight(); @@ -634,11 +628,11 @@ converse.plugins.add('converse-rosterview', { show () { u.showElement(this.el); - _.each(this.getAll(), (contact_view) => { - if (contact_view.mayBeShown() && this.model.get('state') === _converse.OPENED) { - u.showElement(contact_view.el); - } - }); + if (this.model.get('state') === _converse.OPENED) { + Object.values(this.getAll()) + .filter(v => v.mayBeShown()) + .forEach(v => u.showElement(v.el)); + } return this; },