mv blockUx to wds

reset index scope on change wallet

rm wds

rm newTx, better txhistory update

better history display while sync

show first TX will syncing from 0

add new tx anim

WIP mobile

fix mobile

fix mobile 2

keep vanilla state in walletHome
This commit is contained in:
Matias Alejo Garcia 2016-02-18 17:16:07 -03:00
commit e02d4cb00b
6 changed files with 234 additions and 215 deletions

View file

@ -1,6 +1,6 @@
'use strict';
angular.module('copayApp.controllers').controller('walletHomeController', function($scope, $rootScope, $interval, $timeout, $filter, $modal, $log, notification, txStatus, isCordova, isMobile, profileService, lodash, configService, rateService, storageService, bitcore, isChromeApp, gettext, gettextCatalog, nodeWebkit, addressService, ledger, bwsError, confirmDialog, txFormatService, animationService, addressbookService, go, feeService, txService) {
angular.module('copayApp.controllers').controller('walletHomeController', function($scope, $rootScope, $interval, $timeout, $filter, $modal, $log, notification, txStatus, isCordova, isMobile, profileService, lodash, configService, rateService, storageService, bitcore, isChromeApp, gettext, gettextCatalog, nodeWebkit, addressService, ledger, bwsError, confirmDialog, txFormatService, animationService, addressbookService, go, feeService, txService){
var self = this;
window.ignoreMobilePause = false;
@ -8,25 +8,23 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi
$rootScope.wpInputFocused = false;
var config = configService.getSync();
var configWallet = config.wallet;
// INIT
var walletSettings = configWallet.settings;
this.unitToSatoshi = walletSettings.unitToSatoshi;
this.satToUnit = 1 / this.unitToSatoshi;
this.unitName = walletSettings.unitName;
this.alternativeIsoCode = walletSettings.alternativeIsoCode;
this.alternativeName = walletSettings.alternativeName;
this.alternativeAmount = 0;
this.unitDecimals = walletSettings.unitDecimals;
this.isCordova = isCordova;
this.addresses = [];
this.isMobile = isMobile.any();
this.isWindowsPhoneApp = isMobile.Windows() && isCordova;
this.blockUx = false;
this.isRateAvailable = false;
this.showScanner = false;
this.lockedCurrentFeePerKb = null;
this.paymentExpired = false;
var ret = {};
// INIT. Global value
ret.unitToSatoshi = walletSettings.unitToSatoshi;
ret.satToUnit = 1 / ret.unitToSatoshi;
ret.unitName = walletSettings.unitName;
ret.alternativeIsoCode = walletSettings.alternativeIsoCode;
ret.alternativeName = walletSettings.alternativeName;
ret.alternativeAmount = 0;
ret.unitDecimals = walletSettings.unitDecimals;
ret.isCordova = isCordova;
ret.addresses = [];
ret.isMobile = isMobile.any();
ret.isWindowsPhoneApp = isMobile.Windows() && isCordova;
var vanillaScope = ret;
var disableScannerListener = $rootScope.$on('dataScanned', function(event, data) {
@ -47,12 +45,23 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi
}, 100);
});
var disableAddrListener = $rootScope.$on('Local/NeedNewAddress', function() {
var disableAddrListener = $rootScope.$on('Local/AddressIsUsed', function() {
self.setAddress(true);
});
var disableFocusListener = $rootScope.$on('Local/NewFocusedWallet', function() {
self.addr = null;
self.resetForm();
self.kk=1;
$log.debug('Cleaning WalletHome Instance');
lodash.each(self, function(v, k) {
if (lodash.isFunction(v)) return;
if (vanillaScope[k]) return;
delete self[k];
});
});
var disableResumeListener = $rootScope.$on('Local/Resume', function() {
@ -88,24 +97,6 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi
});
this.walletData = {};
this.getWalletData = function(key) {
var fc = profileService.focusedClient;
if (!fc) return;
if (!this.walletData[fc.credentials.walletId]) return;
return this.walletData[fc.credentials.walletId][key];
};
this.setWalletData = function(key,val) {
var fc = profileService.focusedClient;
if (!fc) return;
if (!this.walletData[fc.credentials.walletId] )
this.walletData[fc.credentials.walletId] = {};
this.walletData[fc.credentials.walletId][key] = val;
};
this.onQrCodeScanned = function(data) {
if (data) go.send();
@ -523,13 +514,14 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi
};
this.setAddress = function(forceNew) {
console.log('[walletHome.js.795] KK', self.kk); //TODO
self.addrError = null;
var fc = profileService.focusedClient;
if (!fc)
return;
// Address already set?
if (!forceNew && self.getWalletData('addr')) {
if (!forceNew && self.addr) {
return;
}
@ -542,7 +534,7 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi
self.addrError = err;
} else {
if (addr)
self.setWalletData('addr',addr);;
self.addr = addr;
}
$scope.$digest();
@ -839,6 +831,7 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi
var self = this;
self.blockUx = !!name;
console.log('[walletHome.js.795] KK', self.kk); //TODO
if (isCordova) {
if (name) {
window.plugins.spinnerDialog.hide();
@ -892,7 +885,7 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi
amount = parseInt((form.amount.$modelValue * unitToSat).toFixed(0));
outputs.push({
'toAddress' : address,
'toAddress': address,
'amount': amount,
'message': comment
});
@ -922,7 +915,7 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi
});
return;
} else {
$rootScope.$emit('Local/NeedsConfirmation', txp, function(accept) {
$rootScope.$emit('Local/NeedsConfirmation', txp, function(accept) {
if (accept) self.acceptTx(txp);
else self.resetForm();
});
@ -1269,10 +1262,12 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi
};
/* Start setup */
lodash.assign(self, vanillaScope);
this.bindTouchDown();
if (profileService.focusedClient) {
this.setAddress();
this.setSendFormInputs();
}
});