From 92bb8e01bc93fc774d550e5a51bc67db0867f793 Mon Sep 17 00:00:00 2001 From: Gustavo Maximiliano Cortez Date: Thu, 1 Sep 2016 10:56:13 -0300 Subject: [PATCH] Uses popupService --- public/views/join.html | 4 -- public/views/modals/txp-details.html | 3 - public/views/tab-create-personal.html | 4 -- public/views/tab-create-shared.html | 4 -- public/views/tab-import-file.html | 4 -- public/views/tab-import-hardware.html | 4 -- public/views/tab-import-phrase.html | 24 +++----- public/views/tab-receive.html | 4 -- src/js/controllers/buyGlidera.js | 1 - src/js/controllers/copayers.js | 2 +- src/js/controllers/create.js | 18 +++--- src/js/controllers/export.js | 13 ++--- src/js/controllers/import.js | 73 ++++++++----------------- src/js/controllers/join.js | 18 +++--- src/js/controllers/modals/txpDetails.js | 20 ++----- src/js/controllers/preferencesBwsUrl.js | 1 - src/js/controllers/preferencesDelete.js | 5 +- src/js/controllers/tab-receive.js | 5 +- src/js/services/walletService.js | 21 +------ 19 files changed, 64 insertions(+), 164 deletions(-) diff --git a/public/views/join.html b/public/views/join.html index 7529baf11..fa4509e16 100644 --- a/public/views/join.html +++ b/public/views/join.html @@ -11,10 +11,6 @@ -
- {{join.error|translate}} -
-
diff --git a/public/views/modals/txp-details.html b/public/views/modals/txp-details.html index a8e26e216..fdc3ba9f2 100644 --- a/public/views/modals/txp-details.html +++ b/public/views/modals/txp-details.html @@ -25,9 +25,6 @@
  • -
    - {{error|translate}} -
    diff --git a/public/views/tab-create-personal.html b/public/views/tab-create-personal.html index 47044b542..c3a895c37 100644 --- a/public/views/tab-create-personal.html +++ b/public/views/tab-create-personal.html @@ -10,10 +10,6 @@ -
    - {{create.error|translate}} -
    -
    diff --git a/public/views/tab-create-shared.html b/public/views/tab-create-shared.html index 66043765e..b7471cc68 100644 --- a/public/views/tab-create-shared.html +++ b/public/views/tab-create-shared.html @@ -10,10 +10,6 @@ -
    - {{create.error|translate}} -
    -
    diff --git a/public/views/tab-import-file.html b/public/views/tab-import-file.html index f215ac6f2..0f24c12bf 100644 --- a/public/views/tab-import-file.html +++ b/public/views/tab-import-file.html @@ -10,10 +10,6 @@ -
    - {{error|translate}} -
    -
    diff --git a/public/views/tab-import-hardware.html b/public/views/tab-import-hardware.html index 6bef8121d..6f97a9259 100644 --- a/public/views/tab-import-hardware.html +++ b/public/views/tab-import-hardware.html @@ -10,10 +10,6 @@ -
    - {{error|translate}} -
    -
    diff --git a/public/views/tab-import-phrase.html b/public/views/tab-import-phrase.html index 0ec717ba8..077738b3e 100644 --- a/public/views/tab-import-phrase.html +++ b/public/views/tab-import-phrase.html @@ -10,21 +10,15 @@ -
    -
    -
    Could not access the wallet at the server. Please check:
    -
      -
    • The password of the recovery phrase (if set)
    • -
    • The derivation path
    • -
    • The wallet service URL
    • -
    -
    - NOTE: To import a wallet from a 3rd party software, please go to Add Wallet > Create Wallet, and specify the Recovery Phrase there. -
    -
    - -
    - {{error|translate}} +
    +
    Could not access the wallet at the server. Please check:
    +
      +
    • The password of the recovery phrase (if set)
    • +
    • The derivation path
    • +
    • The wallet service URL
    • +
    +
    + NOTE: To import a wallet from a 3rd party software, please go to Add Wallet > Create Wallet, and specify the Recovery Phrase there.
    diff --git a/public/views/tab-receive.html b/public/views/tab-receive.html index cedff3b8b..7f2119913 100644 --- a/public/views/tab-receive.html +++ b/public/views/tab-receive.html @@ -11,10 +11,6 @@
    -
    - {{error|translate}} -
    -
    No Wallet
    diff --git a/src/js/controllers/buyGlidera.js b/src/js/controllers/buyGlidera.js index 9da07038c..988fccb43 100644 --- a/src/js/controllers/buyGlidera.js +++ b/src/js/controllers/buyGlidera.js @@ -83,7 +83,6 @@ angular.module('copayApp.controllers').controller('buyGlideraController', this.getBuyPrice = function(token, price) { var self = this; - this.error = null; if (!price || (price && !price.qty && !price.fiat)) { this.buyPrice = null; return; diff --git a/src/js/controllers/copayers.js b/src/js/controllers/copayers.js index e9d4c662f..9e52e635a 100644 --- a/src/js/controllers/copayers.js +++ b/src/js/controllers/copayers.js @@ -45,7 +45,7 @@ angular.module('copayApp.controllers').controller('copayersController', profileService.deleteWalletClient(wallet, function(err) { ongoingProcess.set('deletingWallet', false); if (err) { - $scope.error = err.message || err; + popupService.showAlert(gettextCatalog.getString('Error'), err.message || err); } else { $state.transitionTo('tabs.home'); } diff --git a/src/js/controllers/create.js b/src/js/controllers/create.js index 1317959fa..1faf089f7 100644 --- a/src/js/controllers/create.js +++ b/src/js/controllers/create.js @@ -1,7 +1,7 @@ 'use strict'; angular.module('copayApp.controllers').controller('createController', - function($scope, $rootScope, $timeout, $log, lodash, $state, $ionicScrollDelegate, profileService, configService, gettext, ledger, trezor, platformInfo, derivationPathHelper, ongoingProcess, walletService, storageService) { + function($scope, $rootScope, $timeout, $log, lodash, $state, $ionicScrollDelegate, profileService, configService, gettext, gettextCatalog, ledger, trezor, platformInfo, derivationPathHelper, ongoingProcess, walletService, storageService, popupService) { var isChromeApp = platformInfo.isChromeApp; var isCordova = platformInfo.isCordova; @@ -92,7 +92,7 @@ angular.module('copayApp.controllers').controller('createController', this.create = function(form) { if (form && form.$invalid) { - this.error = gettext('Please enter the required fields'); + popupService.showAlert(gettextCatalog.getString('Error'), gettextCatalog.getString('Please enter the required fields')); return; } @@ -119,7 +119,7 @@ angular.module('copayApp.controllers').controller('createController', var pathData = derivationPathHelper.parse($scope.derivationPath); if (!pathData) { - this.error = gettext('Invalid derivation path'); + popupService.showAlert(gettextCatalog.getString('Error'), gettextCatalog.getString('Invalid derivation path')); return; } @@ -132,14 +132,14 @@ angular.module('copayApp.controllers').controller('createController', } if (setSeed && !opts.mnemonic && !opts.extendedPrivateKey) { - this.error = gettext('Please enter the wallet recovery phrase'); + popupService.showAlert(gettextCatalog.getString('Error'), gettextCatalog.getString('Please enter the wallet recovery phrase')); return; } if (self.seedSourceId == 'ledger' || self.seedSourceId == 'trezor') { var account = $scope.account; if (!account || account < 1) { - this.error = gettext('Invalid account number'); + popupService.showAlert(gettextCatalog.getString('Error'), gettextCatalog.getString('Invalid account number')); return; } @@ -154,8 +154,7 @@ angular.module('copayApp.controllers').controller('createController', src.getInfoForNewWallet(opts.n > 1, account, function(err, lopts) { ongoingProcess.set('connecting' + self.seedSourceId, false); if (err) { - self.error = err; - $scope.$apply(); + popupService.showAlert(gettextCatalog.getString('Error'), err); return; } opts = lodash.assign(lopts, opts); @@ -174,10 +173,7 @@ angular.module('copayApp.controllers').controller('createController', ongoingProcess.set('creatingWallet', false); if (err) { $log.warn(err); - self.error = err; - $timeout(function() { - $rootScope.$apply(); - }); + popupService.showAlert(gettextCatalog.getString('Error'), err); return; } diff --git a/src/js/controllers/export.js b/src/js/controllers/export.js index 1ea44845f..0a0690e85 100644 --- a/src/js/controllers/export.js +++ b/src/js/controllers/export.js @@ -1,7 +1,7 @@ 'use strict'; angular.module('copayApp.controllers').controller('exportController', - function($rootScope, $scope, $timeout, $log, lodash, backupService, walletService, storageService, profileService, platformInfo, gettext, gettextCatalog, $state, $stateParams) { + function($rootScope, $scope, $timeout, $log, lodash, backupService, walletService, storageService, profileService, platformInfo, gettext, gettextCatalog, $state, $stateParams, popupService) { var prevState; var isWP = platformInfo.isWP; var isAndroid = platformInfo.isAndroid; @@ -10,7 +10,6 @@ angular.module('copayApp.controllers').controller('exportController', $scope.isEncrypted = wallet.isPrivKeyEncrypted(); $scope.isCordova = platformInfo.isCordova; $scope.isSafari = platformInfo.isSafari; - $scope.error = null; $scope.init = function() { $scope.supported = true; @@ -51,7 +50,7 @@ angular.module('copayApp.controllers').controller('exportController', $scope.downloadWalletBackup = function() { $scope.getAddressbook(function(err, localAddressBook) { if (err) { - $scope.error = true; + popupService.showAlert(gettextCatalog.getString('Error'), gettextCatalog.getString('Failed to export')); return; } var opts = { @@ -61,7 +60,7 @@ angular.module('copayApp.controllers').controller('exportController', backupService.walletDownload($scope.password, opts, function(err) { if (err) { - $scope.error = true; + popupService.showAlert(gettextCatalog.getString('Error'), gettextCatalog.getString('Failed to export')); return; } $state.go('tabs.home'); @@ -87,7 +86,7 @@ angular.module('copayApp.controllers').controller('exportController', $scope.getBackup = function(cb) { $scope.getAddressbook(function(err, localAddressBook) { if (err) { - $scope.error = true; + popupService.showAlert(gettextCatalog.getString('Error'), gettextCatalog.getString('Failed to export')); return cb(null); } var opts = { @@ -97,9 +96,7 @@ angular.module('copayApp.controllers').controller('exportController', var ew = backupService.walletExport($scope.password, opts); if (!ew) { - $scope.error = true; - } else { - $scope.error = false; + popupService.showAlert(gettextCatalog.getString('Error'), gettextCatalog.getString('Failed to export')); } return cb(ew); }); diff --git a/src/js/controllers/import.js b/src/js/controllers/import.js index a5f09fd26..c1fbaf111 100644 --- a/src/js/controllers/import.js +++ b/src/js/controllers/import.js @@ -1,7 +1,7 @@ 'use strict'; angular.module('copayApp.controllers').controller('importController', - function($scope, $rootScope, $timeout, $log, $state, $stateParams, $ionicHistory, profileService, configService, sjcl, gettext, ledger, trezor, derivationPathHelper, platformInfo, bwcService, ongoingProcess, walletService) { + function($scope, $rootScope, $timeout, $log, $state, $stateParams, $ionicHistory, profileService, configService, sjcl, gettext, ledger, trezor, derivationPathHelper, platformInfo, bwcService, ongoingProcess, walletService, popupService, gettextCatalog) { var isChromeApp = platformInfo.isChromeApp; var isDevel = platformInfo.isDevel; @@ -38,12 +38,11 @@ angular.module('copayApp.controllers').controller('importController', if (!code) return; $scope.importErr = false; - $scope.error = null; var parsedCode = code.split('|'); if (parsedCode.length != 5) { /// Trying to import a malformed wallet export QR code - $scope.error = gettext('Incorrect code format'); + popupService.showAlert(gettextCatalog.getString('Error'), gettextCatalog.getString('Incorrect code format')); return; } @@ -56,7 +55,7 @@ angular.module('copayApp.controllers').controller('importController', }; if (info.type == 1 && info.hasPassphrase) - $scope.error = gettext('Password required. Make sure to enter your password in advanced options'); + popupService.showAlert(gettextCatalog.getString('Password required. Make sure to enter your password in advanced options')); $scope.derivationPath = info.derivationPath; $scope.testnetEnabled = info.network == 'testnet' ? true : false; @@ -69,7 +68,6 @@ angular.module('copayApp.controllers').controller('importController', $scope.setType = function(type) { $scope.type = type; - $scope.error = null; $timeout(function() { $rootScope.$apply(); }, 1); @@ -80,12 +78,12 @@ angular.module('copayApp.controllers').controller('importController', try { str2 = sjcl.decrypt($scope.password, str); } catch (e) { - err = gettext('Could not decrypt file, check your password'); + err = gettextCatalog.getString('Could not decrypt file, check your password'); $log.warn(e); }; if (err) { - $scope.error = err; + popupService.showAlert(gettextCatalog.getString('Error'), err); $timeout(function() { $rootScope.$apply(); }); @@ -100,7 +98,7 @@ angular.module('copayApp.controllers').controller('importController', profileService.importWallet(str2, opts, function(err, client) { ongoingProcess.set('importingWallet', false); if (err) { - $scope.error = err; + popupService.showAlert(gettextCatalog.getString('Error'), err); return; } @@ -129,7 +127,7 @@ angular.module('copayApp.controllers').controller('importController', if (err instanceof errors.NOT_AUTHORIZED) { $scope.importErr = true; } else { - $scope.error = err; + popupService.showAlert(gettextCatalog.getString('Error'), err); } return $timeout(function() { $scope.$apply(); @@ -190,7 +188,7 @@ angular.module('copayApp.controllers').controller('importController', if (err instanceof errors.NOT_AUTHORIZED) { $scope.importErr = true; } else { - $scope.error = err; + popupService.showAlert(gettextCatalog.getString('Error'), err); } return $timeout(function() { $scope.$apply(); @@ -232,10 +230,7 @@ angular.module('copayApp.controllers').controller('importController', $scope.importBlob = function(form) { if (form.$invalid) { - $scope.error = gettext('There is an error in the form'); - $timeout(function() { - $scope.$apply(); - }); + popupService.showAlert(gettextCatalog.getString('Error'), gettextCatalog.getString('There is an error in the form')); return; } @@ -244,11 +239,7 @@ angular.module('copayApp.controllers').controller('importController', var password = form.password.$modelValue; if (!backupFile && !backupText) { - $scope.error = gettext('Please, select your backup file'); - $timeout(function() { - $scope.$apply(); - }); - + popupService.showAlert(gettextCatalog.getString('Error'), gettextCatalog.getString('Please, select your backup file')); return; } @@ -263,10 +254,7 @@ angular.module('copayApp.controllers').controller('importController', $scope.importMnemonic = function(form) { if (form.$invalid) { - $scope.error = gettext('There is an error in the form'); - $timeout(function() { - $scope.$apply(); - }); + popupService.showAlert(gettextCatalog.getString('Error'), gettextCatalog.getString('There is an error in the form')); return; } @@ -276,7 +264,7 @@ angular.module('copayApp.controllers').controller('importController', var pathData = derivationPathHelper.parse($scope.derivationPath); if (!pathData) { - $scope.error = gettext('Invalid derivation path'); + popupService.showAlert(gettextCatalog.getString('Error'), gettextCatalog.getString('Invalid derivation path')); return; } opts.account = pathData.account; @@ -284,10 +272,9 @@ angular.module('copayApp.controllers').controller('importController', opts.derivationStrategy = pathData.derivationStrategy; var words = form.words.$modelValue || null; - $scope.error = null; if (!words) { - $scope.error = gettext('Please enter the recovery phrase'); + popupService.showAlert(gettextCatalog.getString('Please enter the recovery phrase')); } else if (words.indexOf('xprv') == 0 || words.indexOf('tprv') == 0) { return _importExtendedPrivateKey(words, opts); } else if (words.indexOf('xpub') == 0 || words.indexOf('tpuv') == 0) { @@ -296,17 +283,11 @@ angular.module('copayApp.controllers').controller('importController', var wordList = words.split(/[\u3000\s]+/); if ((wordList.length % 3) != 0) { - $scope.error = gettext('Wrong number of recovery words:') + wordList.length; + popupService.showAlert(gettextCatalog.getString('Wrong number of recovery words:') + wordList.length); + return; } } - if ($scope.error) { - $timeout(function() { - $scope.$apply(); - }); - return; - } - var passphrase = form.passphrase.$modelValue; opts.passphrase = form.passphrase.$modelValue || null; @@ -317,8 +298,7 @@ angular.module('copayApp.controllers').controller('importController', trezor.getInfoForNewWallet(isMultisig, account, function(err, lopts) { ongoingProcess.clear(); if (err) { - $scope.error = err; - $scope.$apply(); + popupService.showAlert(gettextCatalog.getString('Error'), err); return; } @@ -330,10 +310,8 @@ angular.module('copayApp.controllers').controller('importController', profileService.importExtendedPublicKey(lopts, function(err, wallet) { ongoingProcess.set('importingWallet', false); if (err) { - $scope.error = err; - return $timeout(function() { - $scope.$apply(); - }); + popupService.showAlert(gettextCatalog.getString('Error'), err); + return; } @@ -354,13 +332,9 @@ angular.module('copayApp.controllers').controller('importController', $scope.importHW = function(form) { if (form.$invalid || $scope.account < 0) { - $scope.error = gettext('There is an error in the form'); - $timeout(function() { - $scope.$apply(); - }); + popupService.showAlert(gettextCatalog.getString('There is an error in the form')); return; } - $scope.error = ''; $scope.importErr = false; var account = +$scope.account; @@ -400,8 +374,7 @@ angular.module('copayApp.controllers').controller('importController', ledger.getInfoForNewWallet(true, account, function(err, lopts) { ongoingProcess.clear(); if (err) { - $scope.error = err; - $scope.$apply(); + popupService.showAlert(gettextCatalog.getString('Error'), err); return; } @@ -413,10 +386,8 @@ angular.module('copayApp.controllers').controller('importController', profileService.importExtendedPublicKey(lopts, function(err, wallet) { ongoingProcess.set('importingWallet', false); if (err) { - $scope.error = err; - return $timeout(function() { - $scope.$apply(); - }); + popupService.showAlert(gettextCatalog.getString('Error'), err); + return; } diff --git a/src/js/controllers/join.js b/src/js/controllers/join.js index 4afdbd963..757a584b9 100644 --- a/src/js/controllers/join.js +++ b/src/js/controllers/join.js @@ -1,7 +1,7 @@ 'use strict'; angular.module('copayApp.controllers').controller('joinController', - function($scope, $rootScope, $timeout, $state, profileService, configService, storageService, applicationService, gettext, lodash, ledger, trezor, platformInfo, derivationPathHelper, ongoingProcess, walletService, $log, $stateParams) { + function($scope, $rootScope, $timeout, $state, profileService, configService, storageService, applicationService, gettext, gettextCatalog, lodash, ledger, trezor, platformInfo, derivationPathHelper, ongoingProcess, walletService, $log, $stateParams, popupService) { var isChromeApp = platformInfo.isChromeApp; var isDevel = platformInfo.isDevel; @@ -14,7 +14,6 @@ angular.module('copayApp.controllers').controller('joinController', this.onQrCodeScanned = function(data) { -console.log('[join.js.16:data:]',data); //TODO $scope.secret = data; if ($scope.joinForm) { $scope.joinForm.secret.$setViewValue(data); @@ -64,7 +63,7 @@ console.log('[join.js.16:data:]',data); //TODO this.join = function(form) { if (form && form.$invalid) { - self.error = gettext('Please enter the required fields'); + popupService.showAlert(gettextCatalog.getString('Error'), gettextCatalog.getString('Please enter the required fields')); return; } @@ -86,7 +85,7 @@ console.log('[join.js.16:data:]',data); //TODO var pathData = derivationPathHelper.parse($scope.derivationPath); if (!pathData) { - this.error = gettext('Invalid derivation path'); + popupService.showAlert(gettextCatalog.getString('Error'), gettextCatalog.getString('Invalid derivation path')); return; } opts.account = pathData.account; @@ -100,15 +99,14 @@ console.log('[join.js.16:data:]',data); //TODO if (setSeed && !opts.mnemonic && !opts.extendedPrivateKey) { - - this.error = gettext('Please enter the wallet recovery phrase'); + popupService.showAlert(gettextCatalog.getString('Error'), gettextCatalog.getString('Please enter the wallet recovery phrase')); return; } if (self.seedSourceId == 'ledger' || self.seedSourceId == 'trezor') { var account = $scope.account; if (!account || account < 1) { - this.error = gettext('Invalid account number'); + popupService.showAlert(gettextCatalog.getString('Error'), gettextCatalog.getString('Invalid account number')); return; } @@ -122,8 +120,7 @@ console.log('[join.js.16:data:]',data); //TODO src.getInfoForNewWallet(true, account, function(err, lopts) { ongoingProcess.set('connecting' + self.seedSourceId, false); if (err) { - self.error = err; - $scope.$apply(); + popupService.showAlert(gettextCatalog.getString('Error'), err); return; } opts = lodash.assign(lopts, opts); @@ -141,8 +138,7 @@ console.log('[join.js.16:data:]',data); //TODO profileService.joinWallet(opts, function(err, client) { ongoingProcess.set('joiningWallet', false); if (err) { - self.error = err; - $rootScope.$apply(); + popupService.showAlert(gettextCatalog.getString('Error'), err); return; } diff --git a/src/js/controllers/modals/txpDetails.js b/src/js/controllers/modals/txpDetails.js index b426602e6..e76acb50b 100644 --- a/src/js/controllers/modals/txpDetails.js +++ b/src/js/controllers/modals/txpDetails.js @@ -1,6 +1,6 @@ 'use strict'; -angular.module('copayApp.controllers').controller('txpDetailsController', function($scope, $rootScope, $timeout, $interval, $ionicModal, ongoingProcess, platformInfo, txStatus, $ionicScrollDelegate, txFormatService, fingerprintService, bwcError, gettextCatalog, lodash, walletService) { +angular.module('copayApp.controllers').controller('txpDetailsController', function($scope, $rootScope, $timeout, $interval, $ionicModal, ongoingProcess, platformInfo, txStatus, $ionicScrollDelegate, txFormatService, fingerprintService, bwcError, gettextCatalog, lodash, walletService, popupService) { var self = $scope.self; var tx = $scope.tx; var copayers = $scope.copayers; @@ -25,13 +25,11 @@ angular.module('copayApp.controllers').controller('txpDetailsController', functi } var setSendError = function(msg) { - $scope.error = msg || gettextCatalog.getString('Could not send payment'); + var error = msg || gettextCatalog.getString('Could not send payment'); + popupService.showAlert(gettextCatalog.getString('Error'), error); } - - $scope.sign = function() { - $scope.error = null; $scope.loading = true; walletService.publishAndSign($scope.wallet, $scope.tx, function(err, txp) { $scope.$emit('UpdateTx'); @@ -42,18 +40,14 @@ angular.module('copayApp.controllers').controller('txpDetailsController', functi function setError(err, prefix) { $scope.loading = false; - $scope.error = bwcError.msg(err, prefix); - $timeout(function() { - $scope.$digest(); - }, 10); + popupService.showAlert(gettextCatalog.getString('Error'), bwcError.msg(err, prefix)); }; $scope.reject = function(txp) { $scope.loading = true; - $scope.error = null; walletService.reject($scope.wallet, $scope.tx, function(err, txpr) { - if (err) + if (err) return setError(err, gettextCatalog.getString('Could not reject payment')); $scope.close(txpr); @@ -64,7 +58,6 @@ angular.module('copayApp.controllers').controller('txpDetailsController', functi $scope.remove = function() { $scope.loading = true; - $scope.error = null; $timeout(function() { ongoingProcess.set('removeTx', true); @@ -84,7 +77,6 @@ angular.module('copayApp.controllers').controller('txpDetailsController', functi $scope.broadcast = function(txp) { $scope.loading = true; - $scope.error = null; $timeout(function() { ongoingProcess.set('broadcastTx', true); @@ -185,7 +177,7 @@ angular.module('copayApp.controllers').controller('txpDetailsController', functi if (txp) { var type = txStatus.notify(txp); $scope.openStatusModal(type, txp, function() {}); - } + } $scope.cancel(); }; diff --git a/src/js/controllers/preferencesBwsUrl.js b/src/js/controllers/preferencesBwsUrl.js index 0c886148a..16c8ef2d6 100644 --- a/src/js/controllers/preferencesBwsUrl.js +++ b/src/js/controllers/preferencesBwsUrl.js @@ -3,7 +3,6 @@ angular.module('copayApp.controllers').controller('preferencesBwsUrlController', function($scope, $log, $stateParams, $ionicNavBarDelegate, configService, applicationService, profileService, storageService) { $ionicNavBarDelegate.title('Wallet Service URL'); - $scope.error = null; $scope.success = null; var wallet = profileService.getWallet($stateParams.walletId); diff --git a/src/js/controllers/preferencesDelete.js b/src/js/controllers/preferencesDelete.js index fa0d3bca2..c66e2c165 100644 --- a/src/js/controllers/preferencesDelete.js +++ b/src/js/controllers/preferencesDelete.js @@ -1,12 +1,11 @@ 'use strict'; angular.module('copayApp.controllers').controller('preferencesDeleteWalletController', - function($scope, $ionicPopup, $stateParams, $ionicNavBarDelegate, gettextCatalog, lodash, profileService, $state, ongoingProcess) { + function($scope, $ionicPopup, $stateParams, $ionicNavBarDelegate, gettextCatalog, lodash, profileService, $state, ongoingProcess, popupService) { $ionicNavBarDelegate.title(gettextCatalog.getString('Delete Wallet')); var wallet = profileService.getWallet($stateParams.walletId); $scope.alias = lodash.isEqual(wallet.name, wallet.credentials.walletName) ? null : wallet.name + ' '; $scope.walletName = '[' + wallet.credentials.walletName + ']'; - $scope.error = null; $scope.showDeletePopup = function() { var popup = $ionicPopup.show({ @@ -36,7 +35,7 @@ angular.module('copayApp.controllers').controller('preferencesDeleteWalletContro profileService.deleteWalletClient(wallet, function(err) { ongoingProcess.set('deletingWallet', false); if (err) { - $scope.error = err.message || err; + popupService.showAlert(gettextCatalog.getString('Error'), err.message || err); } else { $state.go('tabs.home'); } diff --git a/src/js/controllers/tab-receive.js b/src/js/controllers/tab-receive.js index 16d509897..3a03d090a 100644 --- a/src/js/controllers/tab-receive.js +++ b/src/js/controllers/tab-receive.js @@ -1,6 +1,6 @@ 'use strict'; -angular.module('copayApp.controllers').controller('tabReceiveController', function($scope, $timeout, $log, platformInfo, walletService, profileService, configService, lodash, gettextCatalog) { +angular.module('copayApp.controllers').controller('tabReceiveController', function($scope, $timeout, $log, platformInfo, walletService, profileService, configService, lodash, gettextCatalog, popupService) { $scope.isCordova = platformInfo.isCordova; @@ -33,7 +33,6 @@ angular.module('copayApp.controllers').controller('tabReceiveController', functi if ($scope.generatingAddress) return; var wallet = wallet || $scope.wallet; - $scope.error = null; $scope.addr = null; $scope.generatingAddress = true; @@ -41,7 +40,7 @@ angular.module('copayApp.controllers').controller('tabReceiveController', functi walletService.getAddress(wallet, forceNew, function(err, addr) { $scope.generatingAddress = false; if (err) { - $scope.error = err; + popupService.showAlert(gettextCatalog.getString('Error'), err); } else { if (addr) $scope.addr = addr; diff --git a/src/js/services/walletService.js b/src/js/services/walletService.js index fd5a5bfa2..e5640af61 100644 --- a/src/js/services/walletService.js +++ b/src/js/services/walletService.js @@ -1,6 +1,6 @@ 'use strict'; -angular.module('copayApp.services').factory('walletService', function($log, $timeout, lodash, trezor, ledger, storageService, configService, rateService, uxLanguage, $filter, gettextCatalog, bwcError, $ionicPopup, fingerprintService, ongoingProcess, gettext, $rootScope, txStatus, txFormatService, $ionicModal, $state, bwcService, bitcore) { +angular.module('copayApp.services').factory('walletService', function($log, $timeout, lodash, trezor, ledger, storageService, configService, rateService, uxLanguage, $filter, gettextCatalog, bwcError, $ionicPopup, fingerprintService, ongoingProcess, gettext, $rootScope, txStatus, txFormatService, $ionicModal, $state, bwcService, bitcore, popupService) { // `wallet` is a decorated version of client. var root = {}; @@ -81,12 +81,11 @@ angular.module('copayApp.services').factory('walletService', function($log, $tim wallet.notAuthorized = true; $state.go('tabs.home'); } else if (err instanceof errors.NOT_FOUND) { - root.showErrorPopup(gettext('Could not access Wallet Service: Not found')); + popupService.showAlert(gettextCatalog.getString('Could not access Wallet Service: Not found')); } else { var msg = "" $rootScope.$emit('Local/ClientError', (err.error ? err.error : err)); - var msg = bwcError.msg(err, gettext('Error at Wallet Service')); - root.showErrorPopup(msg); + popupService.showAlert(bwcError.msg(err, gettextCatalog.getString('Error at Wallet Service'))); } }; root.handleError = lodash.debounce(_handleError, 1000); @@ -664,20 +663,6 @@ angular.module('copayApp.services').factory('walletService', function($log, $tim }); }; - root.showErrorPopup = function(msg, cb) { - $log.warn('Showing err popup:' + msg); - - // An alert dialog - var alertPopup = $ionicPopup.alert({ - title: title, - template: msg - }); - - if (!cb) cb = function() {}; - - alertPopup.then(cb); - }; - // walletHome root.recreate = function(wallet, cb) { ongoingProcess.set('recreating', true);