Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
converse.js
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
converse.js
Commits
370c4c84
Commit
370c4c84
authored
Feb 13, 2019
by
JC Brand
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use async/await instead of explicit promises
parent
4c83a233
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
28 deletions
+12
-28
dist/converse.js
dist/converse.js
+7
-14
src/headless/converse-disco.js
src/headless/converse-disco.js
+5
-14
No files found.
dist/converse.js
View file @
370c4c84
...
@@ -64494,27 +64494,20 @@ _converse_core__WEBPACK_IMPORTED_MODULE_0__["default"].plugins.add('converse-dis
...
@@ -64494,27 +64494,20 @@ _converse_core__WEBPACK_IMPORTED_MODULE_0__["default"].plugins.add('converse-dis
});
});
},
},
hasFeature(feature) {
async
hasFeature(feature) {
/* Returns a Promise which resolves with a map indicating
/* Returns a Promise which resolves with a map indicating
* whether a given feature is supported.
* whether a given feature is supported.
*
*
* Parameters:
* Parameters:
* (String) feature - The feature that might be supported.
* (String) feature - The feature that might be supported.
*/
*/
const entity = this;
await this.waitUntilFeaturesDiscovered;
return new Promise((resolve, reject) => {
function fulfillPromise() {
if (entity.features.findWhere({
'var': feature
})) {
resolve(entity);
} else {
resolve();
}
}
entity.waitUntilFeaturesDiscovered.then(fulfillPromise).catch(_.partial(_converse.log, _, Strophe.LogLevel.FATAL));
if (this.features.findWhere({
});
'var': feature
})) {
return this;
}
},
},
onFeatureAdded(feature) {
onFeatureAdded(feature) {
src/headless/converse-disco.js
View file @
370c4c84
...
@@ -79,26 +79,17 @@ converse.plugins.add('converse-disco', {
...
@@ -79,26 +79,17 @@ converse.plugins.add('converse-disco', {
});
});
},
},
hasFeature
(
feature
)
{
async
hasFeature
(
feature
)
{
/* Returns a Promise which resolves with a map indicating
/* Returns a Promise which resolves with a map indicating
* whether a given feature is supported.
* whether a given feature is supported.
*
*
* Parameters:
* Parameters:
* (String) feature - The feature that might be supported.
* (String) feature - The feature that might be supported.
*/
*/
const
entity
=
this
;
await
this
.
waitUntilFeaturesDiscovered
return
new
Promise
((
resolve
,
reject
)
=>
{
if
(
this
.
features
.
findWhere
({
'
var
'
:
feature
}))
{
function
fulfillPromise
()
{
return
this
;
if
(
entity
.
features
.
findWhere
({
'
var
'
:
feature
}))
{
}
resolve
(
entity
);
}
else
{
resolve
();
}
}
entity
.
waitUntilFeaturesDiscovered
.
then
(
fulfillPromise
)
.
catch
(
_
.
partial
(
_converse
.
log
,
_
,
Strophe
.
LogLevel
.
FATAL
));
});
},
},
onFeatureAdded
(
feature
)
{
onFeatureAdded
(
feature
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment