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,62 +1,49 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
angular.module('copayApp.controllers').controller('preferencesNotificationsController', function($scope, $log, $window, configService, platformInfo, pushNotificationsService, profileService, emailService) {
|
angular.module('copayApp.controllers').controller('preferencesNotificationsController',
|
||||||
var updateConfig = function() {
|
function($scope, $rootScope, $log, $window, lodash, configService, uxLanguage, platformInfo, pushNotificationsService, profileService, feeService) {
|
||||||
$scope.appName = $window.appConfig.nameCase;
|
|
||||||
$scope.PNEnabledByUser = true;
|
|
||||||
$scope.usePushNotifications = platformInfo.isCordova && !platformInfo.isWP;
|
|
||||||
$scope.isIOSApp = platformInfo.isIOS && platformInfo.isCordova;
|
|
||||||
|
|
||||||
if ($scope.isIOSApp) {
|
var updateConfig = function() {
|
||||||
try {
|
|
||||||
PushNotification.hasPermission(function(data) {
|
var config = configService.getSync();
|
||||||
$scope.PNEnabledByUser = data.isEnabled;
|
var isCordova = platformInfo.isCordova;
|
||||||
});
|
var isIOS = platformInfo.isIOS;
|
||||||
} catch (e) {
|
|
||||||
$log.error(e);
|
$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 = {
|
$scope.pushNotificationsChange = function() {
|
||||||
value: config.emailNotifications ? config.emailNotifications.enabled : false
|
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() {
|
$scope.$on("$ionicView.enter", function(event, data) {
|
||||||
if (!$scope.pushNotifications) return;
|
updateConfig();
|
||||||
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.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';
|
'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() {
|
var updateConfig = function() {
|
||||||
$scope.appName = $window.appConfig.nameCase;
|
|
||||||
|
|
||||||
var config = configService.getSync();
|
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.unitName = config.wallet.settings.unitName;
|
||||||
$scope.currentLanguageName = uxLanguage.getCurrentLanguageName();
|
$scope.currentLanguageName = uxLanguage.getCurrentLanguageName();
|
||||||
$scope.selectedAlternative = {
|
$scope.selectedAlternative = {
|
||||||
|
|
|
@ -85,10 +85,6 @@ angular.module('copayApp.services').factory('configService', function(storageSer
|
||||||
windows: {},
|
windows: {},
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
emailNotifications: {
|
|
||||||
enabled: true,
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
|
|
||||||
var configCache = null;
|
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 ng-show="PNEnabledByUser">
|
||||||
<div class="item item-divider" translate>Notifications</div>
|
<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>
|
<span class="toggle-label" translate>Enable push notifications</span>
|
||||||
</ion-toggle>
|
</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>
|
||||||
|
|
||||||
<div ng-show="!PNEnabledByUser && isIOSApp">
|
<div ng-show="!PNEnabledByUser && isIOSApp">
|
||||||
|
|
|
@ -39,7 +39,7 @@
|
||||||
|
|
||||||
<div class="item item-divider" translate>Preferences</div>
|
<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">
|
<i class="icon big-icon-svg">
|
||||||
<img src="img/icon-notifications.svg" class="bg"/>
|
<img src="img/icon-notifications.svg" class="bg"/>
|
||||||
</i>
|
</i>
|
||||||
|
|
Loading…
Reference in New Issue