From 39b9d6e1d863e6a8d0994ae8af55c62dac6d2731 Mon Sep 17 00:00:00 2001 From: Anthony Laibe Date: Thu, 23 Aug 2018 09:59:02 +0100 Subject: [PATCH] PR feedback --- lib/modules/ipfs/embarkjs.js | 18 +++++++++--------- lib/modules/swarm/embarkjs.js | 8 ++++---- templates/demo/app/components/storage.js | 2 ++ 3 files changed, 15 insertions(+), 13 deletions(-) diff --git a/lib/modules/ipfs/embarkjs.js b/lib/modules/ipfs/embarkjs.js index bf81a6f5..105739d4 100644 --- a/lib/modules/ipfs/embarkjs.js +++ b/lib/modules/ipfs/embarkjs.js @@ -53,14 +53,14 @@ __embarkIPFS.saveText = function (text) { var promise = new Promise(function (resolve, reject) { if (!self._ipfsConnection) { var connectionError = new Error(NoConnectionError); - reject(connectionError); + return reject(connectionError); } self._ipfsConnection.add(self._ipfsConnection.Buffer.from(text), function (err, result) { if (err) { - reject(err); - } else { - resolve(result[0].path); + return reject(err); } + + resolve(result[0].path); }); }); @@ -74,7 +74,7 @@ __embarkIPFS.get = function (hash) { var promise = new Promise(function (resolve, reject) { if (!self._ipfsConnection) { var connectionError = new Error(NoConnectionError); - reject(connectionError); + return reject(connectionError); } self._ipfsConnection.get(hash, function (err, files) { if (err) { @@ -98,7 +98,7 @@ __embarkIPFS.uploadFile = function (inputSelector) { var promise = new Promise(function (resolve, reject) { if (!self._ipfsConnection) { var connectionError = new Error(NoConnectionError); - reject(connectionError); + return reject(connectionError); } var reader = new FileReader(); reader.onloadend = function () { @@ -106,10 +106,10 @@ __embarkIPFS.uploadFile = function (inputSelector) { var buffer = self._ipfsConnection.Buffer.from(fileContent); self._ipfsConnection.add(buffer, function (err, result) { if (err) { - reject(err); - } else { - resolve(result[0].path); + return reject(err); } + + resolve(result[0].path); }); }; reader.readAsArrayBuffer(file); diff --git a/lib/modules/swarm/embarkjs.js b/lib/modules/swarm/embarkjs.js index 333c42be..fdce4c80 100644 --- a/lib/modules/swarm/embarkjs.js +++ b/lib/modules/swarm/embarkjs.js @@ -105,10 +105,10 @@ __embarkSwarm.getUrl = function (hash) { const NotAvailable = "Not available with Swarm"; -__embarkSwarm.resolve = function () { - return new Error(NotAvailable); +__embarkSwarm.resolve = function (_name, callback) { + callback(NotAvailable); }; -__embarkSwarm.register = function () { - return new Error(NotAvailable); +__embarkSwarm.register = function (_addr, callback) { + callback(NotAvailable); }; diff --git a/templates/demo/app/components/storage.js b/templates/demo/app/components/storage.js index 5c7540af..7c527009 100644 --- a/templates/demo/app/components/storage.js +++ b/templates/demo/app/components/storage.js @@ -215,6 +215,8 @@ class Storage extends React.Component { + The 2 functions below are only available with IPFS +

Register to IPNS

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