diff --git a/src/js/controllers/preferencesNotifications.js b/src/js/controllers/preferencesNotifications.js index 3f8d43d2b..5cf80a4af 100644 --- a/src/js/controllers/preferencesNotifications.js +++ b/src/js/controllers/preferencesNotifications.js @@ -1,62 +1,49 @@ 'use strict'; -angular.module('copayApp.controllers').controller('preferencesNotificationsController', function($scope, $log, $window, configService, platformInfo, pushNotificationsService, profileService, emailService) { - var updateConfig = function() { - $scope.appName = $window.appConfig.nameCase; - $scope.PNEnabledByUser = true; - $scope.usePushNotifications = platformInfo.isCordova && !platformInfo.isWP; - $scope.isIOSApp = platformInfo.isIOS && platformInfo.isCordova; +angular.module('copayApp.controllers').controller('preferencesNotificationsController', + function($scope, $rootScope, $log, $window, lodash, configService, uxLanguage, platformInfo, pushNotificationsService, profileService, feeService) { - if ($scope.isIOSApp) { - try { - PushNotification.hasPermission(function(data) { - $scope.PNEnabledByUser = data.isEnabled; - }); - } catch (e) { - $log.error(e); + var updateConfig = function() { + + var config = configService.getSync(); + var isCordova = platformInfo.isCordova; + var isIOS = platformInfo.isIOS; + + $scope.appName = $window.appConfig.nameCase; + $scope.PNEnabledByUser = true; + $scope.isIOSApp = isIOS && isCordova; + if ($scope.isIOSApp) { + try { + PushNotification.hasPermission(function(data) { + $scope.PNEnabledByUser = data.isEnabled; + }); + } catch(e) { + $log.error(e); + }; + } + + $scope.pushNotifications = { + value: config.pushNotifications.enabled }; - } - - var config = configService.getSync(); - - $scope.pushNotifications = { - value: config.pushNotifications.enabled }; - $scope.emailNotifications = { - value: config.emailNotifications ? config.emailNotifications.enabled : false + $scope.pushNotificationsChange = function() { + if (!$scope.pushNotifications) return; + var opts = { + pushNotifications: { + enabled: $scope.pushNotifications.value + } + }; + configService.set(opts, function(err) { + if (opts.pushNotifications.enabled) + profileService.pushNotificationsInit(); + else + pushNotificationsService.disableNotifications(profileService.getWallets()); + if (err) $log.debug(err); + }); }; - }; - $scope.pushNotificationsChange = function() { - if (!$scope.pushNotifications) return; - var opts = { - pushNotifications: { - enabled: $scope.pushNotifications.value - } - }; - configService.set(opts, function(err) { - if (opts.pushNotifications.enabled) - profileService.pushNotificationsInit(); - else - pushNotificationsService.disableNotifications(profileService.getWallets()); - if (err) $log.debug(err); + $scope.$on("$ionicView.enter", function(event, data) { + updateConfig(); }); - }; - - $scope.emailNotificationsChange = function() { - var opts = { - emailNotifications: { - enabled: $scope.emailNotifications.value - } - }; - emailService.enableEmailNotifications($scope.emailNotifications.value); - configService.set(opts, function(err) { - if (err) $log.debug(err); - }); - }; - - $scope.$on("$ionicView.enter", function(event, data) { - updateConfig(); }); -}); diff --git a/src/js/controllers/tab-settings.js b/src/js/controllers/tab-settings.js index 1022a77de..773a6a5f3 100644 --- a/src/js/controllers/tab-settings.js +++ b/src/js/controllers/tab-settings.js @@ -1,11 +1,17 @@ 'use strict'; -angular.module('copayApp.controllers').controller('tabSettingsController', function($scope, $window, uxLanguage, profileService, feeService, configService, externalLinkService) { +angular.module('copayApp.controllers').controller('tabSettingsController', function($scope, $window, uxLanguage, platformInfo, profileService, feeService, configService, externalLinkService) { var updateConfig = function() { - $scope.appName = $window.appConfig.nameCase; var config = configService.getSync(); + var isCordova = platformInfo.isCordova; + var isWP = platformInfo.isWP; + + $scope.usePushNotifications = isCordova && !isWP; + + $scope.appName = $window.appConfig.nameCase; + $scope.unitName = config.wallet.settings.unitName; $scope.currentLanguageName = uxLanguage.getCurrentLanguageName(); $scope.selectedAlternative = { diff --git a/src/js/services/configService.js b/src/js/services/configService.js index b3397b162..c766c0582 100644 --- a/src/js/services/configService.js +++ b/src/js/services/configService.js @@ -85,10 +85,6 @@ angular.module('copayApp.services').factory('configService', function(storageSer windows: {}, } }, - - emailNotifications: { - enabled: true, - }, }; var configCache = null; diff --git a/src/js/services/emailService.js b/src/js/services/emailService.js deleted file mode 100644 index 63d940214..000000000 --- a/src/js/services/emailService.js +++ /dev/null @@ -1,36 +0,0 @@ -'use strict'; - -angular.module('copayApp.services').factory('emailService', function($log, configService, profileService, lodash, walletService) { - var root = {}; - - root.enableEmailNotifications = function(val) { - val = val || false; - - var config = configService.getSync(); - - if (!config.emailFor) { - $log.debug('No email configuration available'); - return; - } - - var keys = lodash.keys(config.emailFor); - var wallets = lodash.map(keys, function(k) { - return profileService.getWallet(k); - }); - - if (!wallets) { - $log.debug('No wallets found'); - return; - } - - lodash.each(wallets, function(w) { - walletService.updateRemotePreferences(w, { - email: val ? config.emailFor[w.credentials.walletId] : null - }, function(err) { - if (err) $log.warn(err); - }); - }); - }; - - return root; -}); diff --git a/www/views/preferencesNotifications.html b/www/views/preferencesNotifications.html index bb6a97e18..7385fd380 100644 --- a/www/views/preferencesNotifications.html +++ b/www/views/preferencesNotifications.html @@ -10,13 +10,9 @@
Notifications
- + Enable push notifications - - - Enable email notifications -
diff --git a/www/views/tab-settings.html b/www/views/tab-settings.html index 075ff0a81..f624537e4 100644 --- a/www/views/tab-settings.html +++ b/www/views/tab-settings.html @@ -39,7 +39,7 @@
Preferences
- +