Update: Adds a Bitcoin Core Wallet setting which hides BTC wallets when disabled
This commit is contained in:
parent
7bf656a0a3
commit
780951eb2f
12 changed files with 108 additions and 9 deletions
|
|
@ -13,6 +13,9 @@ angular.module('copayApp.controllers').controller('advancedSettingsController',
|
||||||
$scope.hideNextSteps = {
|
$scope.hideNextSteps = {
|
||||||
value: config.hideNextSteps.enabled
|
value: config.hideNextSteps.enabled
|
||||||
};
|
};
|
||||||
|
$scope.displayBitcoinCoreEnabled = {
|
||||||
|
value: config.displayBitcoinCore.enabled
|
||||||
|
};
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -49,6 +52,17 @@ angular.module('copayApp.controllers').controller('advancedSettingsController',
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
$scope.displayBitcoinCoreChange = function() {
|
||||||
|
var opts = {
|
||||||
|
displayBitcoinCore: {
|
||||||
|
enabled: $scope.displayBitcoinCoreEnabled.value
|
||||||
|
}
|
||||||
|
};
|
||||||
|
configService.set(opts, function(err) {
|
||||||
|
if (err) $log.debug(err);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
$scope.$on("$ionicView.beforeEnter", function(event, data) {
|
$scope.$on("$ionicView.beforeEnter", function(event, data) {
|
||||||
$scope.isWindowsPhoneApp = platformInfo.isCordova && platformInfo.isWP;
|
$scope.isWindowsPhoneApp = platformInfo.isCordova && platformInfo.isWP;
|
||||||
updateConfig();
|
updateConfig();
|
||||||
|
|
|
||||||
|
|
@ -123,6 +123,8 @@ angular.module('copayApp.controllers').controller('tabHomeController',
|
||||||
$scope.nextStepsItems = nextStepsService.get();
|
$scope.nextStepsItems = nextStepsService.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$scope.displayBitcoinCore = config.displayBitcoinCore.enabled;
|
||||||
|
|
||||||
$scope.showServices = true;
|
$scope.showServices = true;
|
||||||
pushNotificationsService.init();
|
pushNotificationsService.init();
|
||||||
firebaseEventsService.init();
|
firebaseEventsService.init();
|
||||||
|
|
@ -317,4 +319,10 @@ angular.module('copayApp.controllers').controller('tabHomeController',
|
||||||
}, 300);
|
}, 300);
|
||||||
updateAllWallets();
|
updateAllWallets();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
$rootScope.$on('Local/SettingsUpdated', function(e, walletId) {
|
||||||
|
configService.whenAvailable(function(config) {
|
||||||
|
$scope.displayBitcoinCore = config.displayBitcoinCore.enabled;
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -53,7 +53,7 @@ angular.module('copayApp.controllers').controller('tabSendController', function(
|
||||||
};
|
};
|
||||||
|
|
||||||
var updateWalletsList = function() {
|
var updateWalletsList = function() {
|
||||||
|
var config = configService.getSync();
|
||||||
var networkResult = lodash.countBy($scope.wallets, 'network');
|
var networkResult = lodash.countBy($scope.wallets, 'network');
|
||||||
|
|
||||||
$scope.showTransferCard = $scope.hasWallets && (networkResult.livenet > 1 || networkResult.testnet > 1);
|
$scope.showTransferCard = $scope.hasWallets && (networkResult.livenet > 1 || networkResult.testnet > 1);
|
||||||
|
|
@ -79,12 +79,14 @@ angular.module('copayApp.controllers').controller('tabSendController', function(
|
||||||
coin: v.coin,
|
coin: v.coin,
|
||||||
network: v.network,
|
network: v.network,
|
||||||
balanceString: v.cachedBalance,
|
balanceString: v.cachedBalance,
|
||||||
|
displayWallet: v.coin == 'btc' ? config.displayBitcoinCore.enabled : true,
|
||||||
getAddress: function(cb) {
|
getAddress: function(cb) {
|
||||||
walletService.getAddress(v, false, cb);
|
walletService.getAddress(v, false, cb);
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
originalList = originalList.concat(walletList);
|
originalList = originalList.concat(walletList);
|
||||||
|
console.log(originalList);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
angular.module('copayApp.directives')
|
angular.module('copayApp.directives')
|
||||||
.directive('walletSelector', function($timeout) {
|
.directive('walletSelector', function($rootScope, $timeout, configService) {
|
||||||
return {
|
return {
|
||||||
restrict: 'E',
|
restrict: 'E',
|
||||||
templateUrl: 'views/includes/walletSelector.html',
|
templateUrl: 'views/includes/walletSelector.html',
|
||||||
|
|
@ -11,9 +11,11 @@ angular.module('copayApp.directives')
|
||||||
show: '=walletSelectorShow',
|
show: '=walletSelectorShow',
|
||||||
wallets: '=walletSelectorWallets',
|
wallets: '=walletSelectorWallets',
|
||||||
selectedWallet: '=walletSelectorSelectedWallet',
|
selectedWallet: '=walletSelectorSelectedWallet',
|
||||||
onSelect: '=walletSelectorOnSelect'
|
onSelect: '=walletSelectorOnSelect',
|
||||||
|
alwaysDisplayBitcoinCore: '=walletSelectorAlwaysDisplayBitcoinCore'
|
||||||
},
|
},
|
||||||
link: function(scope, element, attrs) {
|
link: function(scope, element, attrs) {
|
||||||
|
scope.displayWallet = true;
|
||||||
scope.hide = function() {
|
scope.hide = function() {
|
||||||
scope.show = false;
|
scope.show = false;
|
||||||
};
|
};
|
||||||
|
|
@ -26,6 +28,19 @@ angular.module('copayApp.directives')
|
||||||
scope.$watch('wallets', function(newValue, oldValue) {
|
scope.$watch('wallets', function(newValue, oldValue) {
|
||||||
scope.wallets = newValue;
|
scope.wallets = newValue;
|
||||||
});
|
});
|
||||||
|
scope.initDisplayBitcoinCoreConfig = function() {
|
||||||
|
configService.whenAvailable(function(config) {
|
||||||
|
scope.displayBitcoinCore = config.displayBitcoinCore.enabled;
|
||||||
|
scope.initWalletDisplay();
|
||||||
|
});
|
||||||
|
};
|
||||||
|
scope.initWalletDisplay = function() {
|
||||||
|
scope.displayWallet = scope.alwaysDisplayBitcoinCore ? true : scope.displayBitcoinCore;
|
||||||
|
};
|
||||||
|
scope.initDisplayBitcoinCoreConfig();
|
||||||
|
$rootScope.$on('Local/SettingsUpdated', function(e, walletId) {
|
||||||
|
scope.initDisplayBitcoinCoreConfig();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -1310,6 +1310,9 @@ angular.module('copayApp').config(function(historicLogProvider, $provide, $logPr
|
||||||
applicationService.appLockModal('check');
|
applicationService.appLockModal('check');
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
profileService.initBitcoinCoreDisplay();
|
||||||
|
|
||||||
// After everything have been loaded
|
// After everything have been loaded
|
||||||
$timeout(function() {
|
$timeout(function() {
|
||||||
emailService.init(); // Update email subscription if necessary
|
emailService.init(); // Update email subscription if necessary
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
angular.module('copayApp.services').factory('configService', function(storageService, lodash, $log, $timeout, $rootScope, platformInfo) {
|
angular.module('copayApp.services').factory('configService', function(storageService, lodash, $log, $timeout, $rootScope, $injector, platformInfo) {
|
||||||
var root = {};
|
var root = {};
|
||||||
|
|
||||||
var isWindowsPhoneApp = platformInfo.isCordova && platformInfo.isWP;
|
var isWindowsPhoneApp = platformInfo.isCordova && platformInfo.isWP;
|
||||||
|
|
@ -84,6 +84,10 @@ angular.module('copayApp.services').factory('configService', function(storageSer
|
||||||
enabled: true,
|
enabled: true,
|
||||||
},
|
},
|
||||||
|
|
||||||
|
displayBitcoinCore: {
|
||||||
|
enabled: false,
|
||||||
|
},
|
||||||
|
|
||||||
hideNextSteps: {
|
hideNextSteps: {
|
||||||
enabled: isWindowsPhoneApp ? true : false,
|
enabled: isWindowsPhoneApp ? true : false,
|
||||||
},
|
},
|
||||||
|
|
@ -245,6 +249,18 @@ angular.module('copayApp.services').factory('configService', function(storageSer
|
||||||
return lodash.clone(defaultConfig);
|
return lodash.clone(defaultConfig);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
root.checkIfConfigIsSet = function(key) {
|
||||||
|
return new Promise(function(resolve, reject) {
|
||||||
|
storageService.getConfig(function(err, localConfig) {
|
||||||
|
if (localConfig) {
|
||||||
|
configCache = JSON.parse(localConfig);
|
||||||
|
resolve(configCache.hasOwnProperty(key));
|
||||||
|
} else {
|
||||||
|
reject(false);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
return root;
|
return root;
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -1037,5 +1037,29 @@ angular.module('copayApp.services')
|
||||||
return cb(null, txps, n);
|
return cb(null, txps, n);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
root.initBitcoinCoreDisplay = function() {
|
||||||
|
configService.checkIfConfigIsSet('displayBitcoinCore').then(function(result) {
|
||||||
|
if (!result) {
|
||||||
|
var walletsBtc = root.getWallets({coin: 'btc'});
|
||||||
|
var totalBtc = 0;
|
||||||
|
|
||||||
|
walletsBtc.forEach( (value, key, index) => {
|
||||||
|
totalBtc += parseFloat(value.cachedBalance);
|
||||||
|
});
|
||||||
|
|
||||||
|
var enableDisplayBitcoinCore = totalBtc > 0 ? true : false;
|
||||||
|
|
||||||
|
var opts = {
|
||||||
|
displayBitcoinCore: {
|
||||||
|
enabled: enableDisplayBitcoinCore
|
||||||
|
}
|
||||||
|
};
|
||||||
|
configService.set(opts, function(err) {
|
||||||
|
if (err) $log.debug(err);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
return root;
|
return root;
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -29,6 +29,15 @@
|
||||||
<ion-toggle ng-model="hideNextSteps.value" ng-if="!isWindowsPhoneApp" toggle-class="toggle-balanced" ng-change="nextStepsChange()">
|
<ion-toggle ng-model="hideNextSteps.value" ng-if="!isWindowsPhoneApp" toggle-class="toggle-balanced" ng-change="nextStepsChange()">
|
||||||
<span class="toggle-label" translate>Hide Next Steps Card</span>
|
<span class="toggle-label" translate>Hide Next Steps Card</span>
|
||||||
</ion-toggle>
|
</ion-toggle>
|
||||||
|
|
||||||
|
<div class="item item-divider"></div>
|
||||||
|
|
||||||
|
<ion-toggle class="has-comment" ng-model="displayBitcoinCoreEnabled.value" toggle-class="toggle-balanced" ng-change="displayBitcoinCoreChange()">
|
||||||
|
<span class="toggle-label" translate>Bitcoin Core Wallet</span>
|
||||||
|
</ion-toggle>
|
||||||
|
<div class="comment" translate>
|
||||||
|
If enabled, Bitcoin Core (BTC) wallet(s) will be displayed on the Home screen. If disabled, BTC wallets will be not be deleted, only hidden.
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</ion-content>
|
</ion-content>
|
||||||
</ion-view>
|
</ion-view>
|
||||||
|
|
|
||||||
|
|
@ -37,13 +37,14 @@
|
||||||
</div>
|
</div>
|
||||||
</a>
|
</a>
|
||||||
|
|
||||||
<div class="subheader" ng-if="walletsBtc[0] && walletsBch[0]" translate>
|
<div class="subheader" ng-if="walletsBtc[0] && walletsBch[0] && displayWallet" translate>
|
||||||
<img class="wallet-coin-logo" src="img/icon-bitcoin.svg" width="18">
|
<img class="wallet-coin-logo" src="img/icon-bitcoin.svg" width="18">
|
||||||
<span translate>Bitcoin Core (BTC)</span>
|
<span translate>Bitcoin Core (BTC)</span>
|
||||||
</div>
|
</div>
|
||||||
<a
|
<a
|
||||||
ng-repeat="wallet in walletsBtc track by $index"
|
ng-repeat="wallet in walletsBtc track by $index"
|
||||||
class="item item-icon-left item-big-icon-left item-icon-right wallet"
|
class="item item-icon-left item-big-icon-left item-icon-right wallet"
|
||||||
|
ng-show="displayWallet"
|
||||||
ng-click="selectWallet(wallet)"
|
ng-click="selectWallet(wallet)"
|
||||||
>
|
>
|
||||||
<i class="icon big-icon-svg" ng-include="'views/includes/walletIcon.html'"></i>
|
<i class="icon big-icon-svg" ng-include="'views/includes/walletIcon.html'"></i>
|
||||||
|
|
|
||||||
|
|
@ -99,7 +99,8 @@ wallet-selector-title="fromWalletSelectorTitle"
|
||||||
wallet-selector-wallets="fromWallets"
|
wallet-selector-wallets="fromWallets"
|
||||||
wallet-selector-selected-wallet="fromWallet"
|
wallet-selector-selected-wallet="fromWallet"
|
||||||
wallet-selector-show="showFromWallets"
|
wallet-selector-show="showFromWallets"
|
||||||
wallet-selector-on-select="onFromWalletSelect">
|
wallet-selector-on-select="onFromWalletSelect"
|
||||||
|
wallet-selector-always-display-bitcoin-core="true">
|
||||||
</wallet-selector>
|
</wallet-selector>
|
||||||
|
|
||||||
<wallet-selector
|
<wallet-selector
|
||||||
|
|
@ -107,6 +108,7 @@ wallet-selector-title="toWalletSelectorTitle"
|
||||||
wallet-selector-wallets="toWallets"
|
wallet-selector-wallets="toWallets"
|
||||||
wallet-selector-selected-wallet="toWallet"
|
wallet-selector-selected-wallet="toWallet"
|
||||||
wallet-selector-show="showToWallets"
|
wallet-selector-show="showToWallets"
|
||||||
wallet-selector-on-select="onToWalletSelect">
|
wallet-selector-on-select="onToWalletSelect"
|
||||||
|
wallet-selector-always-display-bitcoin-core="true">
|
||||||
</wallet-selector>
|
</wallet-selector>
|
||||||
</ion-view>
|
</ion-view>
|
||||||
|
|
|
||||||
|
|
@ -78,7 +78,8 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="list card">
|
<div class="list card"
|
||||||
|
ng-show="displayBitcoinCore">
|
||||||
<div class="item item-icon-right item-heading">
|
<div class="item item-icon-right item-heading">
|
||||||
<img class="wallet-coin-logo" src="img/icon-bitcoin.svg" width="18">
|
<img class="wallet-coin-logo" src="img/icon-bitcoin.svg" width="18">
|
||||||
<span translate>Bitcoin Core (BTC)</span>
|
<span translate>Bitcoin Core (BTC)</span>
|
||||||
|
|
|
||||||
|
|
@ -70,7 +70,11 @@
|
||||||
<span translate>Transfer to Wallet</span>
|
<span translate>Transfer to Wallet</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="list">
|
<div class="list">
|
||||||
<a class="item item-icon-left item-icon-right" ng-repeat="item in list" ng-if="hasWallets && item.recipientType == 'wallet'" ng-click="goToAmount(item)">
|
<a class="item item-icon-left item-icon-right"
|
||||||
|
ng-repeat="item in list"
|
||||||
|
ng-if="hasWallets && item.recipientType == 'wallet'"
|
||||||
|
ng-click="goToAmount(item)"
|
||||||
|
ng-show="item.displayWallet">
|
||||||
<i class="icon big-icon-svg" ng-if="item.recipientType == 'wallet'" ng-init="wallet = item" ng-include="'views/includes/walletIcon.html'"></i>
|
<i class="icon big-icon-svg" ng-if="item.recipientType == 'wallet'" ng-init="wallet = item" ng-include="'views/includes/walletIcon.html'"></i>
|
||||||
{{item.name}}
|
{{item.name}}
|
||||||
<p>
|
<p>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue