From 3b13a2c80cc50da4ce662bc2376d40185b65947e Mon Sep 17 00:00:00 2001 From: Richard Ramos Date: Wed, 25 Apr 2018 20:11:15 -0400 Subject: [PATCH] Added whisper status indicator --- templates/demo/app/dapp.js | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/templates/demo/app/dapp.js b/templates/demo/app/dapp.js index de6b4084f..fdc43687f 100644 --- a/templates/demo/app/dapp.js +++ b/templates/demo/app/dapp.js @@ -21,10 +21,30 @@ class App extends React.Component { } componentDidMount(){ - // TODO Verify if whisper & swarm/ipfs are available + let _this = this; + + setTimeout(() => { + if (EmbarkJS.isNewWeb3()) { + EmbarkJS.Messages.Providers.whisper.getWhisperVersion(function(err, version){ + if(!err) + _this.setState({whisperEnabled: true}) + else + console.log(err); + }); + } else { + if (EmbarkJS.Messages.providerName === 'whisper') { + EmbarkJS.Messages.getWhisperVersion(function(err, version) { + if(!err) + _this.setState({whisperEnabled: true}) + else + console.log(err); + }); + } + } + }, 500); + this.setState({ - whisperEnabled: false, - storageEnabled: false + storageEnabled: true }); }