+
Activity
-
HISTORY_SHOW_LIMIT) $scope.txHistoryShowMore = true;
+ else $scope.txHistoryShowMore = false;
+
+ return $scope.filteredTxHistory;
+ };
+ $scope.txHistorySearchResults = filter(search).slice(0, HISTORY_SHOW_LIMIT);
+ if (isCordova)
+ window.plugins.toast.showShortBottom(gettextCatalog.getString('Matches: ' + $scope.filteredTxHistory.length));
+ $timeout(function() {
+ $rootScope.$apply();
+ });
+
+ }, 1000);
+
+ $scope.moreSearchResults = function() {
+ currentTxHistoryPage++;
+ $scope.showHistory();
+ $scope.$broadcast('scroll.infiniteScrollComplete');
};
+
+ $scope.showHistory = function() {
+ $scope.txHistorySearchResults = $scope.filteredTxHistory ? $scope.filteredTxHistory.slice(0, (currentTxHistoryPage + 1) * HISTORY_SHOW_LIMIT) : [];
+ $scope.txHistoryShowMore = $scope.filteredTxHistory.length > $scope.txHistorySearchResults.length;
+ };
+
});
diff --git a/src/js/controllers/search.js b/src/js/controllers/search.js
deleted file mode 100644
index 470e9548a..000000000
--- a/src/js/controllers/search.js
+++ /dev/null
@@ -1,88 +0,0 @@
-'use strict';
-
-angular.module('copayApp.controllers').controller('searchController', function($scope, $rootScope, $interval, $timeout, $filter, $log, $ionicModal, $ionicPopover, $ionicNavBarDelegate, $state, $stateParams, $ionicScrollDelegate, bwcError, profileService, lodash, configService, gettext, gettextCatalog, platformInfo, walletService) {
-
- var HISTORY_SHOW_LIMIT = 10;
- var currentTxHistoryPage = 0;
- var wallet;
- var isCordova = platformInfo.isCordova;
- $scope.txHistorySearchResults = [];
- $scope.filteredTxHistory = [];
-
- $scope.cancel = function() {
- $scope.searchModal.hide();
- };
-
- $scope.cancelSearch = function() {
- $scope.txHistorySearchResults = [];
- $scope.filteredTxHistory = [];
- $scope.search = '';
- $scope.currentTxHistoryPage = 0;
- $ionicScrollDelegate.resize();
- }
-
- $scope.updateSearchInput = function(search) {
- if (isCordova)
- window.plugins.toast.hide();
- throttleSearch(search);
- $ionicScrollDelegate.resize();
- }
-
- var throttleSearch = lodash.throttle(function(search) {
-
- function filter(search) {
- $scope.filteredTxHistory = [];
-
- function computeSearchableString(tx) {
- var addrbook = '';
- if (tx.addressTo && self.addressbook && self.addressbook[tx.addressTo]) addrbook = self.addressbook[tx.addressTo] || '';
- var searchableDate = computeSearchableDate(new Date(tx.time * 1000));
- var message = tx.message ? tx.message : '';
- var comment = tx.note ? tx.note.body : '';
- var addressTo = tx.addressTo ? tx.addressTo : '';
- return ((tx.amountStr + message + addressTo + addrbook + searchableDate + comment).toString()).toLowerCase();
- }
-
- function computeSearchableDate(date) {
- var day = ('0' + date.getDate()).slice(-2).toString();
- var month = ('0' + (date.getMonth() + 1)).slice(-2).toString();
- var year = date.getFullYear();
- return [month, day, year].join('/');
- };
-
- if (lodash.isEmpty(search)) {
- $scope.txHistoryShowMore = false;
- return [];
- }
-
- $scope.filteredTxHistory = lodash.filter($scope.completeTxHistory, function(tx) {
- if (!tx.searcheableString) tx.searcheableString = computeSearchableString(tx);
- return lodash.includes(tx.searcheableString, search.toLowerCase());
- });
-
- if ($scope.filteredTxHistory.length > HISTORY_SHOW_LIMIT) $scope.txHistoryShowMore = true;
- else $scope.txHistoryShowMore = false;
-
- return $scope.filteredTxHistory;
- };
- $scope.txHistorySearchResults = filter(search).slice(0, HISTORY_SHOW_LIMIT);
- if (isCordova)
- window.plugins.toast.showShortBottom(gettextCatalog.getString('Matches: ' + $scope.filteredTxHistory.length));
- $timeout(function() {
- $rootScope.$apply();
- });
-
- }, 1000);
-
- $scope.moreSearchResults = function() {
- currentTxHistoryPage++;
- $scope.showHistory();
- $scope.$broadcast('scroll.infiniteScrollComplete');
- };
-
- $scope.showHistory = function() {
- $scope.txHistorySearchResults = $scope.filteredTxHistory ? $scope.filteredTxHistory.slice(0, (currentTxHistoryPage + 1) * HISTORY_SHOW_LIMIT) : [];
- $scope.txHistoryShowMore = $scope.filteredTxHistory.length > $scope.txHistorySearchResults.length;
- };
-
-});
diff --git a/src/js/controllers/walletDetails.js b/src/js/controllers/walletDetails.js
index 7d1748b7c..349e57bf2 100644
--- a/src/js/controllers/walletDetails.js
+++ b/src/js/controllers/walletDetails.js
@@ -77,6 +77,11 @@ angular.module('copayApp.controllers').controller('walletDetailsController', fun
$scope.searchModal = modal;
$scope.searchModal.show();
});
+
+ $scope.close = function() {
+ $scope.searchModal.hide();
+ }
+
};
$scope.openTxModal = function(btx) {