Merge pull request #121 from Bitcoin-com/wallet/task/322
Improvement - 322 - "Search transactions" empty results case
This commit is contained in:
commit
ff709da290
2 changed files with 37 additions and 2 deletions
|
|
@ -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, bitcoinCashJsService) {
|
||||
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, bitcoinCashJsService) {
|
||||
|
||||
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 = '';
|
||||
|
|
@ -63,8 +65,19 @@ angular.module('copayApp.controllers').controller('searchController', function($
|
|||
return lodash.includes(tx.searcheableString, search.toLowerCase());
|
||||
});
|
||||
|
||||
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.length === 64) {
|
||||
$scope.searchTermIsTxId = true;
|
||||
}
|
||||
}
|
||||
|
||||
if ($scope.filteredTxHistory.length > HISTORY_SHOW_LIMIT) $scope.txHistoryShowMore = true;
|
||||
else $scope.txHistoryShowMore = false;
|
||||
|
||||
return $scope.filteredTxHistory;
|
||||
};
|
||||
|
||||
|
|
@ -90,4 +103,14 @@ angular.module('copayApp.controllers').controller('searchController', function($
|
|||
$scope.txHistoryShowMore = $scope.filteredTxHistory.length > $scope.txHistorySearchResults.length;
|
||||
};
|
||||
|
||||
$scope.searchOnBlockchain = function(searchTerm) {
|
||||
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);
|
||||
};
|
||||
|
||||
});
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
Close
|
||||
</button>
|
||||
<div class="title" translate>
|
||||
Search Transactions
|
||||
Search Transactions ({{wallet.coin}})
|
||||
</div>
|
||||
</ion-header-bar>
|
||||
|
||||
|
|
@ -18,6 +18,18 @@
|
|||
</div>
|
||||
|
||||
<div class="list">
|
||||
<div class="wallet-details__list" ng-show="filteredTxHistory.length === 0 && search != ''">
|
||||
<div class="text-gray text-center p10t">
|
||||
{{'No results found'|translate}}
|
||||
</div>
|
||||
<div class="p10t text-center">
|
||||
<button class="button button-small button-primary" ng-click="searchOnBlockchain(search)" translate>
|
||||
<span ng-if="searchTermIsTxId">{{'Show Transaction on Blockchain'|translate}}</span>
|
||||
<span ng-if="searchTermIsAddress">{{'Show Address on Blockchain'|translate}}</span>
|
||||
<span ng-if="!searchTermIsAddress && !searchTermIsTxId">{{'Search on Blockchain'|translate}}</span>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="wallet-details__list" ng-show="txHistory[0]">
|
||||
<div ng-repeat="btx in txHistorySearchResults track by $index" ng-click="openTx(btx)">
|
||||
<span ng-include="'views/includes/walletHistory.html'"></span>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue