Wallet/src/js/controllers/preferencesEmail.js

29 lines
957 B
JavaScript
Raw Normal View History

2015-05-14 17:21:45 -03:00
'use strict';
2016-09-01 17:46:56 -03:00
angular.module('copayApp.controllers').controller('preferencesEmailController', function($scope, $ionicHistory, $stateParams, $ionicNavBarDelegate, gettextCatalog, profileService, walletService, configService) {
2016-08-29 16:48:15 -03:00
$ionicNavBarDelegate.title(gettextCatalog.getString('Email Notifications'));
2016-09-01 17:46:56 -03:00
var wallet = profileService.getWallet($stateParams.walletId);
var walletId = wallet.credentials.walletId;
var config = configService.getSync();
2016-09-02 09:54:47 -03:00
config.emailFor = config.emailFor || {};
2016-09-01 17:46:56 -03:00
$scope.email = config.emailFor && config.emailFor[walletId];
$scope.save = function(form) {
2016-09-01 17:46:56 -03:00
var opts = {
emailFor: {}
};
opts.emailFor[walletId] = $scope.email;
2015-05-14 17:21:45 -03:00
2016-08-17 15:53:17 -03:00
walletService.updateRemotePreferences(wallet, {
2016-09-01 17:46:56 -03:00
email: $scope.email,
}, function(err) {
2016-08-17 15:53:17 -03:00
if (err) $log.warn(err);
2016-09-01 17:46:56 -03:00
configService.set(opts, function(err) {
if (err) $log.warn(err);
$ionicHistory.goBack();
});
});
};
});