mirror of https://github.com/BTCPrivate/copay.git
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:
parent
13996dc26a
commit
e02d4cb00b
|
@ -13,7 +13,7 @@
|
|||
"angular-gettext": "2.1.2",
|
||||
"angular-moment": "0.10.1",
|
||||
"angular-qrcode": "monospaced/angular-qrcode#~6.0.3",
|
||||
"angular-ui-router": "0.2.15",
|
||||
"angular-ui-router": "0.2.18",
|
||||
"angular-ui-switch": "0.1.1",
|
||||
"animate.css": "3.4.0",
|
||||
"foundation": "5.5.2",
|
||||
|
|
|
@ -16,5 +16,5 @@ src="img/icon-ledger-white.svg">
|
|||
<img style="height:0.6em; margin-right: 1px;" ng-show="index.usingCustomBWS" src="img/icon-bws-white.svg">
|
||||
|
||||
<img style="height:0.6em" class="animated flash infinite" ng-show="index.loadingWallet ||
|
||||
index.updatingTxHistory[index.walletId]" src="img/icon-sync-white.svg">
|
||||
index.updatingTxHistory" src="img/icon-sync-white.svg">
|
||||
|
||||
|
|
|
@ -154,12 +154,16 @@
|
|||
|
||||
<div
|
||||
class="oh pr m20t text-gray size-12 text-center"
|
||||
ng-show="!index.loadingWallet && !index.txHistory[0] && !index.updatingTxHistory[index.walletId] &&
|
||||
!index.txHistoryError && !index.updateError" translate>
|
||||
ng-show="!index.loadingWallet && !index.txHistory[0] && !index.updatingTxHistory && !index.txHistoryError && !index.updateError" translate>
|
||||
No transactions yet
|
||||
</div>
|
||||
<div ng-show="index.updatingTxHistory[index.walletId]
|
||||
&& ( (index.txProgress > 6 && !index.txHistory[0]) || (index.txProgress > 50 ) )">
|
||||
|
||||
<div class="oh pr" ng-show="index.txHistory[0] || index.txProgress > 5">
|
||||
<h4 class="title m0">
|
||||
<span translate>Activity</span>
|
||||
</h4>
|
||||
|
||||
<div ng-show="index.updatingTxHistory && index.txProgress > 5">
|
||||
<div class="row p20 text-center">
|
||||
<div class="columns large-12 medium-12 small-12 m10b">
|
||||
<div class="spinner">
|
||||
|
@ -177,13 +181,7 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<div class="oh pr" ng-show="index.txHistory[0]">
|
||||
<h4 class="title m0">
|
||||
<span translate>Activity</span>
|
||||
</h4>
|
||||
|
||||
|
||||
<div ng-if="index.txHistory[0] && index.updatingTxHistory[index.walletId] && index.newTx" class="row collapse last-transactions-content animated fadeInDown">
|
||||
<div ng-if="index.txHistory[0] && index.updatingTxHistory && index.newTx" class="row collapse last-transactions-content animated fadeInDown">
|
||||
<div class="large-6 medium-6 small-6 columns size-14">
|
||||
<div class="m10r left">
|
||||
<img src="img/icon-new.svg" width="40">
|
||||
|
@ -194,11 +192,10 @@
|
|||
<div style="margin-top:5px; background:#eee; width: 6em; margin-left: 52px; line-height:0.6em">
|
||||
<span> </span>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div ng-repeat="btx in index.txHistory"
|
||||
<div ng-repeat="btx in index.txHistory track by btx.txid"
|
||||
fast-click callback-fn="home.openTxModal(btx)"
|
||||
class="row collapse last-transactions-content">
|
||||
<div class="large-6 medium-6 small-6 columns size-14">
|
||||
|
@ -302,8 +299,8 @@
|
|||
<!-- Address-->
|
||||
<div class="large-12 columns">
|
||||
<h2 class="text-center m10t" translate>My Bitcoin address</h2>
|
||||
<div class="text-center" ng-click="home.copyToClipboard(home.getWalletData('addr'))" ng-show="home.getWalletData('addr') || home.generatingAddress">
|
||||
<qrcode size="220" data="bitcoin:{{home.getWalletData('addr')}}"></qrcode>
|
||||
<div class="text-center" ng-click="home.copyToClipboard(home.addr)" ng-show="home.addr || home.generatingAddress">
|
||||
<qrcode size="220" data="bitcoin:{{home.addr}}"></qrcode>
|
||||
<div ng-show="home.generatingAddress" style="position:relative; top:-226px; height:0px">
|
||||
<div style="height:220px; width:220px; margin:auto; background: white">
|
||||
<div class="spinner" style="margin-top:85px">
|
||||
|
@ -317,29 +314,29 @@
|
|||
</div>
|
||||
<div class="m10t" >
|
||||
<h4 ng-class="{'enable_text_select': !index.isCordova}" class="size-12">
|
||||
{{home.generatingAddress ? '...' : home.getWalletData('addr')}}
|
||||
{{home.generatingAddress ? '...' : home.addr}}
|
||||
</h4>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row m20t">
|
||||
<div class="small-12 columns" ng-show="index.isCordova && home.getWalletData('addr')">
|
||||
<div class="small-12 columns" ng-show="index.isCordova && home.addr">
|
||||
<button class="button outline light-gray small round expand"
|
||||
ng-click="home.shareAddress(home.getWalletData('addr'))"
|
||||
ng-click="home.shareAddress(home.addr)"
|
||||
ng-disabled="home.generatingAddress">
|
||||
<span translate>Share address</span>
|
||||
</button>
|
||||
</div>
|
||||
<div class="small-12 columns" ng-show="home.getWalletData('addr')">
|
||||
<button class="button expand small round m10b" ng-click="home.openCustomizedAmountModal(home.getWalletData('addr'))"
|
||||
<div class="small-12 columns" ng-show="home.addr">
|
||||
<button class="button expand small round m10b" ng-click="home.openCustomizedAmountModal(home.addr)"
|
||||
ng-style="{'background-color':index.backgroundColor}"
|
||||
ng-disabled="home.generatingAddress">
|
||||
<span translate>Request a specific amount</span>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row m10t" ng-show="home.getWalletData('addr')" >
|
||||
<div class="row m10t" ng-show="home.addr" >
|
||||
<div class="large-12 columns">
|
||||
<div class="line-t size-10 text-gray m10b p10t">
|
||||
<span translate> Share this wallet address to receive payments. To protect your privacy, new addresses are generated automatically once you use them.</span>
|
||||
|
@ -361,7 +358,8 @@
|
|||
<div class="pr p25b">
|
||||
<h4 class="title m0">
|
||||
<available-balance></available-balance>
|
||||
<a ng-show="!home.lockedCurrentFeePerKb && index.feeToSendMaxStr && index.availableBalanceSat > 0 && !home.blockUx && !home.lockAmount"
|
||||
<a
|
||||
ng-show="!home.lockedCurrentFeePerKb && index.feeToSendMaxStr && index.availableBalanceSat > 0 && !home.blockUx && !home.lockAmount"
|
||||
ng-click="home.sendAll()"
|
||||
translate> Send All
|
||||
</a>
|
||||
|
|
|
@ -4,25 +4,19 @@ angular.module('copayApp.controllers').controller('indexController', function($r
|
|||
var self = this;
|
||||
var SOFT_CONFIRMATION_LIMIT = 12;
|
||||
var errors = bwcService.getErrors();
|
||||
self.isCordova = isCordova;
|
||||
self.isChromeApp = isChromeApp;
|
||||
self.isSafari = isMobile.Safari();
|
||||
self.isWindowsPhoneApp = isMobile.Windows() && isCordova;
|
||||
self.usePushNotifications = self.isCordova && !isMobile.Windows();
|
||||
self.onGoingProcess = {};
|
||||
self.historyShowLimit = 10;
|
||||
self.updatingTxHistory = {};
|
||||
self.prevState = 'walletHome';
|
||||
var historyUpdateInProgress = {};
|
||||
|
||||
function strip(number) {
|
||||
return (parseFloat(number.toPrecision(12)));
|
||||
};
|
||||
var ret = {};
|
||||
ret.isCordova = isCordova;
|
||||
ret.isChromeApp = isChromeApp;
|
||||
ret.isSafari = isMobile.Safari();
|
||||
ret.isWindowsPhoneApp = isMobile.Windows() && isCordova;
|
||||
ret.usePushNotifications = ret.isCordova && !isMobile.Windows();
|
||||
ret.onGoingProcess = {};
|
||||
ret.historyShowLimit = 10;
|
||||
ret.prevState = 'walletHome';
|
||||
|
||||
self.goHome = function() {
|
||||
go.walletHome();
|
||||
};
|
||||
|
||||
self.menu = [{
|
||||
ret.menu = [{
|
||||
'title': gettext('Receive'),
|
||||
'icon': {
|
||||
false: 'icon-receive',
|
||||
|
@ -45,14 +39,23 @@ angular.module('copayApp.controllers').controller('indexController', function($r
|
|||
'link': 'send'
|
||||
}];
|
||||
|
||||
self.addonViews = addonManager.addonViews();
|
||||
self.menu = self.menu.concat(addonManager.addonMenuItems());
|
||||
self.menuItemSize = self.menu.length > 4 ? 2 : 4;
|
||||
self.txTemplateUrl = addonManager.txTemplateUrl() || 'views/includes/transaction.html';
|
||||
ret.addonViews = addonManager.addonViews();
|
||||
ret.menu = ret.menu.concat(addonManager.addonMenuItems());
|
||||
ret.menuItemSize = ret.menu.length > 4 ? 2 : 4;
|
||||
ret.txTemplateUrl = addonManager.txTemplateUrl() || 'views/includes/transaction.html';
|
||||
|
||||
self.tab = 'walletHome';
|
||||
ret.tab = 'walletHome';
|
||||
ret.feeOpts = feeService.feeOpts;
|
||||
var vanillaScope = ret;
|
||||
|
||||
self.feeOpts = feeService.feeOpts;
|
||||
|
||||
function strip(number) {
|
||||
return (parseFloat(number.toPrecision(12)));
|
||||
};
|
||||
|
||||
self.goHome = function() {
|
||||
go.walletHome();
|
||||
};
|
||||
|
||||
self.setOngoingProcess = function(processName, isOn) {
|
||||
$log.debug('onGoingProcess', processName, isOn);
|
||||
|
@ -72,35 +75,31 @@ angular.module('copayApp.controllers').controller('indexController', function($r
|
|||
});
|
||||
};
|
||||
|
||||
self.cleanInstance = function() {
|
||||
$log.debug('Cleaning Index Instance');
|
||||
lodash.each(self, function(v, k) {
|
||||
if (lodash.isFunction(v)) return;
|
||||
if (vanillaScope[k]) return;
|
||||
|
||||
// This are to prevent flicker in mobile:
|
||||
if (k == 'hasProfile') return;
|
||||
if (k == 'noFocusedWallet') return;
|
||||
if (k == 'backgroundColor') return;
|
||||
if (k == 'loadingWallet') {
|
||||
self.loadingWallet = true;
|
||||
return;
|
||||
}
|
||||
|
||||
delete self[k];
|
||||
});
|
||||
};
|
||||
|
||||
self.setFocusedWallet = function() {
|
||||
var fc = profileService.focusedClient;
|
||||
if (!fc) return;
|
||||
|
||||
// loading full wallet
|
||||
self.cleanInstance();
|
||||
self.loadingWallet = true;
|
||||
|
||||
// Clean status
|
||||
self.totalBalanceSat = null;
|
||||
self.lockedBalanceSat = null;
|
||||
self.availableBalanceSat = null;
|
||||
self.pendingAmount = null;
|
||||
self.spendUnconfirmed = null;
|
||||
|
||||
self.totalBalanceStr = null;
|
||||
self.availableBalanceStr = null;
|
||||
self.lockedBalanceStr = null;
|
||||
|
||||
self.alternativeBalanceAvailable = false;
|
||||
self.totalBalanceAlternative = null;
|
||||
|
||||
self.currentFeeLevel = null;
|
||||
self.notAuthorized = false;
|
||||
self.txHistory = [];
|
||||
self.completeHistory = [];
|
||||
self.txProgress = 0;
|
||||
self.historyShowShowAll = false;
|
||||
self.balanceByAddress = null;
|
||||
self.pendingTxProposalsCountForUs = null;
|
||||
self.setSpendUnconfirmed();
|
||||
|
||||
$timeout(function() {
|
||||
|
@ -138,6 +137,8 @@ angular.module('copayApp.controllers').controller('indexController', function($r
|
|||
self.initGlidera();
|
||||
|
||||
self.setCustomBWSFlag();
|
||||
|
||||
$rootScope.$apply();
|
||||
if (fc.isPrivKeyExternal()) {
|
||||
self.needsBackup = false;
|
||||
self.openWallet();
|
||||
|
@ -373,7 +374,6 @@ angular.module('copayApp.controllers').controller('indexController', function($r
|
|||
|
||||
// Notify external addons or plugins
|
||||
$rootScope.$emit('Local/BalanceUpdated', walletStatus.balance);
|
||||
|
||||
$rootScope.$apply();
|
||||
|
||||
if (opts.triggerTxUpdate) {
|
||||
|
@ -668,7 +668,7 @@ angular.module('copayApp.controllers').controller('indexController', function($r
|
|||
addressService.isUsed(self.walletId, balance.byAddress, function(err, used) {
|
||||
if (used) {
|
||||
$log.debug('Address used. Creating new');
|
||||
$rootScope.$emit('Local/NeedNewAddress');
|
||||
$rootScope.$emit('Local/AddressIsUsed');
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -693,7 +693,7 @@ angular.module('copayApp.controllers').controller('indexController', function($r
|
|||
}
|
||||
};
|
||||
|
||||
this.csvHistory = function() {
|
||||
self.csvHistory = function() {
|
||||
|
||||
function saveFile(name, data) {
|
||||
var chooser = document.querySelector(name);
|
||||
|
@ -823,7 +823,7 @@ angular.module('copayApp.controllers').controller('indexController', function($r
|
|||
'Date': formatDate(it.time * 1000),
|
||||
'Destination': 'Bitcoin Network Fees',
|
||||
'Note': '',
|
||||
'Amount': '-'+_fee,
|
||||
'Amount': '-' + _fee,
|
||||
'Currency': 'BTC',
|
||||
'Txid': '',
|
||||
'Creator': '',
|
||||
|
@ -837,13 +837,13 @@ angular.module('copayApp.controllers').controller('indexController', function($r
|
|||
};
|
||||
|
||||
self.removeSoftConfirmedTx = function(txs) {
|
||||
return lodash.map(txs, function(tx) {
|
||||
return lodash.filter(txs, function(tx) {
|
||||
if (tx.confirmations >= SOFT_CONFIRMATION_LIMIT)
|
||||
return tx;
|
||||
});
|
||||
}
|
||||
|
||||
self.getConfirmedTxs = function(walletId, cb) {
|
||||
self.getSavedTxs = function(walletId, cb) {
|
||||
|
||||
storageService.getTxHistory(walletId, function(err, txs) {
|
||||
if (err) return cb(err);
|
||||
|
@ -859,12 +859,14 @@ angular.module('copayApp.controllers').controller('indexController', function($r
|
|||
} catch (ex) {
|
||||
$log.warn(ex);
|
||||
}
|
||||
return cb(null, lodash.compact(self.removeSoftConfirmedTx(localTxs)));
|
||||
return cb(null, lodash.compact(localTxs));
|
||||
});
|
||||
}
|
||||
|
||||
self.updateLocalTxHistory = function(client, cb) {
|
||||
var requestLimit = 5;
|
||||
var FIRST_LIMIT = 5;
|
||||
var LIMIT = 50;
|
||||
var requestLimit = FIRST_LIMIT;
|
||||
var walletId = client.credentials.walletId;
|
||||
var config = configService.getSync().wallet.settings;
|
||||
|
||||
|
@ -886,12 +888,21 @@ angular.module('copayApp.controllers').controller('indexController', function($r
|
|||
});
|
||||
};
|
||||
|
||||
self.getConfirmedTxs(walletId, function(err, txsFromLocal) {
|
||||
self.getSavedTxs(walletId, function(err, txsFromLocal) {
|
||||
if (err) return cb(err);
|
||||
var endingTxid = txsFromLocal[0] ? txsFromLocal[0].txid : null;
|
||||
|
||||
fixTxsUnit(txsFromLocal);
|
||||
|
||||
var confirmedTxs = self.removeSoftConfirmedTx(txsFromLocal);
|
||||
var endingTxid = confirmedTxs[0] ? confirmedTxs[0].txid : null;
|
||||
|
||||
// First update
|
||||
if (walletId == profileService.focusedClient.credentials.walletId) {
|
||||
self.completeHistory = txsFromLocal;
|
||||
self.setCompactTxHistory();
|
||||
}
|
||||
|
||||
|
||||
function getNewTxs(newTxs, skip, i_cb) {
|
||||
self.getTxsFromServer(client, skip, endingTxid, requestLimit, function(err, res, shouldContinue) {
|
||||
if (err) return i_cb(err);
|
||||
|
@ -907,30 +918,41 @@ angular.module('copayApp.controllers').controller('indexController', function($r
|
|||
return i_cb(null, newTxs);
|
||||
}
|
||||
|
||||
if (walletId == profileService.focusedClient.credentials.walletId)
|
||||
self.txProgress = newTxs.length;
|
||||
requestLimit = LIMIT;
|
||||
getNewTxs(newTxs, skip, i_cb);
|
||||
|
||||
// Progress update
|
||||
if (walletId == profileService.focusedClient.credentials.walletId) {
|
||||
self.txProgress = newTxs.length;
|
||||
if (self.completeHistory < FIRST_LIMIT && txsFromLocal.length == 0) {
|
||||
$log.debug('Showing partial history');
|
||||
var newHistory = self.processNewTxs(newTxs);
|
||||
newHistory = lodash.compact(newHistory.concat(confirmedTxs));
|
||||
self.completeHistory = newHistory;
|
||||
self.setCompactTxHistory();
|
||||
}
|
||||
$timeout(function() {
|
||||
$rootScope.$apply();
|
||||
});
|
||||
requestLimit = 50;
|
||||
getNewTxs(newTxs, skip, i_cb);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
getNewTxs([], 0, function(err, txs) {
|
||||
if (err) return cb(err);
|
||||
|
||||
var newHistory = lodash.compact(txs.concat(txsFromLocal));
|
||||
var newHistory = lodash.compact(txs.concat(confirmedTxs));
|
||||
$log.debug('Tx History synced. Total Txs: ' + newHistory.length);
|
||||
|
||||
// Final update
|
||||
if (walletId == profileService.focusedClient.credentials.walletId) {
|
||||
self.completeHistory = newHistory;
|
||||
self.txHistory = newHistory.slice(0, self.historyShowLimit);
|
||||
self.historyShowShowAll = newHistory.length > self.historyShowLimit;
|
||||
self.setCompactTxHistory();
|
||||
}
|
||||
|
||||
return storageService.setTxHistory(JSON.stringify(newHistory), walletId, function() {
|
||||
$log.debug('Tx History saved.');
|
||||
|
||||
return cb();
|
||||
});
|
||||
});
|
||||
|
@ -974,15 +996,18 @@ angular.module('copayApp.controllers').controller('indexController', function($r
|
|||
if (!fc) return;
|
||||
var walletId = fc.credentials.walletId;
|
||||
|
||||
if (!fc.isComplete() || self.updatingTxHistory[walletId]) return;
|
||||
if (!fc.isComplete() || historyUpdateInProgress[walletId]) {
|
||||
self.updatingTxHistory = historyUpdateInProgress[walletId];
|
||||
return;
|
||||
}
|
||||
|
||||
$log.debug('Updating Transaction History');
|
||||
self.txHistoryError = false;
|
||||
self.updatingTxHistory[walletId] = true;
|
||||
historyUpdateInProgress[walletId] = self.updatingTxHistory = true;
|
||||
|
||||
$timeout(function() {
|
||||
self.updateLocalTxHistory(fc, function(err) {
|
||||
self.updatingTxHistory[walletId] = false;
|
||||
historyUpdateInProgress[walletId] = self.updatingTxHistory = false;
|
||||
self.loadingWallet = false;
|
||||
self.txProgress = 0;
|
||||
if (err)
|
||||
|
@ -999,8 +1024,7 @@ angular.module('copayApp.controllers').controller('indexController', function($r
|
|||
|
||||
self.setCompactTxHistory = function() {
|
||||
self.txHistory = self.completeHistory.slice(0, self.historyShowLimit);
|
||||
if (self.completeHistory.length > self.historyShowLimit)
|
||||
self.historyShowShowAll = true;
|
||||
self.historyShowShowAll = self.completeHistory.length > self.historyShowLimit;
|
||||
};
|
||||
|
||||
self.debounceUpdateHistory = lodash.debounce(function() {
|
||||
|
@ -1470,7 +1494,7 @@ angular.module('copayApp.controllers').controller('indexController', function($r
|
|||
|
||||
$rootScope.$on('Local/NeedsConfirmation', function(event, txp, cb) {
|
||||
self.confirmTx = {
|
||||
txp : txFormatService.processTx(txp),
|
||||
txp: txFormatService.processTx(txp),
|
||||
callback: function(accept) {
|
||||
self.confirmTx = null;
|
||||
return cb(accept);
|
||||
|
@ -1509,4 +1533,7 @@ angular.module('copayApp.controllers').controller('indexController', function($r
|
|||
});
|
||||
});
|
||||
|
||||
|
||||
/* Start setup */
|
||||
lodash.assign(self, vanillaScope);
|
||||
});
|
||||
|
|
|
@ -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
|
||||
});
|
||||
|
@ -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();
|
||||
}
|
||||
|
||||
});
|
||||
|
|
|
@ -52,7 +52,7 @@ angular.module('copayApp.services').factory('go', function($window, $rootScope,
|
|||
toggleSidebar(invert);
|
||||
};
|
||||
|
||||
root.walletHome = function(delayed) {
|
||||
root.walletHome = function() {
|
||||
var fc = profileService.focusedClient;
|
||||
if (fc && !fc.isComplete()) {
|
||||
root.path('copayers');
|
||||
|
@ -63,7 +63,6 @@ angular.module('copayApp.services').factory('go', function($window, $rootScope,
|
|||
}
|
||||
};
|
||||
|
||||
|
||||
root.send = function() {
|
||||
root.path('walletHome', function() {
|
||||
$rootScope.$emit('Local/SetTab', 'send');
|
||||
|
|
Loading…
Reference in New Issue