mirror of https://github.com/BTCPrivate/copay.git
Improves performance on tab-home, refactor of walletDetails, bug fixes
This commit is contained in:
parent
4069998930
commit
28a53ea0c6
|
@ -1,5 +1,5 @@
|
|||
<ion-modal-view id="txp-details" ng-controller="txpDetailsController" ng-init="init()">
|
||||
<ion-header-bar align-title="center" class="bar-royal">
|
||||
<ion-header-bar align-title="center" class="bar-royal" ng-style="{'background-color': wallet.color}">
|
||||
<button class="button button-clear" ng-click="close()">
|
||||
Close
|
||||
</button>
|
||||
|
|
|
@ -69,10 +69,11 @@
|
|||
<span ng-if="!wallet.isComplete()" class="assertive" translate>
|
||||
Incomplete
|
||||
</span>
|
||||
<div ng-if="wallet.isComplete()">
|
||||
<span ng-if="wallet.isComplete()">
|
||||
<span ng-if="!wallet.balanceHidden">{{wallet.status.availableBalanceStr}}</span>
|
||||
<span ng-if="wallet.balanceHidden" translate>[Balance Hidden]</span>
|
||||
</div>
|
||||
</span>
|
||||
|
||||
</p>
|
||||
<i class="icon nav-item-arrow-right"></i>
|
||||
</a>
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<ion-view id="walletDetails">
|
||||
<ion-nav-bar ng-style="{'background-color': walletDetailsColor}">
|
||||
<ion-nav-title>{{walletDetailsName}}</ion-nav-title>
|
||||
<ion-nav-bar ng-style="{'background-color': wallet.color}">
|
||||
<ion-nav-title>{{wallet.name}}</ion-nav-title>
|
||||
<ion-nav-back-button>
|
||||
</ion-nav-back-button>
|
||||
<ion-nav-buttons side="secondary">
|
||||
|
@ -14,14 +14,13 @@
|
|||
<div ng-style="{'background-color':wallet.color}" class="amount">
|
||||
<div ng-if="!notAuthorized && !updatingStatus">
|
||||
|
||||
<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 ng-show="updateStatusError">
|
||||
<a class="button button-outline button-light button-small" ng-click='update()' translate>Tap to retry</a>
|
||||
</div>
|
||||
|
||||
<div class="m20t" ng-show="walletNotRegistered" ng-click='recreate()'>
|
||||
<div ng-show="walletNotRegistered">
|
||||
<span class="size-12 db m10b" translate>This wallet is not registered at the given Bitcore Wallet Service (BWS). You can recreate it from the local information.</span>
|
||||
<button class="outline white tiny round" translate>Recreate</button>
|
||||
<a class="button button-outline button-light button-small" ng-click='recreate()' translate>Recreate</a>
|
||||
</div>
|
||||
|
||||
<div ng-show="wallet.walletScanStatus == 'error'" ng-click='retryScan()'>
|
||||
|
@ -30,7 +29,7 @@
|
|||
</div>
|
||||
|
||||
|
||||
<div ng-click='updateAll()' ng-show="!updateStatusError && wallet.walletScanStatus != 'error' && !wallet.balanceHidden" on-hold="hideToggle()">
|
||||
<div ng-click='updateAll(true)' ng-show="!updateStatusError && wallet.walletScanStatus != 'error' && !wallet.balanceHidden" on-hold="hideToggle()">
|
||||
<strong class="size-36">{{status.totalBalanceStr}}</strong>
|
||||
<div class="size-14 amount-alternative" ng-if="status.totalBalanceAlternative">{{status.totalBalanceAlternative}} {{status.alternativeIsoCode}}</div>
|
||||
<div class="size-14" ng-if="status.pendingAmount">
|
||||
|
@ -46,10 +45,10 @@
|
|||
</div>
|
||||
</div>
|
||||
<div ng-if="updatingStatus">
|
||||
<div class="size-36">
|
||||
<strong>...</strong>
|
||||
</div>
|
||||
<div class="size-36">
|
||||
<strong>...</strong>
|
||||
</div>
|
||||
</div>
|
||||
</div> <!-- amount -->
|
||||
|
||||
<div class="wallet-info">
|
||||
|
@ -108,8 +107,8 @@
|
|||
<!-- Transactions -->
|
||||
|
||||
<div class="oh pr m20t text-gray size-12 text-center"
|
||||
ng-show="!txHistory[0] && !updatingTxHistory && !txHistoryError && !updateStatusError && !notAuthorized"
|
||||
translate>No transactions yet {{status.totalBalanceStr}}
|
||||
ng-show="!txHistory[0] && !updatingTxHistory && !txHistoryError && !updateStatusError && !notAuthorized" translate>
|
||||
No transactions yet
|
||||
</div>
|
||||
|
||||
<div ng-show="updatingTxHistory && updatingTxHistoryProgress>5" class="updatingHistory">
|
||||
|
@ -124,20 +123,6 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<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">
|
||||
</div>
|
||||
<div class="m10t" style="background:#eee; width: 8em; margin-left: 52px; line-height:0.6em">
|
||||
<span> </span>
|
||||
</div>
|
||||
<div style="margin-top:5px; background:#eee; width: 6em; margin-left: 52px; line-height:0.6em">
|
||||
<span> </span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="card list" ng-show="txHistory[0]">
|
||||
<div class="item" ng-repeat="btx in txHistory track by btx.txid" ng-click="openTxModal(btx)">
|
||||
<span class="item-note text-right">
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
angular.module('copayApp.controllers').controller('tabHomeController',
|
||||
function($rootScope, $timeout, $scope, $state, $stateParams, $ionicModal, $ionicScrollDelegate, gettextCatalog, lodash, popupService, ongoingProcess, profileService, walletService, configService, $log, platformInfo, storageService, txpModalService, $window, bitpayCardService) {
|
||||
var wallet;
|
||||
var listeners = [];
|
||||
$scope.externalServices = {};
|
||||
$scope.bitpayCardEnabled = true; // TODO
|
||||
$scope.openTxpModal = txpModalService.open;
|
||||
|
@ -81,7 +82,7 @@ angular.module('copayApp.controllers').controller('tabHomeController',
|
|||
});
|
||||
};
|
||||
|
||||
function updateTxps() {
|
||||
var updateTxps = function() {
|
||||
profileService.getTxps({
|
||||
limit: 3
|
||||
}, function(err, txps, n) {
|
||||
|
@ -90,12 +91,11 @@ angular.module('copayApp.controllers').controller('tabHomeController',
|
|||
$scope.txpsN = n;
|
||||
$timeout(function() {
|
||||
$ionicScrollDelegate.resize();
|
||||
$scope.$apply();
|
||||
}, 10);
|
||||
}, 100);
|
||||
})
|
||||
};
|
||||
|
||||
$scope.updateAllWallets = function() {
|
||||
var updateAllWallets = function() {
|
||||
$scope.wallets = profileService.getWallets();
|
||||
if (lodash.isEmpty($scope.wallets)) return;
|
||||
|
||||
|
@ -123,7 +123,7 @@ angular.module('copayApp.controllers').controller('tabHomeController',
|
|||
limit: 3
|
||||
}, function(err, n) {
|
||||
if (err) {
|
||||
console.log('[tab-home.js.35:err:]', $log.error(err)); //TODO
|
||||
$log.error(err);
|
||||
return;
|
||||
}
|
||||
$scope.fetchingNotifications = false;
|
||||
|
@ -132,16 +132,16 @@ angular.module('copayApp.controllers').controller('tabHomeController',
|
|||
$timeout(function() {
|
||||
$ionicScrollDelegate.resize();
|
||||
$scope.$apply();
|
||||
}, 10);
|
||||
}, 100);
|
||||
|
||||
})
|
||||
};
|
||||
|
||||
$scope.updateWallet = function(wallet) {
|
||||
var updateWallet = function(wallet) {
|
||||
$log.debug('Updating wallet:' + wallet.name)
|
||||
walletService.getStatus(wallet, {}, function(err, status) {
|
||||
if (err) {
|
||||
$log.error(err); //TODO
|
||||
$log.error(err);
|
||||
return;
|
||||
}
|
||||
wallet.status = status;
|
||||
|
@ -155,11 +155,11 @@ angular.module('copayApp.controllers').controller('tabHomeController',
|
|||
}, function(err, notifications) {
|
||||
$scope.fetchingNotifications = false;
|
||||
if (err) {
|
||||
console.log('[tab-home.js.35:err:]', $log.error(err)); //TODO
|
||||
$log.error(err);
|
||||
return;
|
||||
}
|
||||
$scope.notifications = notifications;
|
||||
})
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
|
@ -172,7 +172,7 @@ angular.module('copayApp.controllers').controller('tabHomeController',
|
|||
});
|
||||
};
|
||||
|
||||
$scope.nextStep = function() {
|
||||
var nextStep = function() {
|
||||
lodash.each(['AmazonGiftCards', 'BitpayCard', 'BuyAndSell'], function(service) {
|
||||
storageService.getNextStep(service, function(err, value) {
|
||||
$scope.externalServices[service] = value ? true : false;
|
||||
|
@ -190,24 +190,6 @@ angular.module('copayApp.controllers').controller('tabHomeController',
|
|||
}, 10);
|
||||
};
|
||||
|
||||
var listeners = [
|
||||
$rootScope.$on('bwsEvent', function(e, walletId, type, n) {
|
||||
var wallet = profileService.getWallet(walletId);
|
||||
$scope.updateWallet(wallet);
|
||||
}),
|
||||
$rootScope.$on('Local/TxAction', function(e, walletId) {
|
||||
$log.debug('Got action for wallet ' + walletId);
|
||||
var wallet = profileService.getWallet(walletId);
|
||||
$scope.updateWallet(wallet);
|
||||
}),
|
||||
];
|
||||
|
||||
$scope.$on('$destroy', function() {
|
||||
lodash.each(listeners, function(x) {
|
||||
x();
|
||||
});
|
||||
});
|
||||
|
||||
var bitpayCardCache = function() {
|
||||
bitpayCardService.getCacheData(function(err, data) {
|
||||
if (err || lodash.isEmpty(data)) return;
|
||||
|
@ -217,6 +199,21 @@ angular.module('copayApp.controllers').controller('tabHomeController',
|
|||
|
||||
$scope.$on("$ionicView.enter", function(event, data) {
|
||||
$scope.bitpayCard = null;
|
||||
nextStep();
|
||||
updateAllWallets();
|
||||
|
||||
listeners = [
|
||||
$rootScope.$on('bwsEvent', function(e, walletId, type, n) {
|
||||
var wallet = profileService.getWallet(walletId);
|
||||
updateWallet(wallet);
|
||||
}),
|
||||
$rootScope.$on('Local/TxAction', function(e, walletId) {
|
||||
$log.debug('Got action for wallet ' + walletId);
|
||||
var wallet = profileService.getWallet(walletId);
|
||||
updateWallet(wallet);
|
||||
})
|
||||
];
|
||||
|
||||
configService.whenAvailable(function() {
|
||||
var config = configService.getSync();
|
||||
var isWindowsPhoneApp = platformInfo.isWP && platformInfo.isCordova;
|
||||
|
@ -230,7 +227,12 @@ angular.module('copayApp.controllers').controller('tabHomeController',
|
|||
|
||||
if ($scope.bitpayCardEnabled) bitpayCardCache();
|
||||
});
|
||||
$scope.nextStep();
|
||||
$scope.updateAllWallets();
|
||||
});
|
||||
|
||||
$scope.$on("$ionicView.leave", function(event, data) {
|
||||
lodash.each(listeners, function(x) {
|
||||
x();
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
|
|
@ -1,15 +1,13 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copayApp.controllers').controller('walletDetailsController', function($scope, $rootScope, $interval, $timeout, $filter, $log, $ionicModal, $ionicPopover, $state, $stateParams, profileService, lodash, configService, gettextCatalog, platformInfo, walletService, txpModalService, externalLinkService, popupService) {
|
||||
var isCordova = platformInfo.isCordova;
|
||||
var isWP = platformInfo.isWP;
|
||||
var isAndroid = platformInfo.isAndroid;
|
||||
var isChromeApp = platformInfo.isChromeApp;
|
||||
|
||||
var HISTORY_SHOW_LIMIT = 10;
|
||||
var currentTxHistoryPage;
|
||||
var wallet;
|
||||
var currentTxHistoryPage = 0;
|
||||
var listeners = [];
|
||||
$scope.txps = [];
|
||||
$scope.completeTxHistory = [];
|
||||
$scope.openTxpModal = txpModalService.open;
|
||||
|
||||
$scope.openExternalLink = function(url, target) {
|
||||
externalLinkService.open(url, target);
|
||||
|
@ -24,7 +22,7 @@ angular.module('copayApp.controllers').controller('walletDetailsController', fun
|
|||
// fee: 1000,
|
||||
// createdOn: new Date() / 1000,
|
||||
// outputs: [],
|
||||
// wallet: wallet
|
||||
// wallet: $scope.wallet
|
||||
// };
|
||||
//
|
||||
// function addOutput(n) {
|
||||
|
@ -44,13 +42,12 @@ angular.module('copayApp.controllers').controller('walletDetailsController', fun
|
|||
$scope.txps = lodash.sortBy(txps, 'createdOn').reverse();
|
||||
};
|
||||
|
||||
|
||||
$scope.updateStatus = function(force) {
|
||||
var updateStatus = function(force) {
|
||||
$scope.updatingStatus = true;
|
||||
$scope.updateStatusError = false;
|
||||
$scope.walletNotRegistered = false;
|
||||
|
||||
walletService.getStatus(wallet, {
|
||||
walletService.getStatus($scope.wallet, {
|
||||
force: !!force,
|
||||
}, function(err, status) {
|
||||
$scope.updatingStatus = false;
|
||||
|
@ -74,29 +71,8 @@ angular.module('copayApp.controllers').controller('walletDetailsController', fun
|
|||
});
|
||||
};
|
||||
|
||||
|
||||
$scope.openTxpModal = txpModalService.open;
|
||||
|
||||
var listeners = [
|
||||
$rootScope.$on('bwsEvent', function(e, walletId) {
|
||||
if (walletId == wallet.id)
|
||||
$scope.updateStatus();
|
||||
}),
|
||||
$rootScope.$on('Local/TxAction', function(e, walletId) {
|
||||
if (walletId == wallet.id)
|
||||
$scope.updateStatus();
|
||||
}),
|
||||
];
|
||||
|
||||
$scope.$on('$destroy', function() {
|
||||
lodash.each(listeners, function(x) {
|
||||
x();
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
$scope.openSearchModal = function() {
|
||||
$scope.color = wallet.color;
|
||||
$scope.color = $scope.wallet.color;
|
||||
|
||||
$ionicModal.fromTemplateUrl('views/modals/search.html', {
|
||||
scope: $scope,
|
||||
|
@ -113,7 +89,7 @@ angular.module('copayApp.controllers').controller('walletDetailsController', fun
|
|||
|
||||
$scope.openTxModal = function(btx) {
|
||||
$scope.btx = lodash.cloneDeep(btx);
|
||||
$scope.walletId = wallet.id;
|
||||
$scope.walletId = $scope.wallet.id;
|
||||
$ionicModal.fromTemplateUrl('views/modals/tx-details.html', {
|
||||
scope: $scope
|
||||
}).then(function(modal) {
|
||||
|
@ -123,24 +99,24 @@ angular.module('copayApp.controllers').controller('walletDetailsController', fun
|
|||
};
|
||||
|
||||
$scope.recreate = function() {
|
||||
walletService.recreate(wallet, function(err) {
|
||||
walletService.recreate($scope.wallet, function(err) {
|
||||
$scope.init();
|
||||
if (err) return;
|
||||
$timeout(function() {
|
||||
walletService.startScan(wallet, function() {
|
||||
walletService.startScan($scope.wallet, function() {
|
||||
$scope.$apply();
|
||||
});
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
$scope.updateTxHistory = function(cb) {
|
||||
var updateTxHistory = function(cb) {
|
||||
if (!cb) cb = function() {};
|
||||
if ($scope.updatingTxHistory) return;
|
||||
|
||||
$scope.updatingTxHistory = true;
|
||||
$scope.updateTxHistoryError = false;
|
||||
$scope.updatingTxHistoryProgress = null;
|
||||
$scope.updatingTxHistoryProgress = 0;
|
||||
|
||||
var progressFn = function(txs) {
|
||||
$scope.updatingTxHistoryProgress = txs ? txs.length : 0;
|
||||
|
@ -148,11 +124,11 @@ angular.module('copayApp.controllers').controller('walletDetailsController', fun
|
|||
$scope.showHistory();
|
||||
$timeout(function() {
|
||||
$scope.$apply();
|
||||
}, 1);
|
||||
});
|
||||
};
|
||||
|
||||
$timeout(function() {
|
||||
walletService.getTxHistory(wallet, {
|
||||
walletService.getTxHistory($scope.wallet, {
|
||||
progressFn: progressFn,
|
||||
}, function(err, txHistory) {
|
||||
$scope.updatingTxHistory = false;
|
||||
|
@ -162,12 +138,10 @@ angular.module('copayApp.controllers').controller('walletDetailsController', fun
|
|||
return;
|
||||
}
|
||||
$scope.completeTxHistory = txHistory;
|
||||
|
||||
$scope.showHistory();
|
||||
|
||||
$timeout(function() {
|
||||
$scope.$apply();
|
||||
}, 1);
|
||||
});
|
||||
return cb();
|
||||
});
|
||||
});
|
||||
|
@ -186,51 +160,39 @@ angular.module('copayApp.controllers').controller('walletDetailsController', fun
|
|||
$scope.$broadcast('scroll.infiniteScrollComplete');
|
||||
};
|
||||
|
||||
$scope.updateAll = function(cb) {
|
||||
$scope.updateStatus(false);
|
||||
$scope.updateTxHistory(cb);
|
||||
$scope.updateAll = function(force, cb) {
|
||||
updateStatus(force);
|
||||
updateTxHistory(cb);
|
||||
};
|
||||
|
||||
$scope.hideToggle = function() {
|
||||
profileService.toggleHideBalanceFlag(wallet.credentials.walletId, function(err) {
|
||||
profileService.toggleHideBalanceFlag($scope.wallet.credentials.walletId, function(err) {
|
||||
if (err) $log.error(err);
|
||||
});
|
||||
};
|
||||
|
||||
$scope.$on("$ionicView.beforeEnter", function(event, data){
|
||||
currentTxHistoryPage = 0;
|
||||
$scope.completeTxHistory = [];
|
||||
|
||||
wallet = profileService.getWallet($stateParams.walletId);
|
||||
$scope.wallet = profileService.getWallet(data.stateParams.walletId);
|
||||
$scope.requiresMultipleSignatures = $scope.wallet.credentials.m > 1;
|
||||
|
||||
/* Set color for header bar */
|
||||
$scope.walletDetailsColor = wallet.color;
|
||||
$scope.walletDetailsName = wallet.name;
|
||||
$scope.wallet = wallet;
|
||||
$scope.updateAll();
|
||||
|
||||
$scope.requiresMultipleSignatures = wallet.credentials.m > 1;
|
||||
$scope.newTx = false;
|
||||
listeners = [
|
||||
$rootScope.$on('bwsEvent', function(e, walletId) {
|
||||
if (walletId == $scope.wallet.id)
|
||||
updateStatus();
|
||||
}),
|
||||
$rootScope.$on('Local/TxAction', function(e, walletId) {
|
||||
if (walletId == $scope.wallet.id)
|
||||
updateStatus();
|
||||
}),
|
||||
];
|
||||
});
|
||||
|
||||
$scope.updateAll(function() {
|
||||
if ($stateParams.txid) {
|
||||
var tx = lodash.find($scope.completeTxHistory, {
|
||||
txid: $stateParams.txid
|
||||
});
|
||||
if (tx) {
|
||||
$scope.openTxModal(tx);
|
||||
} else {
|
||||
popupService.showAlert(null, gettextCatalog.getString('TX not available'));
|
||||
}
|
||||
} else if ($stateParams.txpId) {
|
||||
var txp = lodash.find($scope.txps, {
|
||||
id: $stateParams.txpId
|
||||
});
|
||||
if (txp) {
|
||||
$scope.openTxpModal(txp);
|
||||
} else {
|
||||
popupService.showAlert(null, gettextCatalog.getString('Proposal not longer available'));
|
||||
}
|
||||
}
|
||||
$scope.$on("$ionicView.leave", function(event, data) {
|
||||
lodash.each(listeners, function(x) {
|
||||
x();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -157,11 +157,7 @@ angular.module('copayApp').config(function(historicLogProvider, $provide, $logPr
|
|||
controller: 'walletDetailsController',
|
||||
templateUrl: 'views/walletDetails.html'
|
||||
}
|
||||
},
|
||||
params: {
|
||||
txid: null,
|
||||
txpId: null,
|
||||
},
|
||||
}
|
||||
})
|
||||
.state('tabs.activity', {
|
||||
url: '/activity',
|
||||
|
|
|
@ -927,9 +927,9 @@ angular.module('copayApp.services')
|
|||
if (x.pendingTxps)
|
||||
txps = txps.concat(x.pendingTxps);
|
||||
});
|
||||
txps = lodash.sortBy(txps, 'pendingForUs', 'createdOn');
|
||||
txps = lodash.compact(lodash.flatten(txps)).slice(0, MAX);
|
||||
var n = txps.length;
|
||||
txps = lodash.sortBy(txps, 'pendingForUs', 'createdOn');
|
||||
txps = lodash.compact(lodash.flatten(txps)).slice(0, opts.limit || MAX);
|
||||
return cb(null, txps, n);
|
||||
};
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
text-align: center;
|
||||
padding: 2rem 1rem 1.5rem 1rem;
|
||||
color: #fff;
|
||||
min-height: 115px;
|
||||
height: 140px;
|
||||
margin-bottom: 10px;
|
||||
|
||||
&-alternative {
|
||||
|
|
Loading…
Reference in New Issue