move to notification settings
This commit is contained in:
parent
6ce01155d4
commit
2dace50816
5 changed files with 159 additions and 42 deletions
|
|
@ -85,6 +85,10 @@ angular.module('copayApp.services').factory('configService', function(storageSer
|
|||
windows: {},
|
||||
}
|
||||
},
|
||||
|
||||
emailNotifications: {
|
||||
enabled: false,
|
||||
},
|
||||
};
|
||||
|
||||
var configCache = null;
|
||||
|
|
|
|||
40
src/js/services/emailService.js
Normal file
40
src/js/services/emailService.js
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copayApp.services').factory('emailService', function($log, configService, profileService, lodash, walletService) {
|
||||
var root = {};
|
||||
|
||||
root.enableEmailNotifications = function(opts) {
|
||||
opts = opts || {};
|
||||
|
||||
var wallets = profileService.getWallets();
|
||||
var keys = lodash.map(wallets, function(w) {
|
||||
return w.credentials.walletId;
|
||||
});
|
||||
|
||||
lodash.each(wallets, function(w) {
|
||||
walletService.updateRemotePreferences(w, {
|
||||
email: opts.enabled ? opts.email : null
|
||||
}, function(err) {
|
||||
if (err) $log.warn(err);
|
||||
});
|
||||
});
|
||||
|
||||
var config = configService.getSync();
|
||||
if (!config.emailFor)
|
||||
config.emailFor = {};
|
||||
|
||||
lodash.each(keys, function(k) {
|
||||
config.emailFor[k] = opts.email;
|
||||
});
|
||||
|
||||
if (!opts.enabled) return;
|
||||
|
||||
configService.set({
|
||||
emailFor: config.emailFor
|
||||
}, function(err) {
|
||||
if (err) $log.debug(err);
|
||||
});
|
||||
};
|
||||
|
||||
return root;
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue