diff --git a/www/js/services/wallet-services.js b/www/js/services/wallet-services.js index c32a81ca03f1ee6bf3925f05d469ef9ddb8f0ec0..5762f3ce98367c132ce26faccc3567f4d765d021 100644 --- a/www/js/services/wallet-services.js +++ b/www/js/services/wallet-services.js @@ -808,31 +808,26 @@ angular.module('cesium.wallet.services', ['ngApi', 'ngFileSaver', 'cesium.bma.se }, loadSigStock = function() { - return $q(function(resolve, reject) { - // Get certified by, then count written certification - BMA.wot.certifiedBy({pubkey: data.pubkey}) - .then(function(res){ - data.sigStock = !res.certifications ? 0 : res.certifications.reduce(function(res, cert) { - return cert.written === null ? res : res+1; - }, 0); - resolve(); - }) - .catch(function(err) { - if (!!err && err.ucode == BMA.errorCodes.NO_MATCHING_MEMBER) { - data.sigStock = 0; - resolve(); // not found - } - /*FIXME: workaround for Duniter issue #1309 */ - else if (!!err && err.ucode == 1002) { - console.warn("[wallet-service] Detecting Duniter issue #1309 ! Applying workaround... "); - data.sigStock = 0; - resolve(); // not found - } - else { - reject(err); - } - }); - }); + // Get certified by, then count written certification + return BMA.wot.certifiedBy({pubkey: data.pubkey}) + .then(function(res){ + data.sigStock = !res.certifications ? 0 : res.certifications.reduce(function(res, cert) { + return cert.written === null ? res : res+1; + }, 0); + }) + .catch(function(err) { + if (!!err && err.ucode == BMA.errorCodes.NO_MATCHING_MEMBER) { + data.sigStock = 0; + } + /*FIXME: workaround for Duniter issue #1309 */ + else if (!!err && err.ucode == 1002) { + console.warn("[wallet-service] Detecting Duniter issue #1309 ! Applying workaround... "); + data.sigStock = 0; + } + else { + throw err; + } + }); }, loadData = function(options) { diff --git a/www/js/services/wot-services.js b/www/js/services/wot-services.js index 50224409a2cf21a063c8557675496da804a4b73d..1a286334cbd577b42371d40f2878f7b59b4567f2 100644 --- a/www/js/services/wot-services.js +++ b/www/js/services/wot-services.js @@ -454,7 +454,7 @@ angular.module('cesium.wot.services', ['ngApi', 'cesium.bma.services', 'cesium.c return getFunction({ pubkey: pubkey }) .then(function(res) { - return res.certifications.reduce(function (res, cert) { + return (res && res.certifications || []).reduce(function (res, cert) { // Rappel : // cert.sigDate = blockstamp de l'identité // cert.cert_time.block : block au moment de la certification @@ -863,15 +863,13 @@ angular.module('cesium.wot.services', ['ngApi', 'cesium.bma.services', 'cesium.c return $q.all([ csCurrency.blockchain.current(true) .then(function(block) { - total = block.membersCount; + total = block.membersCount || 0; }), BMA.blockchain.stats.newcomers() ]) .then(function(res) { res = res[1]; - if (!res.result.blocks || !res.result.blocks.length) { - return null; - } + if (!res || !res.result || !res.result.blocks || !res.result.blocks.length) return null; // no result var blocks = _.sortBy(res.result.blocks, function (n) { return -n; }); @@ -886,13 +884,12 @@ angular.module('cesium.wot.services', ['ngApi', 'cesium.bma.services', 'cesium.c // Extension point return extendAll(idties, 'pubkey', true/*skipAddUid*/); }) - .then(function(idties) { - return { - hits: idties, - total: total - }; - }) - ; + .then(function(idties) { + return { + hits: idties, + total: total + }; + }); },