mirror of https://github.com/BTCPrivate/copay.git
Merge pull request #4945 from bitpay/revert-4942-feat/email-toggle
Revert "Add toggle for email notifications"
This commit is contained in:
commit
f4017f5a7f
|
@ -1,12 +1,17 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copayApp.controllers').controller('preferencesNotificationsController', function($scope, $log, $window, configService, platformInfo, pushNotificationsService, profileService, emailService) {
|
||||
angular.module('copayApp.controllers').controller('preferencesNotificationsController',
|
||||
function($scope, $rootScope, $log, $window, lodash, configService, uxLanguage, platformInfo, pushNotificationsService, profileService, feeService) {
|
||||
|
||||
var updateConfig = function() {
|
||||
|
||||
var config = configService.getSync();
|
||||
var isCordova = platformInfo.isCordova;
|
||||
var isIOS = platformInfo.isIOS;
|
||||
|
||||
$scope.appName = $window.appConfig.nameCase;
|
||||
$scope.PNEnabledByUser = true;
|
||||
$scope.usePushNotifications = platformInfo.isCordova && !platformInfo.isWP;
|
||||
$scope.isIOSApp = platformInfo.isIOS && platformInfo.isCordova;
|
||||
|
||||
$scope.isIOSApp = isIOS && isCordova;
|
||||
if ($scope.isIOSApp) {
|
||||
try {
|
||||
PushNotification.hasPermission(function(data) {
|
||||
|
@ -17,15 +22,9 @@ angular.module('copayApp.controllers').controller('preferencesNotificationsContr
|
|||
};
|
||||
}
|
||||
|
||||
var config = configService.getSync();
|
||||
|
||||
$scope.pushNotifications = {
|
||||
value: config.pushNotifications.enabled
|
||||
};
|
||||
|
||||
$scope.emailNotifications = {
|
||||
value: config.emailNotifications ? config.emailNotifications.enabled : false
|
||||
};
|
||||
};
|
||||
|
||||
$scope.pushNotificationsChange = function() {
|
||||
|
@ -44,18 +43,6 @@ angular.module('copayApp.controllers').controller('preferencesNotificationsContr
|
|||
});
|
||||
};
|
||||
|
||||
$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();
|
||||
});
|
||||
|
|
|
@ -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 = {
|
||||
|
|
|
@ -85,10 +85,6 @@ angular.module('copayApp.services').factory('configService', function(storageSer
|
|||
windows: {},
|
||||
}
|
||||
},
|
||||
|
||||
emailNotifications: {
|
||||
enabled: true,
|
||||
},
|
||||
};
|
||||
|
||||
var configCache = 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;
|
||||
});
|
|
@ -10,13 +10,9 @@
|
|||
<div ng-show="PNEnabledByUser">
|
||||
<div class="item item-divider" translate>Notifications</div>
|
||||
|
||||
<ion-toggle ng-model="pushNotifications.value" toggle-class="toggle-balanced" ng-change="pushNotificationsChange()" ng-show="usePushNotifications">
|
||||
<ion-toggle ng-model="pushNotifications.value" toggle-class="toggle-balanced" ng-change="pushNotificationsChange()">
|
||||
<span class="toggle-label" translate>Enable push notifications</span>
|
||||
</ion-toggle>
|
||||
|
||||
<ion-toggle ng-model="emailNotifications.value" toggle-class="toggle-balanced" ng-change="emailNotificationsChange()">
|
||||
<span class="toggle-label" translate>Enable email notifications</span>
|
||||
</ion-toggle>
|
||||
</div>
|
||||
|
||||
<div ng-show="!PNEnabledByUser && isIOSApp">
|
||||
|
|
|
@ -39,7 +39,7 @@
|
|||
|
||||
<div class="item item-divider" translate>Preferences</div>
|
||||
|
||||
<a class="item item-icon-left item-icon-right" ui-sref="tabs.notifications">
|
||||
<a class="item item-icon-left item-icon-right" ui-sref="tabs.notifications" ng-show="usePushNotifications">
|
||||
<i class="icon big-icon-svg">
|
||||
<img src="img/icon-notifications.svg" class="bg"/>
|
||||
</i>
|
||||
|
|
Loading…
Reference in New Issue