From a89b7b9c6bbcacc5acc07d109ce66bac3f59a435 Mon Sep 17 00:00:00 2001 From: Sebastiaan Pasma Date: Tue, 8 May 2018 10:28:13 +0200 Subject: [PATCH 1/3] Remember the state of collapsed/open menus on home tab --- src/js/controllers/communityController.js | 10 +++++++++- src/js/controllers/homeIntegrations.js | 11 +++++++++-- src/js/controllers/nextStepsController.js | 10 +++++++++- src/js/controllers/servicesController.js | 11 +++++++++-- src/js/services/configService.js | 4 +++- 5 files changed, 39 insertions(+), 7 deletions(-) diff --git a/src/js/controllers/communityController.js b/src/js/controllers/communityController.js index 1c3d10389..537270b8f 100644 --- a/src/js/controllers/communityController.js +++ b/src/js/controllers/communityController.js @@ -1,8 +1,13 @@ 'use strict'; -angular.module('copayApp.controllers').controller('communityController', function($scope, communityService, $ionicScrollDelegate, $timeout, platformInfo) { +angular.module('copayApp.controllers').controller('communityController', function($scope, communityService, $ionicScrollDelegate, $timeout, platformInfo, configService) { $scope.hide = false; + + configService.whenAvailable(function(config) { + $scope.hide = config.homeSectionIsHidden&&config.homeSectionIsHidden['community']?config.homeSectionIsHidden['community']:false; + }); + $scope.services = communityService.get(); $scope.isCordova = platformInfo.isCordova; @@ -11,6 +16,9 @@ angular.module('copayApp.controllers').controller('communityController', functio $timeout(function() { $ionicScrollDelegate.resize(); $scope.$apply(); + configService.set({homeSectionIsHidden: {community: $scope.hide}}, function(err) { + if (err) $log.debug(err); + }); }, 10); }; diff --git a/src/js/controllers/homeIntegrations.js b/src/js/controllers/homeIntegrations.js index fe01d816b..ccfad0b46 100644 --- a/src/js/controllers/homeIntegrations.js +++ b/src/js/controllers/homeIntegrations.js @@ -1,8 +1,12 @@ 'use strict'; -angular.module('copayApp.controllers').controller('homeIntegrationsController', function($scope, homeIntegrationsService, $ionicScrollDelegate, $timeout) { - +angular.module('copayApp.controllers').controller('homeIntegrationsController', function($scope, homeIntegrationsService, $ionicScrollDelegate, $timeout, configService) { $scope.hide = false; + + configService.whenAvailable(function(config) { + $scope.hide = config.homeSectionIsHidden&&config.homeSectionIsHidden['homeIntegrations']?config.homeSectionIsHidden['homeIntegrations']:false; + }); + $scope.services = homeIntegrationsService.get(); $scope.toggle = function() { @@ -10,6 +14,9 @@ angular.module('copayApp.controllers').controller('homeIntegrationsController', $timeout(function() { $ionicScrollDelegate.resize(); $scope.$apply(); + configService.set({homeSectionIsHidden: {homeIntegrations: $scope.hide}}, function(err) { + if (err) $log.debug(err); + }); }, 10); }; diff --git a/src/js/controllers/nextStepsController.js b/src/js/controllers/nextStepsController.js index 393f29dd3..48ce15a5f 100644 --- a/src/js/controllers/nextStepsController.js +++ b/src/js/controllers/nextStepsController.js @@ -1,8 +1,13 @@ 'use strict'; -angular.module('copayApp.controllers').controller('nextStepsController', function($scope, nextStepsService, $ionicScrollDelegate, $timeout) { +angular.module('copayApp.controllers').controller('nextStepsController', function($scope, nextStepsService, $ionicScrollDelegate, $timeout, configService) { $scope.hide = false; + + configService.whenAvailable(function(config) { + $scope.hide = config.homeSectionIsHidden&&config.homeSectionIsHidden['nextSteps']?config.homeSectionIsHidden['nextSteps']:false; + }); + $scope.services = nextStepsService.get(); $scope.toggle = function() { @@ -10,6 +15,9 @@ angular.module('copayApp.controllers').controller('nextStepsController', functio $timeout(function() { $ionicScrollDelegate.resize(); $scope.$apply(); + configService.set({homeSectionIsHidden: {nextSteps: $scope.hide}}, function(err) { + if (err) $log.debug(err); + }); }, 10); }; diff --git a/src/js/controllers/servicesController.js b/src/js/controllers/servicesController.js index d3a542a9b..62b13c041 100644 --- a/src/js/controllers/servicesController.js +++ b/src/js/controllers/servicesController.js @@ -1,8 +1,12 @@ 'use strict'; -angular.module('copayApp.controllers').controller('servicesController', function($scope, $ionicScrollDelegate, $timeout, servicesService) { - +angular.module('copayApp.controllers').controller('servicesController', function($scope, $ionicScrollDelegate, $timeout, servicesService, configService) { $scope.hide = false; + + configService.whenAvailable(function(config) { + $scope.hide = config.homeSectionIsHidden&&config.homeSectionIsHidden['services']?config.homeSectionIsHidden['services']:false; + }); + $scope.services = servicesService.get(); $scope.toggle = function() { @@ -10,6 +14,9 @@ angular.module('copayApp.controllers').controller('servicesController', function $timeout(function() { $ionicScrollDelegate.resize(); $scope.$apply(); + configService.set({homeSectionIsHidden: {services: $scope.hide}}, function(err) { + if (err) $log.debug(err); + }); }, 10); }; diff --git a/src/js/services/configService.js b/src/js/services/configService.js index 5cf454558..19c21fe00 100644 --- a/src/js/services/configService.js +++ b/src/js/services/configService.js @@ -120,7 +120,9 @@ angular.module('copayApp.services').factory('configService', function(storageSer bitcoinAlias: 'btc', bitcoinCashAlias: 'bch', bitcoinWalletColor: '#fab915', // Observatory - bitcoinCashWalletColor: '#26B03C' // Dollar Green + bitcoinCashWalletColor: '#26B03C', // Dollar Green + + homeSectionIsHidden: {} }; var configCache = null; From f945b0f9a75b959b343166becb6536c8d6cd2043 Mon Sep 17 00:00:00 2001 From: Sebastiaan Pasma Date: Tue, 8 May 2018 10:28:13 +0200 Subject: [PATCH 2/3] Remember the state of collapsed/open menus on home tab --- src/js/controllers/communityController.js | 10 +++++++++- src/js/controllers/homeIntegrations.js | 11 +++++++++-- src/js/controllers/nextStepsController.js | 10 +++++++++- src/js/controllers/servicesController.js | 11 +++++++++-- src/js/services/configService.js | 4 +++- 5 files changed, 39 insertions(+), 7 deletions(-) diff --git a/src/js/controllers/communityController.js b/src/js/controllers/communityController.js index 1c3d10389..537270b8f 100644 --- a/src/js/controllers/communityController.js +++ b/src/js/controllers/communityController.js @@ -1,8 +1,13 @@ 'use strict'; -angular.module('copayApp.controllers').controller('communityController', function($scope, communityService, $ionicScrollDelegate, $timeout, platformInfo) { +angular.module('copayApp.controllers').controller('communityController', function($scope, communityService, $ionicScrollDelegate, $timeout, platformInfo, configService) { $scope.hide = false; + + configService.whenAvailable(function(config) { + $scope.hide = config.homeSectionIsHidden&&config.homeSectionIsHidden['community']?config.homeSectionIsHidden['community']:false; + }); + $scope.services = communityService.get(); $scope.isCordova = platformInfo.isCordova; @@ -11,6 +16,9 @@ angular.module('copayApp.controllers').controller('communityController', functio $timeout(function() { $ionicScrollDelegate.resize(); $scope.$apply(); + configService.set({homeSectionIsHidden: {community: $scope.hide}}, function(err) { + if (err) $log.debug(err); + }); }, 10); }; diff --git a/src/js/controllers/homeIntegrations.js b/src/js/controllers/homeIntegrations.js index fe01d816b..ccfad0b46 100644 --- a/src/js/controllers/homeIntegrations.js +++ b/src/js/controllers/homeIntegrations.js @@ -1,8 +1,12 @@ 'use strict'; -angular.module('copayApp.controllers').controller('homeIntegrationsController', function($scope, homeIntegrationsService, $ionicScrollDelegate, $timeout) { - +angular.module('copayApp.controllers').controller('homeIntegrationsController', function($scope, homeIntegrationsService, $ionicScrollDelegate, $timeout, configService) { $scope.hide = false; + + configService.whenAvailable(function(config) { + $scope.hide = config.homeSectionIsHidden&&config.homeSectionIsHidden['homeIntegrations']?config.homeSectionIsHidden['homeIntegrations']:false; + }); + $scope.services = homeIntegrationsService.get(); $scope.toggle = function() { @@ -10,6 +14,9 @@ angular.module('copayApp.controllers').controller('homeIntegrationsController', $timeout(function() { $ionicScrollDelegate.resize(); $scope.$apply(); + configService.set({homeSectionIsHidden: {homeIntegrations: $scope.hide}}, function(err) { + if (err) $log.debug(err); + }); }, 10); }; diff --git a/src/js/controllers/nextStepsController.js b/src/js/controllers/nextStepsController.js index 393f29dd3..48ce15a5f 100644 --- a/src/js/controllers/nextStepsController.js +++ b/src/js/controllers/nextStepsController.js @@ -1,8 +1,13 @@ 'use strict'; -angular.module('copayApp.controllers').controller('nextStepsController', function($scope, nextStepsService, $ionicScrollDelegate, $timeout) { +angular.module('copayApp.controllers').controller('nextStepsController', function($scope, nextStepsService, $ionicScrollDelegate, $timeout, configService) { $scope.hide = false; + + configService.whenAvailable(function(config) { + $scope.hide = config.homeSectionIsHidden&&config.homeSectionIsHidden['nextSteps']?config.homeSectionIsHidden['nextSteps']:false; + }); + $scope.services = nextStepsService.get(); $scope.toggle = function() { @@ -10,6 +15,9 @@ angular.module('copayApp.controllers').controller('nextStepsController', functio $timeout(function() { $ionicScrollDelegate.resize(); $scope.$apply(); + configService.set({homeSectionIsHidden: {nextSteps: $scope.hide}}, function(err) { + if (err) $log.debug(err); + }); }, 10); }; diff --git a/src/js/controllers/servicesController.js b/src/js/controllers/servicesController.js index d3a542a9b..62b13c041 100644 --- a/src/js/controllers/servicesController.js +++ b/src/js/controllers/servicesController.js @@ -1,8 +1,12 @@ 'use strict'; -angular.module('copayApp.controllers').controller('servicesController', function($scope, $ionicScrollDelegate, $timeout, servicesService) { - +angular.module('copayApp.controllers').controller('servicesController', function($scope, $ionicScrollDelegate, $timeout, servicesService, configService) { $scope.hide = false; + + configService.whenAvailable(function(config) { + $scope.hide = config.homeSectionIsHidden&&config.homeSectionIsHidden['services']?config.homeSectionIsHidden['services']:false; + }); + $scope.services = servicesService.get(); $scope.toggle = function() { @@ -10,6 +14,9 @@ angular.module('copayApp.controllers').controller('servicesController', function $timeout(function() { $ionicScrollDelegate.resize(); $scope.$apply(); + configService.set({homeSectionIsHidden: {services: $scope.hide}}, function(err) { + if (err) $log.debug(err); + }); }, 10); }; diff --git a/src/js/services/configService.js b/src/js/services/configService.js index 5cf454558..19c21fe00 100644 --- a/src/js/services/configService.js +++ b/src/js/services/configService.js @@ -120,7 +120,9 @@ angular.module('copayApp.services').factory('configService', function(storageSer bitcoinAlias: 'btc', bitcoinCashAlias: 'bch', bitcoinWalletColor: '#fab915', // Observatory - bitcoinCashWalletColor: '#26B03C' // Dollar Green + bitcoinCashWalletColor: '#26B03C', // Dollar Green + + homeSectionIsHidden: {} }; var configCache = null; From 030f595132e0b3c30aea58bc6fc0298f497d5e81 Mon Sep 17 00:00:00 2001 From: Sebastiaan Pasma Date: Tue, 8 May 2018 15:38:29 +0200 Subject: [PATCH 3/3] Bug: Wallet not switching Currency --- src/js/controllers/amount.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/js/controllers/amount.js b/src/js/controllers/amount.js index 7807ac06d..adbb21a61 100644 --- a/src/js/controllers/amount.js +++ b/src/js/controllers/amount.js @@ -257,6 +257,8 @@ angular.module('copayApp.controllers').controller('amountController', function($ if ($scope.alternativeAmount == 0) { $scope.alternativeAmount = null; + } else { + $scope.amountModel.amount = parseFloat($scope.alternativeAmount.replace(/[^0-9-.]/g, '')); } if (fixedUnit) return; @@ -267,6 +269,7 @@ angular.module('copayApp.controllers').controller('amountController', function($ } if (availableUnits[unitIndex].isFiat) { + $scope.amountModel.amount = parseFloat($scope.amountModel.amount).toFixed(2); altUnitIndex = altUnitIndex == 0 && availableUnits.length > 2 ? 1 : 0; } else { altUnitIndex = lodash.findIndex(availableUnits, {