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
a3830e9a
Commit
a3830e9a
authored
Dec 21, 2018
by
JC Brand
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use async/await
parent
6f10f95d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
32 additions
and
31 deletions
+32
-31
dist/converse.js
dist/converse.js
+19
-14
src/converse-omemo.js
src/converse-omemo.js
+13
-17
No files found.
dist/converse.js
View file @
a3830e9a
...
@@ -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) {
src/converse-omemo.js
View file @
a3830e9a
...
@@ -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
)
{
...
...
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