diff options
author | Maximilian Krambach <[email protected]> | 2018-05-25 09:53:24 +0000 |
---|---|---|
committer | Maximilian Krambach <[email protected]> | 2018-05-25 09:53:24 +0000 |
commit | eff27d6387b1cad2ef9901fa03dbee2ea86c786a (patch) | |
tree | aebdc295b1cd60152fbcfe55f8b7ce69916e40e1 /lang/js/src/index.js | |
parent | js: adding sign method (diff) | |
download | gpgme-eff27d6387b1cad2ef9901fa03dbee2ea86c786a.tar.gz gpgme-eff27d6387b1cad2ef9901fa03dbee2ea86c786a.zip |
js: use version operation for connection checks
--
* src/Connection.js: isConnected was renamed to checkConnection, that
returns a promise with either version information or Boolean
* Connection checks have been adapted to reflect that checkConnection
returns a Promise
* BrowsertestExtension: tests/signTest.js was missing from my last
commit
Diffstat (limited to 'lang/js/src/index.js')
-rw-r--r-- | lang/js/src/index.js | 22 |
1 files changed, 9 insertions, 13 deletions
diff --git a/lang/js/src/index.js b/lang/js/src/index.js index 8527b3f3..7f969fee 100644 --- a/lang/js/src/index.js +++ b/lang/js/src/index.js @@ -34,20 +34,16 @@ function init(config){ } return new Promise(function(resolve, reject){ let connection = new Connection; - // TODO: Delayed reaction is ugly. We need to listen to the port's - // event listener in isConnected, but in some cases this takes some - // time (<5ms) to disconnect if there is no successfull connection. - let delayedreaction = function(){ - if (connection === undefined) { + connection.checkConnection(false).then( + function(result){ + if (result === true) { + resolve(new GpgME(connection, _conf)); + } else { + reject(gpgme_error('CONN_NO_CONNECT')); + } + }, function(error){ reject(gpgme_error('CONN_NO_CONNECT')); - } - if (connection.isConnected === true){ - resolve(new GpgME(connection, _conf)); - } else { - reject(gpgme_error('CONN_NO_CONNECT')); - } - }; - setTimeout(delayedreaction, 5); + }); }); } |