From 17ad7e8e745c76dce780fde8f71cc6d41858c6fe Mon Sep 17 00:00:00 2001 From: Sebastiaan Pasma Date: Tue, 15 May 2018 15:07:31 +0200 Subject: [PATCH 1/4] Improvement - 322 - "Search transactions" empty results case --- src/js/controllers/modals/search.js | 21 ++++++++++++++++++++- www/views/modals/search.html | 20 ++++++++++++++++++++ 2 files changed, 40 insertions(+), 1 deletion(-) diff --git a/src/js/controllers/modals/search.js b/src/js/controllers/modals/search.js index 3d5ae366e..12899deaf 100644 --- a/src/js/controllers/modals/search.js +++ b/src/js/controllers/modals/search.js @@ -1,6 +1,6 @@ 'use strict'; -angular.module('copayApp.controllers').controller('searchController', function($scope, $interval, $timeout, $filter, $log, $ionicModal, $ionicPopover, $state, $stateParams, $ionicScrollDelegate, bwcError, profileService, lodash, configService, gettext, gettextCatalog, platformInfo, walletService) { +angular.module('copayApp.controllers').controller('searchController', function($scope, $interval, $timeout, $filter, $log, $ionicModal, $ionicPopover, $state, $stateParams, $ionicScrollDelegate, bwcError, profileService, lodash, configService, gettext, gettextCatalog, platformInfo, walletService, externalLinkService) { var HISTORY_SHOW_LIMIT = 10; var currentTxHistoryPage = 0; @@ -21,6 +21,8 @@ angular.module('copayApp.controllers').controller('searchController', function($ function filter(search) { $scope.filteredTxHistory = []; + $scope.searchTermIsAddress = false; + $scope.searchTermIsTxId = false; function computeSearchableString(tx) { var addrbook = ''; @@ -50,8 +52,15 @@ angular.module('copayApp.controllers').controller('searchController', function($ return lodash.includes(tx.searcheableString, search.toLowerCase()); }); + if (search && (search.indexOf('bitcoincash:') >= 0 || search[0] === 'C' || search[0] === 'H' || search[0] === 'p' || search[0] === 'q') && search.replace('bitcoincash:', '').length === 42) { + $scope.searchTermIsAddress = true; + } else if (search && search.lengh === 64) { + $scope.searchTermIsTxId = true; + } + if ($scope.filteredTxHistory.length > HISTORY_SHOW_LIMIT) $scope.txHistoryShowMore = true; else $scope.txHistoryShowMore = false; + return $scope.filteredTxHistory; }; @@ -77,4 +86,14 @@ angular.module('copayApp.controllers').controller('searchController', function($ $scope.txHistoryShowMore = $scope.filteredTxHistory.length > $scope.txHistorySearchResults.length; }; + $scope.searchOnBlockchain = function(searchTerm) { + var url = 'https://explorer.bitcoin.com/bch/search/' + searchTerm; + var optIn = true; + var title = null; + var message = gettextCatalog.getString('Search on Explorer.Bitcoin.com'); + var okText = gettextCatalog.getString('Open Explorer'); + var cancelText = gettextCatalog.getString('Go Back'); + externalLinkService.open(url, optIn, title, message, okText, cancelText); + }; + }); diff --git a/www/views/modals/search.html b/www/views/modals/search.html index ad82409de..efa3f84f7 100644 --- a/www/views/modals/search.html +++ b/www/views/modals/search.html @@ -18,6 +18,26 @@
+
+
+ {{'No results found'|translate}} +
+
+ +
+
+ +
+
+ +
+
From a915570df3d9b56223c436169533af4d81e95c00 Mon Sep 17 00:00:00 2001 From: Sebastiaan Pasma Date: Wed, 16 May 2018 12:11:41 +0200 Subject: [PATCH 2/4] Improvement - 322 - "Search transactions" empty results case --- src/js/controllers/modals/search.js | 14 +++++++++----- www/views/modals/search.html | 18 +++++------------- 2 files changed, 14 insertions(+), 18 deletions(-) diff --git a/src/js/controllers/modals/search.js b/src/js/controllers/modals/search.js index 12899deaf..082ef52cc 100644 --- a/src/js/controllers/modals/search.js +++ b/src/js/controllers/modals/search.js @@ -52,10 +52,14 @@ angular.module('copayApp.controllers').controller('searchController', function($ return lodash.includes(tx.searcheableString, search.toLowerCase()); }); - if (search && (search.indexOf('bitcoincash:') >= 0 || search[0] === 'C' || search[0] === 'H' || search[0] === 'p' || search[0] === 'q') && search.replace('bitcoincash:', '').length === 42) { - $scope.searchTermIsAddress = true; - } else if (search && search.lengh === 64) { - $scope.searchTermIsTxId = true; + if (search) { + if ((search.indexOf('bitcoincash:') >= 0 || search[0] === 'C' || search[0] === 'H' || search[0] === 'p' || search[0] === 'q') && search.replace('bitcoincash:', '').length === 42) { // CashAddr + $scope.searchTermIsAddress = true; + } else if ((search[0] === "1" || search[0] === "3" || search.substring(0, 3) === "bc1") && search.length >= 26 && search.length <= 35) { // Legacy Addresses + $scope.searchTermIsAddress = true; + } else if (search.lengh === 64) { + $scope.searchTermIsTxId = true; + } } if ($scope.filteredTxHistory.length > HISTORY_SHOW_LIMIT) $scope.txHistoryShowMore = true; @@ -87,7 +91,7 @@ angular.module('copayApp.controllers').controller('searchController', function($ }; $scope.searchOnBlockchain = function(searchTerm) { - var url = 'https://explorer.bitcoin.com/bch/search/' + searchTerm; + var url = 'https://explorer.bitcoin.com/'+$scope.wallet.coin+'/search/' + searchTerm; var optIn = true; var title = null; var message = gettextCatalog.getString('Search on Explorer.Bitcoin.com'); diff --git a/www/views/modals/search.html b/www/views/modals/search.html index efa3f84f7..877173e73 100644 --- a/www/views/modals/search.html +++ b/www/views/modals/search.html @@ -4,7 +4,7 @@ Close
- Search Transactions + Search Transactions ({{wallet.coin}})
@@ -23,18 +23,10 @@ {{'No results found'|translate}}
- -
-
- -
-
-
From cba937eebc8fba591d8fd014fe4d277a24b8e5d2 Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Dominguez Date: Fri, 18 May 2018 11:50:58 +0900 Subject: [PATCH 3/4] Fix - 322 - *lengh* -> *length* --- src/js/controllers/modals/search.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/js/controllers/modals/search.js b/src/js/controllers/modals/search.js index 082ef52cc..17b759226 100644 --- a/src/js/controllers/modals/search.js +++ b/src/js/controllers/modals/search.js @@ -57,7 +57,7 @@ angular.module('copayApp.controllers').controller('searchController', function($ $scope.searchTermIsAddress = true; } else if ((search[0] === "1" || search[0] === "3" || search.substring(0, 3) === "bc1") && search.length >= 26 && search.length <= 35) { // Legacy Addresses $scope.searchTermIsAddress = true; - } else if (search.lengh === 64) { + } else if (search.length === 64) { $scope.searchTermIsTxId = true; } } From 09566af448ef075a52880fe2ace869a6b2baa2df Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Dominguez Date: Fri, 18 May 2018 14:21:38 +0900 Subject: [PATCH 4/4] Fix - 322 - Fix >= -> === --- src/js/controllers/modals/search.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/js/controllers/modals/search.js b/src/js/controllers/modals/search.js index 17b759226..6612da6e8 100644 --- a/src/js/controllers/modals/search.js +++ b/src/js/controllers/modals/search.js @@ -53,7 +53,7 @@ angular.module('copayApp.controllers').controller('searchController', function($ }); if (search) { - if ((search.indexOf('bitcoincash:') >= 0 || search[0] === 'C' || search[0] === 'H' || search[0] === 'p' || search[0] === 'q') && search.replace('bitcoincash:', '').length === 42) { // CashAddr + if ((search.indexOf('bitcoincash:') === 0 || search[0] === 'C' || search[0] === 'H' || search[0] === 'p' || search[0] === 'q') && search.replace('bitcoincash:', '').length === 42) { // CashAddr $scope.searchTermIsAddress = true; } else if ((search[0] === "1" || search[0] === "3" || search.substring(0, 3) === "bc1") && search.length >= 26 && search.length <= 35) { // Legacy Addresses $scope.searchTermIsAddress = true; @@ -91,12 +91,12 @@ angular.module('copayApp.controllers').controller('searchController', function($ }; $scope.searchOnBlockchain = function(searchTerm) { - var url = 'https://explorer.bitcoin.com/'+$scope.wallet.coin+'/search/' + searchTerm; - var optIn = true; - var title = null; - var message = gettextCatalog.getString('Search on Explorer.Bitcoin.com'); - var okText = gettextCatalog.getString('Open Explorer'); - var cancelText = gettextCatalog.getString('Go Back'); + const url = 'https://explorer.bitcoin.com/'+$scope.wallet.coin+'/search/' + searchTerm; + const optIn = true; + const title = null; + const message = gettextCatalog.getString('Search on Explorer.Bitcoin.com'); + const okText = gettextCatalog.getString('Open Explorer'); + const cancelText = gettextCatalog.getString('Go Back'); externalLinkService.open(url, optIn, title, message, okText, cancelText); };