mirror of https://github.com/BTCPrivate/copay.git
wallet details refactor
This commit is contained in:
parent
e3076d18ab
commit
8aefbe25b3
|
@ -3,7 +3,7 @@
|
|||
<ion-nav-bar class="bar-stable">
|
||||
<ion-nav-title>Home</ion-nav-title>
|
||||
</ion-nav-bar>
|
||||
<ion-content class="padding home" ng-controller="tabHomeController">
|
||||
<ion-content class="padding home" ng-controller="tabHomeController" cache-view="false">
|
||||
|
||||
<h2 class="title m0" translate>Payment Proposals</h2>
|
||||
<div class="list card" ng-if="txps[0]">
|
||||
|
@ -64,7 +64,7 @@
|
|||
Incomplete
|
||||
</span>
|
||||
<span class="item-note" ng-show="item.isComplete()">
|
||||
{{item.availableBalanceStr}}
|
||||
{{item.status.availableBalanceStr}}
|
||||
</span>
|
||||
</li>
|
||||
</ul>
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
|
||||
|
||||
<ion-view ng-controller="walletDetailsController">
|
||||
<ion-view>
|
||||
<ion-nav-bar class="bar-stable">
|
||||
<ion-nav-title>{{wallet.name}}</ion-nav-title>
|
||||
|
||||
|
@ -14,7 +14,7 @@
|
|||
</ion-nav-buttons>
|
||||
</ion-nav-bar>
|
||||
|
||||
<ion-content class="has-header" delegate-handle="my-handle" overflow-scroll="true">
|
||||
<ion-content ng-controller="walletDetailsController" ng-init="init()" cache-view="false" class="has-header" delegate-handle="my-handle" overflow-scroll="true">
|
||||
<div ng-show="!wallet">
|
||||
No Wallet
|
||||
<a href ui-sref="tabs.home" class="button">
|
||||
|
@ -33,35 +33,35 @@
|
|||
|
||||
<div class="oh pr" ng-show="wallet && wallet.isComplete()">
|
||||
<div ng-style="{'background-color':wallet.color}" class="amount">
|
||||
<div ng-if="!wallet.notAuthorized && !updating">
|
||||
<div ng-if="!notAuthorized && !updatingStatus">
|
||||
|
||||
<div class="m20t" ng-show="wallet.updateError" ng-click='update()'>
|
||||
<span class="size-12 db m10b">{{wallet.updateError|translate}}</span>
|
||||
<div class="m20t" ng-show="updateStatusError" ng-click='update()'>
|
||||
<span class="size-12 db m10b">{{updateStatusError|translate}}</span>
|
||||
<button class="outline white tiny round" translate>Tap to retry</button>
|
||||
</div>
|
||||
|
||||
<div ng-show="wallet.walletScanStatus == 'error'" ng-click='wallet.retryScan()'>
|
||||
<div ng-show="wallet.walletScanStatus == 'error'" ng-click='retryScan()'>
|
||||
<span translate>Scan status finished with error</span>
|
||||
<br><span translate>Tap to retry</span>
|
||||
</div>
|
||||
|
||||
|
||||
<div ng-click='updateAll({triggerTxUpdate: true})' ng-show="!updateError && wallet.walletScanStatus != 'error' && !hideBalance" on-hold="hideToggle()">
|
||||
<div ng-click='updateAll()' ng-show="!updateStatusError && wallet.walletScanStatus != 'error' && !hideBalance" on-hold="hideToggle()">
|
||||
<strong class="size-36">{{status.totalBalanceStr}}</strong>
|
||||
<div class="size-14" ng-if="wallet.totalBalanceAlternative">{{status.totalBalanceAlternative}} {{status.alternativeIsoCode}}</div>
|
||||
<div class="size-14" ng-if="wallet.pendingAmount">
|
||||
<div class="size-14" ng-if="status.totalBalanceAlternative">{{status.totalBalanceAlternative}} {{status.alternativeIsoCode}}</div>
|
||||
<div class="size-14" ng-if="status.pendingAmount">
|
||||
<span translate>Pending Confirmation</span>: {{status.pendingAmountStr}}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div ng-show="!wallet.updateError && wallet.walletScanStatus != 'error' && wallet.shouldHideBalance" on-hold="wallet.hideToggle()">
|
||||
<div ng-show="!updateStatusError && wallet.walletScanStatus != 'error' && shouldHideBalance" on-hold="hideToggle()">
|
||||
<strong class="size-24" translate>[Balance Hidden]</strong>
|
||||
<div class="size-14" translate>
|
||||
Tap and hold to show
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div ng-if="updating">
|
||||
<div ng-if="updatingStatus">
|
||||
<div class="size-36">
|
||||
<strong>...</strong>
|
||||
</div>
|
||||
|
@ -82,7 +82,7 @@
|
|||
</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="oh pr m20t" ng-show="wallet.notAuthorized && !updating">
|
||||
<div class="oh pr m20t" ng-show="notAuthorized && !updatingStatus">
|
||||
<div class="text-center text-warning">
|
||||
<i class="fi-alert"></i>
|
||||
<span translate>
|
||||
|
@ -94,7 +94,7 @@
|
|||
</div>
|
||||
<div class="text-center m10t ">
|
||||
<span class="button outline round dark-gray tiny"
|
||||
ng-click="wallet.recreate()">
|
||||
ng-click="recreate()">
|
||||
<span translate>Recreate</span>
|
||||
</span>
|
||||
</div>
|
||||
|
@ -105,48 +105,46 @@
|
|||
</div>
|
||||
|
||||
<div ng-if="wallet.txps[0]">
|
||||
<h4 ng-show="wallet.requiresMultipleSignatures" class="title m0" translate>Payment Proposals</h4>
|
||||
<h4 ng-show="!wallet.requiresMultipleSignatures" class="title m0" translate>Unsent transactions</h4>
|
||||
<h4 ng-show="requiresMultipleSignatures" class="title m0" translate>Payment Proposals</h4>
|
||||
<h4 ng-show="!requiresMultipleSignatures" class="title m0" translate>Unsent transactions</h4>
|
||||
<div ng-repeat="tx in wallet.txps">
|
||||
<div ng-include="wallet.txTemplateUrl"></div>
|
||||
</div>
|
||||
|
||||
<div class="text-gray text-center size-12 p10t"
|
||||
ng-show="wallet.lockedBalanceSat">
|
||||
ng-show="status.lockedBalanceSat">
|
||||
<span translate>Total Locked Balance</span>:
|
||||
<b>{{wallet.lockedBalanceStr}} </b>
|
||||
<span> {{wallet.lockedBalanceAlternative}}
|
||||
{{wallet.alternativeIsoCode}} </span>
|
||||
<b>{{status.lockedBalanceStr}} </b>
|
||||
<span> {{status.lockedBalanceAlternative}}
|
||||
{{status.alternativeIsoCode}} </span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Activity -->
|
||||
|
||||
<h4 class="title" ng-click="wallet.startSearch(); openSearchModal()" ng-show="!wallet.notAuthorized">
|
||||
<!-- Transactions -->
|
||||
<h4 class="title" ng-click="startSearch(); openSearchModal()" ng-show="!notAuthorized">
|
||||
<span translate>Activity</span>
|
||||
<i class="dib m5l size-16 pointer fi-magnifying-glass"></i>
|
||||
</h4>
|
||||
|
||||
<div class="oh pr m20t text-gray size-12 text-center"
|
||||
ng-show="!wallet.loadingWallet && !txHistory[0] && !wallet.updatingTxHistory && !wallet.txHistoryError && !wallet.updateError && !wallet.notAuthorized"
|
||||
translate>No transactions yet ZZZZ {{wallet.totalBalanceStr}}
|
||||
ng-show="!txHistory[0] && !updatingTxHistory && !txHistoryError && !updateStatusError && !notAuthorized"
|
||||
translate>No transactions yet {{status.totalBalanceStr}}
|
||||
</div>
|
||||
<div class="oh pr" ng-show="(txHistory[0] || updatingTxHistoryProgress > 5) && !notAuthorized">
|
||||
|
||||
<div class="oh pr" ng-show="(txHistory[0] || wallet.txProgress > 5) && !wallet.notAuthorized">
|
||||
|
||||
<div ng-show="wallet.updatingTxHistory && wallet.txProgress > 5">
|
||||
<div ng-show="updatingTxHistory">
|
||||
<div class="row p20 text-center">
|
||||
<div class="columns large-12 medium-12 small-12 m10b">
|
||||
<ion-spinner class="spinner-dark" icon="lines"></ion-spinner>
|
||||
</div>
|
||||
<div class="size-12 text-gray m20t">
|
||||
<div translate>{{wallet.txProgress}} transactions downloaded</div>
|
||||
<div translate>{{updatingTxHistoryProgress}} transactions downloaded</div>
|
||||
<div translate>Updating transaction history. Please stand by.</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div ng-if="txHistory[0] && wallet.updatingTxHistory && wallet.newTx" class="row collapse last-transactions-content animated fadeInDown">
|
||||
<div ng-if="txHistory[0] && updatingTxHistory && 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">
|
||||
|
@ -219,14 +217,12 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row m20t text-center" ng-show="wallet.historyRendering && !wallet.ching">
|
||||
<div class="columns large-12 medium-12 small-12">
|
||||
<ion-spinner class="spinner-stable" icon="lines"></ion-spinner>
|
||||
</div>
|
||||
<div class="text-center" ng-show="updatingTxHistory && !isSearching">
|
||||
<ion-spinner class="spinner-stable" icon="lines"></ion-spinner>
|
||||
</div>
|
||||
|
||||
<ion-infinite-scroll
|
||||
ng-if="wallet.historyShowMore"
|
||||
ng-if="txHistoryShowMore"
|
||||
on-infinite="showMore()"
|
||||
distance="1%">
|
||||
</ion-infinite-scroll>
|
||||
|
|
|
@ -11,7 +11,7 @@ angular.module('copayApp.controllers').controller('preferencesController',
|
|||
$scope.externalSource = null;
|
||||
|
||||
if (wallet) {
|
||||
walletService.updateStatus(wallet, {}, function(err, status) {});
|
||||
walletService.getStatus(wallet, {}, function(err, status) {});
|
||||
var config = configService.getSync();
|
||||
config.aliasFor = config.aliasFor || {};
|
||||
$scope.alias = config.aliasFor[walletId] || wallet.credentials.walletName;
|
||||
|
|
|
@ -7,22 +7,19 @@ angular.module('copayApp.controllers').controller('preferencesUnitController', f
|
|||
$scope.currentUnit = config.wallet.settings.unitCode;
|
||||
}
|
||||
|
||||
$scope.unitList = [
|
||||
{
|
||||
name: 'bits (1,000,000 bits = 1BTC)',
|
||||
shortName: 'bits',
|
||||
value: 100,
|
||||
decimals: 2,
|
||||
code: 'bit',
|
||||
},
|
||||
{
|
||||
name: 'BTC',
|
||||
shortName: 'BTC',
|
||||
value: 100000000,
|
||||
decimals: 8,
|
||||
code: 'btc',
|
||||
}
|
||||
];
|
||||
$scope.unitList = [{
|
||||
name: 'bits (1,000,000 bits = 1BTC)',
|
||||
shortName: 'bits',
|
||||
value: 100,
|
||||
decimals: 2,
|
||||
code: 'bit',
|
||||
}, {
|
||||
name: 'BTC',
|
||||
shortName: 'BTC',
|
||||
value: 100000000,
|
||||
decimals: 8,
|
||||
code: 'btc',
|
||||
}];
|
||||
|
||||
$scope.save = function(newUnit) {
|
||||
var opts = {
|
||||
|
|
|
@ -88,11 +88,9 @@ angular.module('copayApp.controllers').controller('tabHomeController',
|
|||
|
||||
self.updateAllClients = function() {
|
||||
var txps = [];
|
||||
var wallets = profileService.getWallets();
|
||||
var l = wallets.length,
|
||||
i = 0;
|
||||
var i = $scope.wallets.length;
|
||||
|
||||
lodash.each(wallets, function(wallet) {
|
||||
lodash.each($scope.wallets, function(wallet) {
|
||||
walletService.getStatus(wallet, {}, function(err, status) {
|
||||
if (err) {
|
||||
console.log('[tab-home.js.35:err:]', $log.error(err)); //TODO
|
||||
|
@ -101,9 +99,10 @@ angular.module('copayApp.controllers').controller('tabHomeController',
|
|||
if (status.pendingTxps && status.pendingTxps[0]) {
|
||||
txps = txps.concat(status.pendingTxps);
|
||||
}
|
||||
if (++i == l) {
|
||||
if (--i == 0) {
|
||||
setPendingTxps(txps);
|
||||
}
|
||||
wallet.status = status;
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
|
@ -1,36 +1,16 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copayApp.controllers').controller('walletDetailsController', function($scope, $rootScope, $interval, $timeout, $filter, $log, $ionicModal, $ionicPopover, $state, $stateParams, profileService, lodash, configService, gettext, gettextCatalog, platformInfo, go, walletService) {
|
||||
|
||||
angular.module('copayApp.controllers').controller('walletDetailsController', function($scope, $rootScope, $interval, $timeout, $filter, $log, $ionicModal, $ionicPopover, $state, $stateParams, bwcError, profileService, lodash, configService, gettext, gettextCatalog, platformInfo, go, walletService) {
|
||||
|
||||
var isCordova = platformInfo.isCordova;
|
||||
var isWP = platformInfo.isWP;
|
||||
var isAndroid = platformInfo.isAndroid;
|
||||
var isChromeApp = platformInfo.isChromeApp;
|
||||
|
||||
var self = this;
|
||||
$rootScope.shouldHideMenuBar = false;
|
||||
$rootScope.wpInputFocused = false;
|
||||
var config = configService.getSync();
|
||||
var configWallet = config.wallet;
|
||||
var walletSettings = configWallet.settings;
|
||||
var ret = {};
|
||||
var errorPopup;
|
||||
|
||||
var HISTORY_SHOW_LIMIT = 10;
|
||||
|
||||
// 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 = platformInfo.isMobile;
|
||||
ret.isWindowsPhoneApp = platformInfo.isWP;
|
||||
ret.countDown = null;
|
||||
ret.sendMaxInfo = {};
|
||||
ret.showAlternative = false;
|
||||
|
||||
$scope.openSearchModal = function() {
|
||||
var fc = profileService.focusedClient;
|
||||
|
@ -61,48 +41,100 @@ angular.module('copayApp.controllers').controller('walletDetailsController', fun
|
|||
});
|
||||
};
|
||||
|
||||
$scope.updateAll = function() {
|
||||
$scope.update();
|
||||
}
|
||||
$scope.recreate = function() {
|
||||
walletService.recreate();
|
||||
};
|
||||
|
||||
$scope.update = function() {
|
||||
$scope.updating = true;
|
||||
$scope.updateStatus = function(force) {
|
||||
$scope.updatingStatus = true;
|
||||
$scope.updateStatusError = false;
|
||||
$timeout(function() {
|
||||
walletService.getStatus(wallet, {
|
||||
force: true
|
||||
force: !!force,
|
||||
}, function(err, status) {
|
||||
if (err) {} // TODO
|
||||
$scope.updatingStatus = false;
|
||||
if (err) {
|
||||
$scope.status = null;
|
||||
$scope.updateStatusError = true;
|
||||
return;
|
||||
}
|
||||
$scope.status = status;
|
||||
$scope.updating = false;
|
||||
});
|
||||
})
|
||||
};
|
||||
|
||||
$scope.updateTxHistory = function() {
|
||||
|
||||
if ($scope.updatingTxHistory) return;
|
||||
|
||||
$scope.updatingTxHistory = true;
|
||||
$scope.updateTxHistoryError = false;
|
||||
$scope.updatingTxHistoryProgress = null;
|
||||
|
||||
var progressFn = function(txs) {
|
||||
$scope.updatingTxHistoryProgress = txs ? txs.length : 0;
|
||||
completeTxHistory = txs;
|
||||
$scope.showHistory();
|
||||
$scope.$digest();
|
||||
};
|
||||
|
||||
$timeout(function() {
|
||||
walletService.getTxHistory(wallet, {
|
||||
progressFn: progressFn,
|
||||
}, function(err, txHistory) {
|
||||
$scope.updatingTxHistory = false;
|
||||
if (err) {
|
||||
$scope.txHistory = null;
|
||||
$scope.updateTxHistoryError = true;
|
||||
return;
|
||||
}
|
||||
completeTxHistory = txHistory;
|
||||
|
||||
$scope.showHistory();
|
||||
$scope.$apply();
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
$scope.showHistory = function() {
|
||||
if ($scope.isSearching) {
|
||||
$scope.txHistorySearchResults = filteredTxHistory ? filteredTxHistory.slice(0, (currentTxHistoryPage + 1) * HISTORY_SHOW_LIMIT) : [];
|
||||
$scope.txHistoryShowMore = filteredTxHistory.length > $scope.txHistorySearchResults.length;
|
||||
} else {
|
||||
$scope.txHistory = completeTxHistory ? completeTxHistory.slice(0, (currentTxHistoryPage + 1) * HISTORY_SHOW_LIMIT) : [];
|
||||
$scope.txHistoryShowMore = completeTxHistory.length > $scope.txHistory.length;
|
||||
}
|
||||
};
|
||||
|
||||
$scope.showMore = function() {
|
||||
currentTxHistoryPage++;
|
||||
$scope.showHistory();
|
||||
$scope.$broadcast('scroll.infiniteScrollComplete');
|
||||
};
|
||||
|
||||
$scope.updateAll = function() {
|
||||
$scope.updateStatus(false);
|
||||
$scope.updateTxHistory();
|
||||
}
|
||||
|
||||
$scope.hideToggle = function() {
|
||||
console.log('[walletDetails.js.70:hideToogle:] TODO'); //TODO
|
||||
};
|
||||
|
||||
if (!$stateParams.walletId) {
|
||||
$log.debug('No wallet provided... using the first one');
|
||||
$stateParams.walletId = profileService.getWallets({
|
||||
onlyComplete: true
|
||||
})[0].id;
|
||||
}
|
||||
var currentTxHistoryPage;
|
||||
var completeTxHistory;
|
||||
var wallet;
|
||||
|
||||
$scope.init = function() {
|
||||
currentTxHistoryPage = 0;
|
||||
completeTxHistory = [];
|
||||
|
||||
var wallet = profileService.getWallet($stateParams.walletId);
|
||||
$scope.wallet = wallet;
|
||||
wallet = profileService.getWallet($stateParams.walletId);
|
||||
$scope.wallet = wallet;
|
||||
$scope.requiresMultipleSignatures = wallet.credentials.m > 1;
|
||||
$scope.newTx = false;
|
||||
|
||||
$scope.updateAll();
|
||||
};
|
||||
|
||||
if (wallet) {
|
||||
walletService.getStatus(wallet, {}, function(err, status) {
|
||||
console.log('*** [walletDetails.js ln89] status:', status); // TODO
|
||||
if (err) {} // TODO
|
||||
$scope.status = status;
|
||||
});
|
||||
walletService.getHistory(wallet, {}, function(err, txHistory) {
|
||||
console.log('*** [walletDetails.js ln93] txHistory:', txHistory); // TODO
|
||||
if (err) {} // TODO
|
||||
$scope.txHistory = txHistory;
|
||||
});
|
||||
}
|
||||
});
|
||||
|
|
1072
src/js/routes.js
1072
src/js/routes.js
File diff suppressed because it is too large
Load Diff
|
@ -3,17 +3,6 @@
|
|||
angular.module('copayApp.services').factory('txFormatService', function(bwcService, rateService, configService, lodash) {
|
||||
var root = {};
|
||||
|
||||
|
||||
// // RECEIVE
|
||||
// // Check address
|
||||
// root.isUsed(wallet.walletId, balance.byAddress, function(err, used) {
|
||||
// if (used) {
|
||||
// $log.debug('Address used. Creating new');
|
||||
// $rootScope.$emit('Local/AddressIsUsed');
|
||||
// }
|
||||
// });
|
||||
//
|
||||
|
||||
root.Utils = bwcService.getUtils();
|
||||
|
||||
|
||||
|
|
|
@ -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, gettextCatalog, bwcError, $ionicPopup, fingerprintService, ongoingProcess, gettext, $rootScope, txStatus, txFormatService, $ionicModal) {
|
||||
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) {
|
||||
// DO NOT INCLUDE STORAGE HERE ^^
|
||||
//
|
||||
//
|
||||
|
@ -12,7 +12,7 @@ angular.module('copayApp.services').factory('walletService', function($log, $tim
|
|||
root.WALLET_STATUS_MAX_TRIES = 7;
|
||||
root.WALLET_STATUS_DELAY_BETWEEN_TRIES = 1.4 * 1000;
|
||||
root.SOFT_CONFIRMATION_LIMIT = 12;
|
||||
root.HISTORY_SHOW_LIMIT = 10;
|
||||
root.SAFE_CONFIRMATIONS = 6;
|
||||
|
||||
// UI Related
|
||||
root.openStatusModal = function(type, txp, cb) {
|
||||
|
@ -31,8 +31,15 @@ angular.module('copayApp.services').factory('walletService', function($log, $tim
|
|||
});
|
||||
};
|
||||
|
||||
|
||||
|
||||
// // RECEIVE
|
||||
// // Check address
|
||||
// root.isUsed(wallet.walletId, balance.byAddress, function(err, used) {
|
||||
// if (used) {
|
||||
// $log.debug('Address used. Creating new');
|
||||
// $rootScope.$emit('Local/AddressIsUsed');
|
||||
// }
|
||||
// });
|
||||
//
|
||||
|
||||
var _signWithLedger = function(wallet, txp, cb) {
|
||||
$log.info('Requesting Ledger Chrome app to sign the transaction');
|
||||
|
@ -154,12 +161,12 @@ angular.module('copayApp.services').factory('walletService', function($log, $tim
|
|||
cache.unitName = config.unitName;
|
||||
|
||||
//STR
|
||||
cache.totalBalanceStr = root.formatAmount(cache.totalBalanceSat) + ' ' + cache.unitName;
|
||||
cache.lockedBalanceStr = root.formatAmount(cache.lockedBalanceSat) + ' ' + cache.unitName;
|
||||
cache.availableBalanceStr = root.formatAmount(cache.availableBalanceSat) + ' ' + cache.unitName;
|
||||
cache.totalBalanceStr = txFormatService.formatAmount(cache.totalBalanceSat) + ' ' + cache.unitName;
|
||||
cache.lockedBalanceStr = txFormatService.formatAmount(cache.lockedBalanceSat) + ' ' + cache.unitName;
|
||||
cache.availableBalanceStr = txFormatService.formatAmount(cache.availableBalanceSat) + ' ' + cache.unitName;
|
||||
|
||||
if (cache.pendingAmount) {
|
||||
cache.pendingAmountStr = root.formatAmount(cache.pendingAmount) + ' ' + cache.unitName;
|
||||
cache.pendingAmountStr = txFormatService.formatAmount(cache.pendingAmount) + ' ' + cache.unitName;
|
||||
} else {
|
||||
cache.pendingAmountStr = null;
|
||||
}
|
||||
|
@ -229,13 +236,7 @@ angular.module('copayApp.services').factory('walletService', function($log, $tim
|
|||
});
|
||||
};
|
||||
|
||||
_getStatus(walletStatusHash(), 0, function(err, status) {
|
||||
if (err) {
|
||||
root.handleError(err);
|
||||
return cb(err);
|
||||
}
|
||||
return cb(null, status);
|
||||
})
|
||||
_getStatus(walletStatusHash(), 0, cb);
|
||||
};
|
||||
|
||||
var getSavedTxs = function(walletId, cb) {
|
||||
|
@ -300,8 +301,8 @@ angular.module('copayApp.services').factory('walletService', function($log, $tim
|
|||
if (tx.time > now)
|
||||
tx.time = now;
|
||||
|
||||
if (tx.confirmations >= SAFE_CONFIRMATIONS) {
|
||||
tx.safeConfirmed = SAFE_CONFIRMATIONS + '+';
|
||||
if (tx.confirmations >= root.SAFE_CONFIRMATIONS) {
|
||||
tx.safeConfirmed = root.SAFE_CONFIRMATIONS + '+';
|
||||
} else {
|
||||
tx.safeConfirmed = false;
|
||||
wallet.hasUnsafeConfirmed = true;
|
||||
|
@ -323,13 +324,15 @@ angular.module('copayApp.services').factory('walletService', function($log, $tim
|
|||
return ret;
|
||||
};
|
||||
|
||||
var updateLocalTxHistory = function(wallet, cb) {
|
||||
var updateLocalTxHistory = function(wallet, progressFn, cb) {
|
||||
var FIRST_LIMIT = 5;
|
||||
var LIMIT = 50;
|
||||
var requestLimit = FIRST_LIMIT;
|
||||
var walletId = wallet.credentials.walletId;
|
||||
var config = configService.getSync().wallet.settings;
|
||||
|
||||
progressFn = progressFn || function() {};
|
||||
|
||||
var fixTxsUnit = function(txs) {
|
||||
if (!txs || !txs[0] || !txs[0].amountStr) return;
|
||||
|
||||
|
@ -359,43 +362,27 @@ angular.module('copayApp.services').factory('walletService', function($log, $tim
|
|||
|
||||
|
||||
// First update
|
||||
if (walletId == wallet.credentials.walletId) {
|
||||
wallet.completeHistory = txsFromLocal;
|
||||
}
|
||||
wallet.completeHistory = txsFromLocal;
|
||||
|
||||
if (wallet.historyUpdateInProgress)
|
||||
return;
|
||||
|
||||
wallet.historyUpdateInProgress = true;
|
||||
|
||||
function getNewTxs(newTxs, skip, i_cb) {
|
||||
function getNewTxs(newTxs, skip, cb) {
|
||||
getTxsFromServer(wallet, skip, endingTxid, requestLimit, function(err, res, shouldContinue) {
|
||||
if (err) return i_cb(err);
|
||||
if (err) return cb(err);
|
||||
|
||||
newTxs = newTxs.concat(processNewTxs(wallet, lodash.compact(res)));
|
||||
|
||||
progressFn(newTxs);
|
||||
|
||||
newTxs = newTxs.concat(lodash.compact(res));
|
||||
skip = skip + requestLimit;
|
||||
|
||||
$log.debug('Syncing TXs. Got:' + newTxs.length + ' Skip:' + skip, ' EndingTxid:', endingTxid, ' Continue:', shouldContinue);
|
||||
|
||||
if (!shouldContinue) {
|
||||
newTxs = processNewTxs(wallet, newTxs);
|
||||
$log.debug('Finished Sync: New / soft confirmed Txs: ' + newTxs.length);
|
||||
return i_cb(null, newTxs);
|
||||
return cb(null, newTxs);
|
||||
}
|
||||
|
||||
requestLimit = LIMIT;
|
||||
getNewTxs(newTxs, skip, i_cb);
|
||||
|
||||
// Progress update
|
||||
if (walletId == wallet.credentials.walletId) {
|
||||
wallet.txProgress = newTxs.length;
|
||||
if (wallet.completeHistory < FIRST_LIMIT && txsFromLocal.length == 0) {
|
||||
$log.debug('Showing partial history');
|
||||
var newHistory = processNewTxs(wallet, newTxs);
|
||||
newHistory = lodash.compact(newHistory.concat(confirmedTxs));
|
||||
wallet.completeHistory = newHistory;
|
||||
}
|
||||
}
|
||||
getNewTxs(newTxs, skip, cb);
|
||||
});
|
||||
};
|
||||
|
||||
|
@ -456,10 +443,8 @@ angular.module('copayApp.services').factory('walletService', function($log, $tim
|
|||
};
|
||||
|
||||
|
||||
root.getHistory = function(wallet, opts, cb) {
|
||||
root.getTxHistory = function(wallet, opts, cb) {
|
||||
opts = opts || {};
|
||||
opts.skip = opts.skip || 0;
|
||||
opts.limit = opts.limit || root.HISTORY_SHOW_LIMIT;
|
||||
|
||||
var walletId = wallet.credentials.walletId;
|
||||
|
||||
|
@ -467,10 +452,9 @@ angular.module('copayApp.services').factory('walletService', function($log, $tim
|
|||
|
||||
$log.debug('Updating Transaction History');
|
||||
|
||||
updateLocalTxHistory(wallet, function(err) {
|
||||
updateLocalTxHistory(wallet, opts.progressFn, function(err) {
|
||||
if (err) return cb(err);
|
||||
var txs = wallet.completeHistory ? wallet.completeHistory.slice(opts.skip, opts.limit) : null;
|
||||
return cb(err, txs);
|
||||
return cb(err, wallet.completeHistory);
|
||||
});
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue