mirror of https://github.com/BTCPrivate/copay.git
throttle search function
This commit is contained in:
parent
5ca10f777d
commit
71fd35f7c1
|
@ -160,7 +160,7 @@
|
||||||
|
|
||||||
<div class="oh pr" ng-show="index.txHistory[0] || index.txProgress > 5">
|
<div class="oh pr" ng-show="index.txHistory[0] || index.txProgress > 5">
|
||||||
<ul class="no-bullet m0">
|
<ul class="no-bullet m0">
|
||||||
<li ng-click="index.isSearching = true;" ng-show="!index.isSearching" >
|
<li ng-click="index.startSearch()" ng-show="!index.isSearching" >
|
||||||
<h4 class="title m0" translate>Activity
|
<h4 class="title m0" translate>Activity
|
||||||
<i class="fi-magnifying-glass"></i>
|
<i class="fi-magnifying-glass"></i>
|
||||||
</h4>
|
</h4>
|
||||||
|
@ -206,6 +206,7 @@
|
||||||
<form>
|
<form>
|
||||||
<input name="search"
|
<input name="search"
|
||||||
type="search"
|
type="search"
|
||||||
|
ng-change="index.updateSearchInput(search)"
|
||||||
placeholder="{{'Search transactions' | translate}}"
|
placeholder="{{'Search transactions' | translate}}"
|
||||||
ng-model="search">
|
ng-model="search">
|
||||||
</input>
|
</input>
|
||||||
|
@ -213,10 +214,10 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="small-1 columns">
|
<div class="small-1 columns">
|
||||||
<a ng-click="index.isSearching = false" translate>Cancel</a>
|
<a ng-click="index.cancelSearch()" translate>Cancel</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div ng-repeat="btx in index.txHistoryToShow(search) track by btx.txid"
|
<div ng-repeat="btx in index.txHistoryToList track by btx.txid"
|
||||||
ng-click="home.openTxModal(btx)"
|
ng-click="home.openTxModal(btx)"
|
||||||
class="row collapse last-transactions-content">
|
class="row collapse last-transactions-content">
|
||||||
<div class="large-6 medium-6 small-6 columns size-14">
|
<div class="large-6 medium-6 small-6 columns size-14">
|
||||||
|
|
|
@ -4,7 +4,6 @@ angular.module('copayApp.controllers').controller('indexController', function($r
|
||||||
var self = this;
|
var self = this;
|
||||||
var SOFT_CONFIRMATION_LIMIT = 12;
|
var SOFT_CONFIRMATION_LIMIT = 12;
|
||||||
var errors = bwcService.getErrors();
|
var errors = bwcService.getErrors();
|
||||||
<<<<<<< 0b48a2e2f3178bc3dd4062c7c17fe59e89554285
|
|
||||||
var historyUpdateInProgress = {};
|
var historyUpdateInProgress = {};
|
||||||
|
|
||||||
var ret = {};
|
var ret = {};
|
||||||
|
@ -19,28 +18,6 @@ angular.module('copayApp.controllers').controller('indexController', function($r
|
||||||
ret.prevState = 'walletHome';
|
ret.prevState = 'walletHome';
|
||||||
|
|
||||||
ret.menu = [{
|
ret.menu = [{
|
||||||
=======
|
|
||||||
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';
|
|
||||||
self.isSearching = false;
|
|
||||||
|
|
||||||
function strip(number) {
|
|
||||||
return (parseFloat(number.toPrecision(12)));
|
|
||||||
};
|
|
||||||
|
|
||||||
self.goHome = function() {
|
|
||||||
go.walletHome();
|
|
||||||
};
|
|
||||||
|
|
||||||
self.menu = [{
|
|
||||||
>>>>>>> refactor
|
|
||||||
'title': gettext('Receive'),
|
'title': gettext('Receive'),
|
||||||
'icon': {
|
'icon': {
|
||||||
false: 'icon-receive',
|
false: 'icon-receive',
|
||||||
|
@ -396,7 +373,7 @@ angular.module('copayApp.controllers').controller('indexController', function($r
|
||||||
|
|
||||||
self.setSpendUnconfirmed = function(spendUnconfirmed) {
|
self.setSpendUnconfirmed = function(spendUnconfirmed) {
|
||||||
self.spendUnconfirmed = spendUnconfirmed || configService.getSync().wallet.spendUnconfirmed;
|
self.spendUnconfirmed = spendUnconfirmed || configService.getSync().wallet.spendUnconfirmed;
|
||||||
};
|
};
|
||||||
|
|
||||||
self.updateBalance = function() {
|
self.updateBalance = function() {
|
||||||
var fc = profileService.focusedClient;
|
var fc = profileService.focusedClient;
|
||||||
|
@ -918,6 +895,9 @@ angular.module('copayApp.controllers').controller('indexController', function($r
|
||||||
if (walletId == profileService.focusedClient.credentials.walletId) {
|
if (walletId == profileService.focusedClient.credentials.walletId) {
|
||||||
self.completeHistory = newHistory;
|
self.completeHistory = newHistory;
|
||||||
self.setCompactTxHistory();
|
self.setCompactTxHistory();
|
||||||
|
self.txHistory = newHistory.slice(0, self.historyShowLimit);
|
||||||
|
self.historyShowMore = newHistory.length > self.historyShowLimit;
|
||||||
|
self.txHistoryToList = self.txHistory;
|
||||||
}
|
}
|
||||||
|
|
||||||
return storageService.setTxHistory(JSON.stringify(newHistory), walletId, function() {
|
return storageService.setTxHistory(JSON.stringify(newHistory), walletId, function() {
|
||||||
|
@ -932,6 +912,7 @@ angular.module('copayApp.controllers').controller('indexController', function($r
|
||||||
self.showMore = function() {
|
self.showMore = function() {
|
||||||
$timeout(function() {
|
$timeout(function() {
|
||||||
self.txHistory = self.completeHistory.slice(0, self.nextTxHistory);
|
self.txHistory = self.completeHistory.slice(0, self.nextTxHistory);
|
||||||
|
self.txHistoryToList = self.txHistory;
|
||||||
$log.debug('Total txs: ', self.txHistory.length + '/' + self.completeHistory.length);
|
$log.debug('Total txs: ', self.txHistory.length + '/' + self.completeHistory.length);
|
||||||
self.nextTxHistory += self.historyShowMoreLimit;
|
self.nextTxHistory += self.historyShowMoreLimit;
|
||||||
if (self.txHistory.length >= self.completeHistory.length)
|
if (self.txHistory.length >= self.completeHistory.length)
|
||||||
|
@ -939,11 +920,25 @@ angular.module('copayApp.controllers').controller('indexController', function($r
|
||||||
}, 100);
|
}, 100);
|
||||||
};
|
};
|
||||||
|
|
||||||
self.txHistoryToShow = function(search) {
|
self.startSearch = function(){
|
||||||
|
self.isSearching = true;
|
||||||
|
self.txHistoryToList = [];
|
||||||
|
}
|
||||||
|
|
||||||
|
self.cancelSearch = function(){
|
||||||
|
self.isSearching = false
|
||||||
|
self.txHistoryToList = self.txHistory;
|
||||||
|
}
|
||||||
|
|
||||||
|
self.updateSearchInput = function(search){
|
||||||
|
self.search = search;
|
||||||
|
self.throttleSearch();
|
||||||
|
}
|
||||||
|
|
||||||
|
self.throttleSearch = lodash.throttle(function() {
|
||||||
|
|
||||||
function filter(search) {
|
function filter(search) {
|
||||||
var result = [];
|
var result = [];
|
||||||
|
|
||||||
function formatDate(date) {
|
function formatDate(date) {
|
||||||
var day = ('0' + date.getDate()).slice(-2).toString();
|
var day = ('0' + date.getDate()).slice(-2).toString();
|
||||||
var month = ('0' + (date.getMonth() + 1)).slice(-2).toString();
|
var month = ('0' + (date.getMonth() + 1)).slice(-2).toString();
|
||||||
|
@ -965,12 +960,12 @@ angular.module('copayApp.controllers').controller('indexController', function($r
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
|
|
||||||
if (!self.isSearching) {
|
self.txHistoryToList = filter(self.search);
|
||||||
return self.txHistory;
|
$timeout(function() {
|
||||||
} else {
|
$rootScope.$apply();
|
||||||
return filter(search);;
|
});
|
||||||
}
|
|
||||||
}
|
},1000);
|
||||||
|
|
||||||
self.getTxsFromServer = function(client, skip, endingTxid, limit, cb) {
|
self.getTxsFromServer = function(client, skip, endingTxid, limit, cb) {
|
||||||
var res = [];
|
var res = [];
|
||||||
|
|
Loading…
Reference in New Issue