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
c32ecb7e
Commit
c32ecb7e
authored
Mar 30, 2019
by
JC Brand
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor `fetchDevices` to make it smaller and simpler to read
parent
1b08df89
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
21 deletions
+19
-21
src/converse-omemo.js
src/converse-omemo.js
+19
-21
No files found.
src/converse-omemo.js
View file @
c32ecb7e
...
...
@@ -950,29 +950,28 @@ converse.plugins.add('converse-omemo', {
this
.
fetchDevices
();
},
async
onDevicesFound
(
collection
)
{
if
(
collection
.
length
===
0
)
{
let
ids
;
try
{
ids
=
await
this
.
fetchDevicesFromServer
()
}
catch
(
e
)
{
_converse
.
log
(
`Could not fetch devices for
${
this
.
get
(
'
jid
'
)}
`
);
_converse
.
log
(
e
,
Strophe
.
LogLevel
.
ERROR
);
this
.
destroy
();
}
if
(
this
.
get
(
'
jid
'
)
===
_converse
.
bare_jid
)
{
await
this
.
publishCurrentDevice
(
ids
);
}
}
},
fetchDevices
()
{
if
(
_
.
isUndefined
(
this
.
_devices_promise
))
{
this
.
_devices_promise
=
new
Promise
(
resolve
=>
{
this
.
devices
.
fetch
({
'
success
'
:
async
collection
=>
{
if
(
collection
.
length
===
0
)
{
let
ids
;
try
{
ids
=
await
this
.
fetchDevicesFromServer
()
}
catch
(
e
)
{
_converse
.
log
(
`Could not fetch devices for
${
this
.
get
(
'
jid
'
)}
`
);
_converse
.
log
(
e
,
Strophe
.
LogLevel
.
ERROR
);
this
.
destroy
();
return
resolve
(
e
);
}
await
this
.
publishCurrentDevice
(
ids
);
}
resolve
();
},
'
error
'
:
e
=>
{
_converse
.
log
(
e
,
Strophe
.
LogLevel
.
ERROR
);
resolve
(
e
);
}
'
success
'
:
_
.
flow
(
c
=>
this
.
onDevicesFound
(
c
),
resolve
),
'
error
'
:
_
.
flow
(
_
.
partial
(
_converse
.
log
,
_
,
Strophe
.
LogLevel
.
ERROR
),
resolve
)
});
});
}
...
...
@@ -981,8 +980,7 @@ converse.plugins.add('converse-omemo', {
async
publishCurrentDevice
(
device_ids
)
{
if
(
this
.
get
(
'
jid
'
)
!==
_converse
.
bare_jid
)
{
// We only publish for ourselves.
return
return
// We only publish for ourselves.
}
await
restoreOMEMOSession
();
let
device_id
=
_converse
.
omemo_store
.
get
(
'
device_id
'
);
...
...
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