Use async/await
This commit is contained in:
parent
87c77385d8
commit
cc3735ff08
45
dist/converse.js
vendored
45
dist/converse.js
vendored
|
@ -64996,8 +64996,8 @@ _converse_headless_converse_core__WEBPACK_IMPORTED_MODULE_0__["default"].plugins
|
|||
chatstate_notification_blacklist: [],
|
||||
// ^ a list of JIDs to ignore concerning chat state notifications
|
||||
play_sounds: true,
|
||||
sounds_path: '/sounds/',
|
||||
notification_icon: '/logo/conversejs-filled.svg'
|
||||
sounds_path: 'sounds/',
|
||||
notification_icon: 'logo/conversejs-filled.svg'
|
||||
});
|
||||
|
||||
_converse.isOnlyChatStateNotification = msg => // See XEP-0085 Chat State Notification
|
||||
|
@ -77202,7 +77202,7 @@ _converse_headless_converse_core__WEBPACK_IMPORTED_MODULE_0__["default"].plugins
|
|||
}, Strophe.NS.ROSTERX, 'message', null);
|
||||
},
|
||||
|
||||
fetchRosterContacts() {
|
||||
async fetchRosterContacts() {
|
||||
/* Fetches the roster contacts, first by trying the
|
||||
* sessionStorage cache, and if that's empty, then by querying
|
||||
* the XMPP server.
|
||||
|
@ -77210,26 +77210,29 @@ _converse_headless_converse_core__WEBPACK_IMPORTED_MODULE_0__["default"].plugins
|
|||
* Returns a promise which resolves once the contacts have been
|
||||
* fetched.
|
||||
*/
|
||||
const that = this;
|
||||
return new Promise((resolve, reject) => {
|
||||
this.fetch({
|
||||
'add': true,
|
||||
'silent': true,
|
||||
|
||||
success(collection) {
|
||||
if (collection.length === 0 || that.rosterVersioningSupported() && !_converse.session.get('roster_fetched')) {
|
||||
_converse.send_initial_presence = true;
|
||||
|
||||
_converse.roster.fetchFromServer().then(resolve).catch(reject);
|
||||
} else {
|
||||
_converse.emit('cachedRoster', collection);
|
||||
|
||||
resolve();
|
||||
}
|
||||
}
|
||||
let collection;
|
||||
|
||||
try {
|
||||
collection = await new Promise((resolve, reject) => {
|
||||
const config = {
|
||||
'add': true,
|
||||
'silent': true,
|
||||
'success': resolve,
|
||||
'error': reject
|
||||
};
|
||||
this.fetch(config);
|
||||
});
|
||||
});
|
||||
} catch (e) {
|
||||
return _converse.log(e, Strophe.LogLevel.ERROR);
|
||||
}
|
||||
|
||||
if (collection.length === 0 || this.rosterVersioningSupported() && !_converse.session.get('roster_fetched')) {
|
||||
_converse.send_initial_presence = true;
|
||||
|
||||
_converse.roster.fetchFromServer();
|
||||
} else {
|
||||
_converse.emit('cachedRoster', collection);
|
||||
}
|
||||
},
|
||||
|
||||
subscribeToSuggestedItems(msg) {
|
||||
|
|
|
@ -390,7 +390,7 @@ converse.plugins.add('converse-roster', {
|
|||
);
|
||||
},
|
||||
|
||||
fetchRosterContacts () {
|
||||
async fetchRosterContacts () {
|
||||
/* Fetches the roster contacts, first by trying the
|
||||
* sessionStorage cache, and if that's empty, then by querying
|
||||
* the XMPP server.
|
||||
|
@ -398,23 +398,22 @@ converse.plugins.add('converse-roster', {
|
|||
* Returns a promise which resolves once the contacts have been
|
||||
* fetched.
|
||||
*/
|
||||
const that = this;
|
||||
return new Promise((resolve, reject) => {
|
||||
this.fetch({
|
||||
'add': true,
|
||||
'silent': true,
|
||||
success (collection) {
|
||||
if (collection.length === 0 ||
|
||||
(that.rosterVersioningSupported() && !_converse.session.get('roster_fetched'))) {
|
||||
_converse.send_initial_presence = true;
|
||||
_converse.roster.fetchFromServer().then(resolve).catch(reject);
|
||||
} else {
|
||||
_converse.emit('cachedRoster', collection);
|
||||
resolve();
|
||||
}
|
||||
}
|
||||
let collection;
|
||||
try {
|
||||
collection = await new Promise((resolve, reject) => {
|
||||
const config = {'add': true, 'silent': true, 'success': resolve, 'error': reject};
|
||||
this.fetch(config);
|
||||
});
|
||||
});
|
||||
} catch (e) {
|
||||
return _converse.log(e, Strophe.LogLevel.ERROR);
|
||||
}
|
||||
if (collection.length === 0 ||
|
||||
(this.rosterVersioningSupported() && !_converse.session.get('roster_fetched'))) {
|
||||
_converse.send_initial_presence = true;
|
||||
_converse.roster.fetchFromServer();
|
||||
} else {
|
||||
_converse.emit('cachedRoster', collection);
|
||||
}
|
||||
},
|
||||
|
||||
subscribeToSuggestedItems (msg) {
|
||||
|
|
Loading…
Reference in New Issue
Block a user