diff --git a/public/views/tab-home.html b/public/views/tab-home.html index ada43e865..d07ec38f5 100644 --- a/public/views/tab-home.html +++ b/public/views/tab-home.html @@ -9,17 +9,19 @@
  • - + {{item.name || item.id}} - - [ {{item.m}}-of-{{item.n}} ] + + {{item.m}}-of-{{item.n}} - + + + Incomplete + + {{item.availableBalanceStr}} - -
  • diff --git a/public/views/tab-receive.html b/public/views/tab-receive.html index a7dc9a38e..7877b0ce3 100644 --- a/public/views/tab-receive.html +++ b/public/views/tab-receive.html @@ -1,25 +1,53 @@ Receive -
    - -
    -
    - -
    + +
    + +
    + +
    +
    +
    -
    - - Share address + +
    +
    +incomplete wallet +
    + +
    + +
    +
    + +
    +
    + +
    -
    - - Next Address + +
    +
    +Error: {{addrError}} +
    -
    - - {{generatingAddress ? '...' : addr}} + + +
    +
    + + Share address +
    +
    + + Next Address +
    +
    + + {{generatingAddress ? '...' : addr}} +
    @@ -27,11 +55,15 @@
    • - + {{item.name || item.id}} - + {{item.m}}-of-{{item.n}} + + Incomplete + +
    diff --git a/src/js/controllers/tab-receive.js b/src/js/controllers/tab-receive.js index 87c146516..50c80bcbd 100644 --- a/src/js/controllers/tab-receive.js +++ b/src/js/controllers/tab-receive.js @@ -1,6 +1,8 @@ 'use strict'; -angular.module('copayApp.controllers').controller('tabReceiveController', function($scope, $ionicPopover, $timeout, platformInfo, nodeWebkit, addressService, profileService, configService, lodash) { +angular.module('copayApp.controllers').controller('tabReceiveController', function($scope, $ionicPopover, $timeout, platformInfo, nodeWebkit, walletService, profileService, configService, lodash, gettextCatalog) { + + $scope.isCordova = platformInfo.isCordova; $scope.init = function() { $scope.index = 0; @@ -26,7 +28,7 @@ angular.module('copayApp.controllers').controller('tabReceiveController', functi $scope.$on("$ionicSlides.slideChangeEnd", function(event, data) { $scope.index = data.slider.activeIndex; - $scope.setAddress(false); + $scope.setAddress(); }); } @@ -70,10 +72,24 @@ angular.module('copayApp.controllers').controller('tabReceiveController', functi }; $scope.setAddress = function(forceNew) { + if ($scope.generatingAddress) return; + + $scope.addr = null; $scope.addrError = null; + + var wallet = $scope.wallets[$scope.index]; + if (!wallet.isComplete()) { + $scope.incomplete = true; + $timeout(function() { + $scope.$digest(); + }); + return; + } + + $scope.incomplete = false; $scope.generatingAddress = true; $timeout(function() { - addressService.getAddress($scope.wallets[$scope.index].id, forceNew, function(err, addr) { + walletService.getAddress($scope.wallets[$scope.index], forceNew, function(err, addr) { $scope.generatingAddress = false; if (err) { $scope.addrError = err; @@ -88,25 +104,7 @@ angular.module('copayApp.controllers').controller('tabReceiveController', functi $scope.setWallets = function() { - if (!profileService.profile) return; - - var config = configService.getSync(); - config.colorFor = config.colorFor || {}; - config.aliasFor = config.aliasFor || {}; - - // Sanitize empty wallets (fixed in BWC 1.8.1, and auto fixed when wallets completes) - var credentials = lodash.filter(profileService.profile.credentials, 'walletName'); - var ret = lodash.map(credentials, function(c) { - return { - m: c.m, - n: c.n, - name: config.aliasFor[c.walletId] || c.walletName, - id: c.walletId, - color: config.colorFor[c.walletId] || '#4A90E2', - }; - }); - - $scope.wallets = lodash.sortBy(ret, 'name'); + $scope.wallets = profileService.getWallets(); }; }); diff --git a/src/js/services/profileService.js b/src/js/services/profileService.js index 490a69af5..42325e62a 100644 --- a/src/js/services/profileService.js +++ b/src/js/services/profileService.js @@ -82,8 +82,10 @@ angular.module('copayApp.services') c.name = config.aliasFor[walletId] || client.credentials.walletName; c.color = config.colorFor[walletId] || '#4A90E2'; c.network = client.credentials.network; - root.setCustomBWSFlag(c); + c.m = client.credentials.m; + c.n = client.credentials.n; + root.setCustomBWSFlag(c); root.wallet[walletId] = c; client.removeAllListeners(); @@ -713,18 +715,30 @@ angular.module('copayApp.services') storageService.storeProfile(root.profile, cb); }; - root.getWallets = function(network, n) { + root.getWallets = function(opts) { + + if (opts && !lodash.isObject(opts)) + throw "bad argument"; + + opts = opts || {}; + var ret = lodash.values(root.wallet); - if (network) { + if (opts.network) { ret = lodash.filter(ret, function(x) { - return (x.credentials.network == network); + return (x.credentials.network == opts.network); }); } - if (n) { + if (opts.n) { ret = lodash.filter(ret, function(w) { - return (w.credentials.n == n); + return (w.credentials.n == opts.n); + }); + } + + if (opts.onlyComplete) { + ret = lodash.filter(ret, function(w) { + return w.isComplete(); }); } diff --git a/src/js/services/walletService.js b/src/js/services/walletService.js index 915130e41..735593c32 100644 --- a/src/js/services/walletService.js +++ b/src/js/services/walletService.js @@ -1,7 +1,7 @@ 'use strict'; // DO NOT INCLUDE STORAGE HERE \/ \/ -angular.module('copayApp.services').factory('walletService', function($log, $timeout, lodash, trezor, ledger, storageService, configService, rateService, uxLanguage, bwcService, $filter) { +angular.module('copayApp.services').factory('walletService', function($log, $timeout, lodash, trezor, ledger, storageService, configService, rateService, uxLanguage, bwcService, $filter, gettextCatalog, bwcError) { // DO NOT INCLUDE STORAGE HERE ^^ // // @@ -755,7 +755,7 @@ angular.module('copayApp.services').factory('walletService', function($log, $tim }); }; - root._createAddress = function(wallet, cb) { + var createAddress = function(wallet, cb) { $log.debug('Creating address for wallet:', wallet.id); wallet.createAddress({}, function(err, addr) { @@ -764,7 +764,7 @@ angular.module('copayApp.services').factory('walletService', function($log, $tim if (err.error && err.error.match(/locked/gi)) { $log.debug(err.error); return $timeout(function() { - root._createAddress(walletId, cb); + createAddress(wallet, cb); }, 5000); } else if (err.message && err.message == 'MAIN_ADDRESS_GAP_REACHED') { $log.warn(err.message); @@ -784,6 +784,7 @@ angular.module('copayApp.services').factory('walletService', function($log, $tim }; root.getAddress = function(wallet, forceNew, cb) { +console.log('[walletService.js.786:wallet:]',wallet, forceNew); //TODO var firstStep; if (forceNew) { @@ -802,7 +803,7 @@ angular.module('copayApp.services').factory('walletService', function($log, $tim if (addr) return cb(null, addr); - root._createAddress(wallet, function(err, addr) { + createAddress(wallet, function(err, addr) { if (err) return cb(err); storageService.storeLastAddress(wallet.id, addr, function() { if (err) return cb(err);