From bf06163d30399abd1eb763100209f40a425c0862 Mon Sep 17 00:00:00 2001 From: Jonathan Rainville Date: Wed, 15 Aug 2018 13:12:52 -0400 Subject: [PATCH] enter submit for storage --- templates/demo/app/components/blockchain.js | 2 +- templates/demo/app/components/storage.js | 18 +++++++++++++----- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/templates/demo/app/components/blockchain.js b/templates/demo/app/components/blockchain.js index 4dd177f0..3b5ec984 100644 --- a/templates/demo/app/components/blockchain.js +++ b/templates/demo/app/components/blockchain.js @@ -47,7 +47,7 @@ class Blockchain extends React.Component { if (EmbarkJS.isNewWeb3()) { SimpleStorage.methods.get().call() - .then(_value => this.setState({ valueGet: _value })) + .then(_value => this.setState({ valueGet: _value })); this._addToLog("SimpleStorage.methods.get(console.log)"); } else { SimpleStorage.get() diff --git a/templates/demo/app/components/storage.js b/templates/demo/app/components/storage.js index a3295a38..1d153294 100644 --- a/templates/demo/app/components/storage.js +++ b/templates/demo/app/components/storage.js @@ -28,6 +28,14 @@ class Storage extends React.Component { this.setState(this.state); } + checkEnter(e, func) { + if (e.key !== 'Enter') { + return; + } + e.preventDefault(); + func.apply(this, [e]); + } + handleFileUpload(e) { this.setState({fileToUpload: [e.target]}); } @@ -159,7 +167,7 @@ class Storage extends React.Component { : '' }

Save text to storage

-
+ this.checkEnter(e, this.setText)}>

Load text from storage given an hash

- + this.checkEnter(e, this.loadHash)}>

Get file or image from storage

- + this.checkEnter(e, this.loadFile)}>

Register to IPNS

- + this.checkEnter(e, this.ipnsRegister)}>

Resolve name

- + this.checkEnter(e, this.ipnsResolve)}>