Fetch devices upon devicelist creation

updates #497
This commit is contained in:
JC Brand 2018-05-12 12:39:28 +02:00
parent 0c50808b65
commit 2f149a0ea2

View File

@ -138,10 +138,12 @@
this.devices.browserStorage = new Backbone.BrowserStorage.session( this.devices.browserStorage = new Backbone.BrowserStorage.session(
b64_sha1(`converse.devicelist-${_converse.bare_jid}-${this.get('jid')}`) b64_sha1(`converse.devicelist-${_converse.bare_jid}-${this.get('jid')}`)
); );
this.fetchDevices();
}, },
fetchDevices () { fetchDevices () {
return new Promise((resolve, reject) => { if (_.isUndefined(this._devices_promise)) {
this._devices_promise = new Promise((resolve, reject) => {
this.devices.fetch({ this.devices.fetch({
'success': (collection) => { 'success': (collection) => {
if (collection.length === 0) { if (collection.length === 0) {
@ -152,6 +154,8 @@
} }
}); });
}); });
}
return this._devices_promise;
}, },
fetchDevicesFromServer () { fetchDevicesFromServer () {