use tryAndWait()
This commit is contained in:
parent
438c5d09c7
commit
6c8c7c27ed
1 changed files with 9 additions and 3 deletions
|
|
@ -206,12 +206,18 @@ const recipientToOutgoingID = async recipientPub => {
|
||||||
* @returns {Promise<string|null>}
|
* @returns {Promise<string|null>}
|
||||||
*/
|
*/
|
||||||
const currHandshakeAddress = async userPub => {
|
const currHandshakeAddress = async userPub => {
|
||||||
const maybeAddr = await tryAndWait(gun =>
|
const maybeAddr = await tryAndWait(async gun => {
|
||||||
gun
|
const addr = await gun
|
||||||
.user(userPub)
|
.user(userPub)
|
||||||
.get(Key.CURRENT_HANDSHAKE_ADDRESS)
|
.get(Key.CURRENT_HANDSHAKE_ADDRESS)
|
||||||
.then()
|
.then()
|
||||||
)
|
|
||||||
|
if (typeof addr !== 'string' && addr !== null) {
|
||||||
|
throw new TypeError('Expected handshake address to be string or null')
|
||||||
|
}
|
||||||
|
|
||||||
|
return addr
|
||||||
|
})
|
||||||
|
|
||||||
return typeof maybeAddr === 'string' ? maybeAddr : null
|
return typeof maybeAddr === 'string' ? maybeAddr : null
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue