Commit a3830e9a authored by JC Brand's avatar JC Brand

Use async/await

parent 6f10f95d
...@@ -57078,23 +57078,24 @@ _converse_headless_converse_core__WEBPACK_IMPORTED_MODULE_0__["default"].plugins ...@@ -57078,23 +57078,24 @@ _converse_headless_converse_core__WEBPACK_IMPORTED_MODULE_0__["default"].plugins
}); });
function fetchDeviceLists() { function fetchDeviceLists() {
return new Promise((resolve, reject) => _converse.devicelists.fetch({ return new Promise((success, error) => _converse.devicelists.fetch({
'success': resolve success,
error
})); }));
} }
function fetchOwnDevices() { async function fetchOwnDevices() {
return fetchDeviceLists().then(() => { await fetchDeviceLists();
let own_devicelist = _converse.devicelists.get(_converse.bare_jid);
if (_.isNil(own_devicelist)) { let own_devicelist = _converse.devicelists.get(_converse.bare_jid);
own_devicelist = _converse.devicelists.create({
'jid': _converse.bare_jid
});
}
return own_devicelist.fetchDevices(); if (_.isNil(own_devicelist)) {
}); own_devicelist = _converse.devicelists.create({
'jid': _converse.bare_jid
});
}
return own_devicelist.fetchDevices();
} }
function updateBundleFromStanza(stanza) { function updateBundleFromStanza(stanza) {
...@@ -57191,7 +57192,7 @@ _converse_headless_converse_core__WEBPACK_IMPORTED_MODULE_0__["default"].plugins ...@@ -57191,7 +57192,7 @@ _converse_headless_converse_core__WEBPACK_IMPORTED_MODULE_0__["default"].plugins
return _converse.omemo_store.fetchSession(); return _converse.omemo_store.fetchSession();
} }
function initOMEMO() { async function initOMEMO() {
if (!_converse.config.get('trusted')) { if (!_converse.config.get('trusted')) {
return; return;
} }
...@@ -57202,7 +57203,11 @@ _converse_headless_converse_core__WEBPACK_IMPORTED_MODULE_0__["default"].plugins ...@@ -57202,7 +57203,11 @@ _converse_headless_converse_core__WEBPACK_IMPORTED_MODULE_0__["default"].plugins
id = `converse.devicelists-${_converse.bare_jid}`; id = `converse.devicelists-${_converse.bare_jid}`;
_converse.devicelists.browserStorage = new Backbone.BrowserStorage[storage](id); _converse.devicelists.browserStorage = new Backbone.BrowserStorage[storage](id);
fetchOwnDevices().then(() => restoreOMEMOSession()).then(() => _converse.omemo_store.publishBundle()).then(() => _converse.emit('OMEMOInitialized')).catch(_.partial(_converse.log, _, Strophe.LogLevel.ERROR)); await fetchOwnDevices();
await restoreOMEMOSession();
await _converse.omemo_store.publishBundle();
_converse.emit('OMEMOInitialized');
} }
async function onOccupantAdded(chatroom, occupant) { async function onOccupantAdded(chatroom, occupant) {
...@@ -1028,19 +1028,16 @@ converse.plugins.add('converse-omemo', { ...@@ -1028,19 +1028,16 @@ converse.plugins.add('converse-omemo', {
function fetchDeviceLists () { function fetchDeviceLists () {
return new Promise((resolve, reject) => _converse.devicelists.fetch({ return new Promise((success, error) => _converse.devicelists.fetch({success, error}));
'success': resolve
}));
} }
function fetchOwnDevices () { async function fetchOwnDevices () {
return fetchDeviceLists().then(() => { await fetchDeviceLists();
let own_devicelist = _converse.devicelists.get(_converse.bare_jid); let own_devicelist = _converse.devicelists.get(_converse.bare_jid);
if (_.isNil(own_devicelist)) { if (_.isNil(own_devicelist)) {
own_devicelist = _converse.devicelists.create({'jid': _converse.bare_jid}); own_devicelist = _converse.devicelists.create({'jid': _converse.bare_jid});
} }
return own_devicelist.fetchDevices(); return own_devicelist.fetchDevices();
});
} }
function updateBundleFromStanza (stanza) { function updateBundleFromStanza (stanza) {
...@@ -1115,7 +1112,7 @@ converse.plugins.add('converse-omemo', { ...@@ -1115,7 +1112,7 @@ converse.plugins.add('converse-omemo', {
return _converse.omemo_store.fetchSession(); return _converse.omemo_store.fetchSession();
} }
function initOMEMO () { async function initOMEMO () {
if (!_converse.config.get('trusted')) { if (!_converse.config.get('trusted')) {
return; return;
} }
...@@ -1124,11 +1121,10 @@ converse.plugins.add('converse-omemo', { ...@@ -1124,11 +1121,10 @@ converse.plugins.add('converse-omemo', {
id = `converse.devicelists-${_converse.bare_jid}`; id = `converse.devicelists-${_converse.bare_jid}`;
_converse.devicelists.browserStorage = new Backbone.BrowserStorage[storage](id); _converse.devicelists.browserStorage = new Backbone.BrowserStorage[storage](id);
fetchOwnDevices() await fetchOwnDevices();
.then(() => restoreOMEMOSession()) await restoreOMEMOSession();
.then(() => _converse.omemo_store.publishBundle()) await _converse.omemo_store.publishBundle();
.then(() => _converse.emit('OMEMOInitialized')) _converse.emit('OMEMOInitialized');
.catch(_.partial(_converse.log, _, Strophe.LogLevel.ERROR));
} }
async function onOccupantAdded (chatroom, occupant) { async function onOccupantAdded (chatroom, occupant) {
......
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