Browse Source

Stop using `Model.prototype.extend`

JC Brand 2 years ago
parent
commit
394fbb632c

+ 6 - 3
src/headless/plugins/bookmarks/model.js

@@ -3,11 +3,14 @@ import { Model } from '@converse/skeletor/src/model.js';
 
 const { Strophe } = converse.env;
 
-const Bookmark = Model.extend({
-    idAttribute: 'jid',
+class Bookmark extends Model {
+    get idAttribute () { // eslint-disable-line class-methods-use-this
+        return 'jid';
+    }
+
     getDisplayName () {
         return Strophe.xmlunescape(this.get('name'));
     }
-});
+}
 
 export default Bookmark;

+ 16 - 13
src/headless/plugins/disco/entity.js

@@ -15,10 +15,13 @@ const { Strophe } = converse.env;
  *
  * See XEP-0030: https://xmpp.org/extensions/xep-0030.html
  */
-const DiscoEntity = Model.extend({
-    idAttribute: 'jid',
+class DiscoEntity extends Model {
+    get idAttribute () { // eslint-disable-line class-methods-use-this
+        return 'jid';
+    }
 
     initialize (_, options) {
+        super.initialize();
         this.waitUntilFeaturesDiscovered = getOpenPromise();
 
         this.dataforms = new Collection();
@@ -39,7 +42,7 @@ const DiscoEntity = Model.extend({
         id = `converse.identities-${this.get('jid')}`;
         this.identities.browserStorage = _converse.createStore(id, 'session');
         this.fetchFeatures(options);
-    },
+    }
 
     /**
      * Returns a Promise which resolves with a map indicating
@@ -55,7 +58,7 @@ const DiscoEntity = Model.extend({
             'category': category,
             'type': type,
         });
-    },
+    }
 
     /**
      * Returns a Promise which resolves with a map indicating
@@ -69,7 +72,7 @@ const DiscoEntity = Model.extend({
         if (this.features.findWhere({ 'var': feature })) {
             return this;
         }
-    },
+    }
 
     onFeatureAdded (feature) {
         feature.entity = this;
@@ -81,7 +84,7 @@ const DiscoEntity = Model.extend({
          * @example _converse.api.listen.on('featuresDiscovered', feature => { ... });
          */
         api.trigger('serviceDiscovered', feature);
-    },
+    }
 
     onFieldAdded (field) {
         field.entity = this;
@@ -92,7 +95,7 @@ const DiscoEntity = Model.extend({
          * @example _converse.api.listen.on('discoExtensionFieldDiscovered', () => { ... });
          */
         api.trigger('discoExtensionFieldDiscovered', field);
-    },
+    }
 
     async fetchFeatures (options) {
         if (options.ignore_cache) {
@@ -113,7 +116,7 @@ const DiscoEntity = Model.extend({
                 this.identities.fetch({ add: true });
             }
         }
-    },
+    }
 
     async queryInfo () {
         let stanza;
@@ -125,7 +128,7 @@ const DiscoEntity = Model.extend({
             return;
         }
         this.onInfo(stanza);
-    },
+    }
 
     onDiscoItems (stanza) {
         sizzle(`query[xmlns="${Strophe.NS.DISCO_ITEMS}"] item`, stanza).forEach(item => {
@@ -146,7 +149,7 @@ const DiscoEntity = Model.extend({
                 });
             }
         });
-    },
+    }
 
     async queryForItems () {
         if (this.identities.where({ 'category': 'server' }).length === 0) {
@@ -156,7 +159,7 @@ const DiscoEntity = Model.extend({
         }
         const stanza = await api.disco.items(this.get('jid'));
         this.onDiscoItems(stanza);
-    },
+    }
 
     async onInfo (stanza) {
         Array.from(stanza.querySelectorAll('identity')).forEach(identity => {
@@ -199,7 +202,7 @@ const DiscoEntity = Model.extend({
 
         this.waitUntilFeaturesDiscovered.resolve(this);
         this.trigger('featuresDiscovered');
-    },
-});
+    }
+}
 
 export default DiscoEntity;

+ 10 - 7
src/headless/plugins/emoji/index.js

@@ -59,17 +59,20 @@ converse.plugins.add('converse-emoji', {
 
         /**
          * Model for storing data related to the Emoji picker widget
-         * @class
          * @namespace _converse.EmojiPicker
          * @memberOf _converse
          */
-        _converse.EmojiPicker = Model.extend({
-            defaults: {
-                'current_category': 'smileys',
-                'current_skintone': '',
-                'scroll_position': 0
+        class EmojiPicker extends Model {
+            defaults () { // eslint-disable-line class-methods-use-this
+                return {
+                    'current_category': 'smileys',
+                    'current_skintone': '',
+                    'scroll_position': 0
+                }
             }
-        });
+        }
+
+        _converse.EmojiPicker = EmojiPicker;
 
         // We extend the default converse.js API to add methods specific to MUC groupchats.
         Object.assign(api, {

+ 3 - 3
src/headless/plugins/muc/muc.js

@@ -46,13 +46,13 @@ const METADATA_ATTRIBUTES = [
 
 const ACTION_INFO_CODES = ['301', '303', '333', '307', '321', '322'];
 
-const MUCSession = Model.extend({
-    defaults () {
+class MUCSession extends Model {
+    defaults () { // eslint-disable-line class-methods-use-this
         return {
             'connection_status': ROOMSTATUS.DISCONNECTED
         };
     }
-});
+}
 
 /**
  * Represents an open/ongoing groupchat conversation.

+ 29 - 33
src/headless/plugins/roster/contact.js

@@ -6,23 +6,24 @@ import { rejectPresenceSubscription } from './utils.js';
 
 const { Strophe, $iq, $pres } = converse.env;
 
-/**
- * @class
- * @namespace RosterContact
- */
-const RosterContact = Model.extend({
-    idAttribute: 'jid',
-
-    defaults: {
-        'chat_state': undefined,
-        'groups': [],
-        'image': _converse.DEFAULT_IMAGE,
-        'image_type': _converse.DEFAULT_IMAGE_TYPE,
-        'num_unread': 0,
-        'status': undefined,
-    },
+class RosterContact extends Model {
+    get idAttribute () { // eslint-disable-line class-methods-use-this
+        return 'jid';
+    }
+
+    defaults () { // eslint-disable-line class-methods-use-this
+        return {
+            'chat_state': undefined,
+            'groups': [],
+            'image': _converse.DEFAULT_IMAGE,
+            'image_type': _converse.DEFAULT_IMAGE_TYPE,
+            'num_unread': 0,
+            'status': undefined,
+        }
+    }
 
     async initialize (attributes) {
+        super.initialize(attributes);
         this.initialized = getOpenPromise();
         this.setPresence();
         const { jid } = attributes;
@@ -49,17 +50,17 @@ const RosterContact = Model.extend({
          */
         await api.trigger('rosterContactInitialized', this, {'Synchronous': true});
         this.initialized.resolve();
-    },
+    }
 
     setPresence () {
         const jid = this.get('jid');
         this.presence = _converse.presences.findWhere(jid) || _converse.presences.create({ jid });
-    },
+    }
 
     openChat () {
         const attrs = this.attributes;
         api.chats.open(attrs.jid, attrs, true);
-    },
+    }
 
     /**
      * Return a string of tab-separated values that are to be used when
@@ -76,7 +77,7 @@ const RosterContact = Model.extend({
         criteria = !criteria.includes(jid) ? criteria.concat(`   ${jid}`) : criteria;
         criteria = !criteria.includes(nick) ? criteria.concat(`   ${nick}`) : criteria;
         return criteria.toLowerCase();
-    },
+    }
 
     getDisplayName () {
         // Gets overridden in converse-vcard where the fullname is may be returned
@@ -85,12 +86,12 @@ const RosterContact = Model.extend({
         } else {
             return this.get('jid');
         }
-    },
+    }
 
     getFullname () {
         // Gets overridden in converse-vcard where the fullname may be returned
         return this.get('jid');
-    },
+    }
 
     /**
      * Send a presence subscription request to this roster contact
@@ -102,14 +103,13 @@ const RosterContact = Model.extend({
         api.user.presence.send('subscribe', this.get('jid'), message);
         this.save('ask', "subscribe"); // ask === 'subscribe' Means we have asked to subscribe to them.
         return this;
-    },
+    }
 
     /**
      * Upon receiving the presence stanza of type "subscribed",
      * the user SHOULD acknowledge receipt of that subscription
      * state notification by sending a presence stanza of type
      * "subscribe" to the contact
-     * @private
      * @method _converse.RosterContacts#ackSubscribe
      */
     ackSubscribe () {
@@ -117,7 +117,7 @@ const RosterContact = Model.extend({
             'type': 'subscribe',
             'to': this.get('jid')
         }));
-    },
+    }
 
     /**
      * Upon receiving the presence stanza of type "unsubscribed",
@@ -125,29 +125,26 @@ const RosterContact = Model.extend({
      * notification by sending a presence stanza of type "unsubscribe"
      * this step lets the user's server know that it MUST no longer
      * send notification of the subscription state change to the user.
-     * @private
      * @method _converse.RosterContacts#ackUnsubscribe
      */
     ackUnsubscribe () {
         api.send($pres({'type': 'unsubscribe', 'to': this.get('jid')}));
         this.removeFromRoster();
         this.destroy();
-    },
+    }
 
     /**
      * Unauthorize this contact's presence subscription
-     * @private
      * @method _converse.RosterContacts#unauthorize
      * @param { String } message - Optional message to send to the person being unauthorized
      */
     unauthorize (message) {
         rejectPresenceSubscription(this.get('jid'), message);
         return this;
-    },
+    }
 
     /**
      * Authorize presence subscription
-     * @private
      * @method _converse.RosterContacts#authorize
      * @param { String } message - Optional message to send to the person being authorized
      */
@@ -158,12 +155,11 @@ const RosterContact = Model.extend({
         }
         api.send(pres);
         return this;
-    },
+    }
 
     /**
      * Instruct the XMPP server to remove this contact from our roster
-     * @private
-     * @method _converse.RosterContacts#
+     * @method _converse.RosterContacts#removeFromRoster
      * @returns { Promise }
      */
     removeFromRoster () {
@@ -172,6 +168,6 @@ const RosterContact = Model.extend({
             .c('item', {jid: this.get('jid'), subscription: "remove"});
         return api.sendIQ(iq);
     }
-});
+}
 
 export default RosterContact;

+ 5 - 2
src/headless/plugins/roster/filter.js

@@ -1,11 +1,14 @@
 import { Model } from '@converse/skeletor/src/model.js';
 
-export const RosterFilter = Model.extend({
+class RosterFilter extends Model {
     initialize () {
+        super.initialize();
         this.set({
             'filter_text': '',
             'filter_type': 'contacts',
             'chat_state': 'online'
         });
     }
-});
+}
+
+export { RosterFilter };

+ 16 - 12
src/headless/plugins/roster/presence.js

@@ -10,21 +10,26 @@ export const Resource = Model.extend({'idAttribute': 'name'});
 export const Resources = Collection.extend({'model': Resource});
 
 
-export const Presence = Model.extend({
-    idAttribute: 'jid',
+class Presence extends Model {
+    get idAttribute () { // eslint-disable-line class-methods-use-this
+        return 'jid';
+    }
 
-    defaults: {
-        'show': 'offline'
-    },
+    defaults () { // eslint-disable-line class-methods-use-this
+        return {
+            'show': 'offline'
+        }
+    }
 
     initialize () {
+        super.initialize();
         this.resources = new Resources();
         const id = `converse.identities-${this.get('jid')}`;
         initStorage(this.resources, id, 'session');
 
         this.listenTo(this.resources, 'update', this.onResourcesChanged);
         this.listenTo(this.resources, 'change', this.onResourcesChanged);
-    },
+    }
 
     onResourcesChanged () {
         const hpr = this.getHighestPriorityResource();
@@ -32,7 +37,7 @@ export const Presence = Model.extend({
         if (this.get('show') !== show) {
             this.save({ show });
         }
-    },
+    }
 
     /**
      * Return the resource with the highest priority.
@@ -41,13 +46,12 @@ export const Presence = Model.extend({
      */
     getHighestPriorityResource () {
         return this.resources.sortBy(r => `${r.get('priority')}-${r.get('timestamp')}`).reverse()[0];
-    },
+    }
 
     /**
      * Adds a new resource and it's associated attributes as taken
      * from the passed in presence stanza.
      * Also updates the presence if the resource has higher priority (and is newer).
-     * @private
      * @param { Element } presence: The presence stanza
      */
     addResource (presence) {
@@ -67,20 +71,20 @@ export const Presence = Model.extend({
         } else {
             this.resources.create(settings);
         }
-    },
+    }
 
     /**
      * Remove the passed in resource from the resources map.
      * Also redetermines the presence given that there's one less
      * resource.
-     * @private
      * @param { string } name: The resource name
      */
     removeResource (name) {
         const resource = this.resources.get(name);
         resource?.destroy();
     }
-});
+}
 
+export { Presence };
 
 export const Presences = Collection.extend({'model': Presence });

+ 12 - 9
src/headless/plugins/vcard/vcard.js

@@ -3,17 +3,20 @@ import { _converse } from "../../index.js";
 
 /**
  * Represents a VCard
- * @class
  * @namespace _converse.VCard
  * @memberOf _converse
  */
-const VCard = Model.extend({
-    idAttribute: 'jid',
+class VCard extends Model {
+    get idAttribute () { // eslint-disable-line class-methods-use-this
+        return 'jid';
+    }
 
-    defaults: {
-        'image': _converse.DEFAULT_IMAGE,
-        'image_type': _converse.DEFAULT_IMAGE_TYPE
-    },
+    defaults () { // eslint-disable-line class-methods-use-this
+        return {
+            'image': _converse.DEFAULT_IMAGE,
+            'image_type': _converse.DEFAULT_IMAGE_TYPE
+        }
+    }
 
     set (key, val, options) {
         // Override Model.prototype.set to make sure that the
@@ -32,11 +35,11 @@ const VCard = Model.extend({
         } else {
             return Model.prototype.set.apply(this, arguments);
         }
-    },
+    }
 
     getDisplayName () {
         return this.get('nickname') || this.get('fullname') || this.get('jid');
     }
-});
+}
 
 export default VCard;

+ 13 - 6
src/headless/shared/connection/feedback.js

@@ -2,14 +2,21 @@ import _converse from '../_converse';
 import { Model } from '@converse/skeletor/src/model.js';
 import { Strophe } from 'strophe.js';
 
-export default Model.extend({
-    defaults: {
-        'connection_status': Strophe.Status.DISCONNECTED,
-        'message': ''
-    },
+
+class Feedback extends Model {
+
+    defaults () { // eslint-disable-line class-methods-use-this
+        return {
+            'connection_status': Strophe.Status.DISCONNECTED,
+            'message': '',
+        }
+    }
 
     initialize () {
+        super.initialize();
         const { api } = _converse;
         this.on('change', () => api.trigger('connfeedback', _converse.connfeedback));
     }
-});
+}
+
+export default Feedback;

+ 6 - 6
src/plugins/controlbox/model.js

@@ -11,9 +11,9 @@ const { dayjs } = converse.env;
  * `view_mode` it's a left-aligned sidebar.
  * @mixin
  */
-const ControlBox = Model.extend({
+class ControlBox extends Model {
 
-    defaults () {
+    defaults () {  // eslint-disable-line class-methods-use-this
         return {
             'bookmarked': false,
             'box_id': 'controlbox',
@@ -24,7 +24,7 @@ const ControlBox = Model.extend({
             'type': _converse.CONTROLBOX_TYPE,
             'url': ''
         };
-    },
+    }
 
     validate (attrs) {
         if (attrs.type === _converse.CONTROLBOX_TYPE) {
@@ -34,7 +34,7 @@ const ControlBox = Model.extend({
             return;
         }
         return _converse.ChatBox.prototype.validate.call(this, attrs);
-    },
+    }
 
     maybeShow (force) {
         if (!force && this.get('id') === 'controlbox') {
@@ -42,11 +42,11 @@ const ControlBox = Model.extend({
             return this;
         }
         return _converse.ChatBox.prototype.maybeShow.call(this, force);
-    },
+    }
 
     onReconnection () {
         this.save('connected', true);
     }
-});
+}
 
 export default ControlBox;

+ 6 - 4
src/plugins/minimize/toggle.js

@@ -1,9 +1,11 @@
 import { Model } from '@converse/skeletor/src/model.js';
 
-const MinimizedChatsToggle = Model.extend({
-    defaults: {
-        'collapsed': false
+class MinimizedChatsToggle extends Model {
+    defaults () { // eslint-disable-line class-methods-use-this
+        return {
+            'collapsed': false
+        }
     }
-});
+}
 
 export default MinimizedChatsToggle;

+ 10 - 10
src/plugins/omemo/device.js

@@ -7,23 +7,23 @@ import { parseBundle } from './utils.js';
 
 const { Strophe, sizzle, $iq } = converse.env;
 
-
 /**
- * @class
  * @namespace _converse.Device
  * @memberOf _converse
  */
-const Device = Model.extend({
-    defaults: {
-        'trusted': UNDECIDED,
-        'active': true
-    },
+class Device extends Model {
+    defaults () { // eslint-disable-line class-methods-use-this
+        return {
+            'trusted': UNDECIDED,
+            'active': true
+        }
+    }
 
     getRandomPreKey () {
         // XXX: assumes that the bundle has already been fetched
         const bundle = this.get('bundle');
         return bundle.prekeys[getRandomInt(bundle.prekeys.length)];
-    },
+    }
 
     async fetchBundleFromServer () {
         const stanza = $iq({
@@ -49,7 +49,7 @@ const Device = Model.extend({
         const bundle = parseBundle(bundle_el);
         this.save('bundle', bundle);
         return bundle;
-    },
+    }
 
     /**
      * Fetch and save the bundle information associated with
@@ -63,6 +63,6 @@ const Device = Model.extend({
             return this.fetchBundleFromServer();
         }
     }
-});
+}
 
 export default Device;

+ 14 - 12
src/plugins/omemo/devicelist.js

@@ -7,25 +7,27 @@ import { restoreOMEMOSession } from './utils.js';
 const { Strophe, $build, $iq, sizzle } = converse.env;
 
 /**
- * @class
  * @namespace _converse.DeviceList
  * @memberOf _converse
  */
-const DeviceList = Model.extend({
-    idAttribute: 'jid',
+class DeviceList extends Model {
+    get idAttribute () { // eslint-disable-line class-methods-use-this
+        return 'jid';
+    }
 
     async initialize () {
+        super.initialize();
         this.initialized = getOpenPromise();
         await this.initDevices();
         this.initialized.resolve();
-    },
+    }
 
     initDevices () {
         this.devices = new _converse.Devices();
         const id = `converse.devicelist-${_converse.bare_jid}-${this.get('jid')}`;
         initStorage(this.devices, id);
         return this.fetchDevices();
-    },
+    }
 
     async onDevicesFound (collection) {
         if (collection.length === 0) {
@@ -45,7 +47,7 @@ const DeviceList = Model.extend({
                 this.publishCurrentDevice(ids);
             }
         }
-    },
+    }
 
     fetchDevices () {
         if (this._devices_promise === undefined) {
@@ -60,7 +62,7 @@ const DeviceList = Model.extend({
             });
         }
         return this._devices_promise;
-    },
+    }
 
     async getOwnDeviceId () {
         let device_id = _converse.omemo_store.get('device_id');
@@ -70,7 +72,7 @@ const DeviceList = Model.extend({
             device_id = _converse.omemo_store.get('device_id');
         }
         return device_id;
-    },
+    }
 
     async publishCurrentDevice (device_ids) {
         if (this.get('jid') !== _converse.bare_jid) {
@@ -87,7 +89,7 @@ const DeviceList = Model.extend({
         if (!device_ids.includes(await this.getOwnDeviceId())) {
             return this.publishDevices();
         }
-    },
+    }
 
     async fetchDevicesFromServer () {
         const stanza = $iq({
@@ -102,7 +104,7 @@ const DeviceList = Model.extend({
         const device_ids = sizzle(selector, iq).map(d => d.getAttribute('id'));
         const jid = this.get('jid');
         return Promise.all(device_ids.map(id => this.devices.create({ id, jid }, { 'promise': true })));
-    },
+    }
 
     /**
      * Send an IQ stanza to the current user's "devices" PEP node to
@@ -114,7 +116,7 @@ const DeviceList = Model.extend({
         this.devices.filter(d => d.get('active')).forEach(d => item.c('device', { 'id': d.get('id') }).up());
         const options = { 'pubsub#access_model': 'open' };
         return api.pubsub.publish(null, Strophe.NS.OMEMO_DEVICELIST, item, options, false);
-    },
+    }
 
     async removeOwnDevices (device_ids) {
         if (this.get('jid') !== _converse.bare_jid) {
@@ -128,6 +130,6 @@ const DeviceList = Model.extend({
         ));
         return this.publishDevices();
     }
-});
+}
 
 export default DeviceList;

+ 22 - 26
src/plugins/omemo/store.js

@@ -10,11 +10,7 @@ import { _converse, api, converse, log } from '@converse/headless';
 const { Strophe, $build, u } = converse.env;
 
 
-const OMEMOStore = Model.extend({
-    Direction: {
-        SENDING: 1,
-        RECEIVING: 2
-    },
+class OMEMOStore extends Model {
 
     getIdentityKeyPair () {
         const keypair = this.get('identity_keypair');
@@ -22,11 +18,11 @@ const OMEMOStore = Model.extend({
             'privKey': u.base64ToArrayBuffer(keypair.privKey),
             'pubKey': u.base64ToArrayBuffer(keypair.pubKey)
         });
-    },
+    }
 
     getLocalRegistrationId () {
         return Promise.resolve(parseInt(this.get('device_id'), 10));
-    },
+    }
 
     isTrustedIdentity (identifier, identity_key, direction) { // eslint-disable-line no-unused-vars
         if (identifier === null || identifier === undefined) {
@@ -40,14 +36,14 @@ const OMEMOStore = Model.extend({
             return Promise.resolve(true);
         }
         return Promise.resolve(u.arrayBufferToBase64(identity_key) === trusted);
-    },
+    }
 
     loadIdentityKey (identifier) {
         if (identifier === null || identifier === undefined) {
             throw new Error("Can't load identity_key for invalid identifier");
         }
         return Promise.resolve(u.base64ToArrayBuffer(this.get('identity_key' + identifier)));
-    },
+    }
 
     saveIdentity (identifier, identity_key) {
         if (identifier === null || identifier === undefined) {
@@ -63,11 +59,11 @@ const OMEMOStore = Model.extend({
         } else {
             return Promise.resolve(false);
         }
-    },
+    }
 
     getPreKeys () {
         return this.get('prekeys') || {};
-    },
+    }
 
     loadPreKey (key_id) {
         const res = this.getPreKeys()[key_id];
@@ -78,7 +74,7 @@ const OMEMOStore = Model.extend({
             });
         }
         return Promise.resolve();
-    },
+    }
 
     storePreKey (key_id, key_pair) {
         const prekey = {};
@@ -88,12 +84,12 @@ const OMEMOStore = Model.extend({
         };
         this.save('prekeys', Object.assign(this.getPreKeys(), prekey));
         return Promise.resolve();
-    },
+    }
 
     removePreKey (key_id) {
         this.save('prekeys', omit(this.getPreKeys(), key_id));
         return Promise.resolve();
-    },
+    }
 
     loadSignedPreKey (keyId) { // eslint-disable-line no-unused-vars
         const res = this.get('signed_prekey');
@@ -104,7 +100,7 @@ const OMEMOStore = Model.extend({
             });
         }
         return Promise.resolve();
-    },
+    }
 
     storeSignedPreKey (spk) {
         if (typeof spk !== 'object') {
@@ -126,7 +122,7 @@ const OMEMOStore = Model.extend({
             'signature': u.arrayBufferToBase64(spk.signature)
         });
         return Promise.resolve();
-    },
+    }
 
     removeSignedPreKey (key_id) {
         if (this.get('signed_prekey')['id'] === key_id) {
@@ -134,19 +130,19 @@ const OMEMOStore = Model.extend({
             this.save();
         }
         return Promise.resolve();
-    },
+    }
 
     loadSession (identifier) {
         return Promise.resolve(this.get('session' + identifier));
-    },
+    }
 
     storeSession (identifier, record) {
         return Promise.resolve(this.save('session' + identifier, record));
-    },
+    }
 
     removeSession (identifier) {
         return Promise.resolve(this.unset('session' + identifier));
-    },
+    }
 
     removeAllSessions (identifier) {
         const keys = Object.keys(this.attributes).filter(key =>
@@ -156,7 +152,7 @@ const OMEMOStore = Model.extend({
         keys.forEach(key => { attrs[key] = undefined; });
         this.save(attrs);
         return Promise.resolve();
-    },
+    }
 
     publishBundle () {
         const signed_prekey = this.get('signed_prekey');
@@ -179,7 +175,7 @@ const OMEMOStore = Model.extend({
         );
         const options = { 'pubsub#access_model': 'open' };
         return api.pubsub.publish(null, node, item, options, false);
-    },
+    }
 
     async generateMissingPreKeys () {
         const missing_keys = difference(
@@ -202,7 +198,7 @@ const OMEMOStore = Model.extend({
         const device = devicelist.devices.get(this.get('device_id'));
         const bundle = await device.getBundle();
         device.save('bundle', Object.assign(bundle, { 'prekeys': marshalled_keys }));
-    },
+    }
 
     /**
      * Generates, stores and then returns pre-keys.
@@ -227,7 +223,7 @@ const OMEMOStore = Model.extend({
             'id': k.keyId,
             'key': u.arrayBufferToBase64(k.keyPair.pubKey)
         }));
-    },
+    }
 
     /**
      * Generate the cryptographic data used by the X3DH key agreement protocol
@@ -276,7 +272,7 @@ const OMEMOStore = Model.extend({
             { 'promise': true }
         );
         device.save('bundle', bundle);
-    },
+    }
 
     fetchSession () {
         if (this._setup_promise === undefined) {
@@ -299,6 +295,6 @@ const OMEMOStore = Model.extend({
         }
         return this._setup_promise;
     }
-});
+}
 
 export default OMEMOStore;

+ 6 - 5
src/plugins/roomslist/model.js

@@ -3,25 +3,26 @@ import { _converse, api, converse } from "@converse/headless";
 
 const { Strophe } = converse.env;
 
-const RoomsListModel = Model.extend({
+class RoomsListModel extends Model {
 
-    defaults: function () {
+    defaults () {  // eslint-disable-line class-methods-use-this
         return {
             'muc_domain': api.settings.get('muc_domain'),
             'nick': _converse.getDefaultMUCNickname(),
             'toggle_state':  _converse.OPENED,
         };
-    },
+    }
 
     initialize () {
+        super.initialize();
         api.settings.listen.on('change:muc_domain', (muc_domain) => this.setDomain(muc_domain));
-    },
+    }
 
     setDomain (jid) {
         if (!api.settings.get('locked_muc_domain')) {
             this.save('muc_domain', Strophe.getDomainFromJid(jid));
         }
     }
-});
+}
 
 export default RoomsListModel;