Merge pull request #6025 from cmgustavo/ref/pref-email-01
Ref/pref email 01
This commit is contained in:
commit
459c005a46
6 changed files with 79 additions and 68 deletions
|
|
@ -1,6 +1,6 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copayApp.controllers').controller('collectEmailController', function($scope, $state, $log, $timeout, $http, $httpParamSerializer, $ionicConfig, profileService, configService, walletService, appConfigService) {
|
||||
angular.module('copayApp.controllers').controller('collectEmailController', function($scope, $state, $log, $timeout, $http, $httpParamSerializer, $ionicConfig, profileService, configService, walletService, appConfigService, emailService) {
|
||||
|
||||
var wallet, walletId;
|
||||
$scope.data = {};
|
||||
|
|
@ -48,22 +48,18 @@ angular.module('copayApp.controllers').controller('collectEmailController', func
|
|||
};
|
||||
|
||||
$scope.save = function() {
|
||||
var opts = {
|
||||
emailFor: {}
|
||||
};
|
||||
opts.emailFor[walletId] = $scope.data.email;
|
||||
walletService.updateRemotePreferences(wallet, {
|
||||
email: $scope.data.email,
|
||||
}, function(err) {
|
||||
if (err) return;
|
||||
configService.set(opts, function(err) {
|
||||
if (err) $log.warn(err);
|
||||
if ($scope.data.accept) collectEmail();
|
||||
$timeout(function() {
|
||||
$scope.goNextView();
|
||||
}, 200);
|
||||
});
|
||||
var enabled = true; // Set enabled email: true
|
||||
|
||||
emailService.updateEmail({
|
||||
enabled: enabled,
|
||||
email: enabled ? $scope.data.email : null
|
||||
});
|
||||
|
||||
if ($scope.data.accept) collectEmail();
|
||||
|
||||
$timeout(function() {
|
||||
$scope.goNextView();
|
||||
}, 200);
|
||||
};
|
||||
|
||||
$scope.goNextView = function() {
|
||||
|
|
|
|||
|
|
@ -1,10 +1,9 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copayApp.controllers').controller('preferencesController',
|
||||
function($scope, $rootScope, $timeout, $log, $stateParams, $ionicHistory, configService, profileService, fingerprintService, walletService) {
|
||||
var wallet = profileService.getWallet($stateParams.walletId);
|
||||
var walletId = wallet.credentials.walletId;
|
||||
$scope.wallet = wallet;
|
||||
function($scope, $rootScope, $timeout, $log, $ionicHistory, configService, profileService, fingerprintService, walletService) {
|
||||
var wallet;
|
||||
var walletId;
|
||||
|
||||
$scope.encryptEnabled = {
|
||||
value: walletService.isEncrypted(wallet)
|
||||
|
|
@ -78,6 +77,10 @@ angular.module('copayApp.controllers').controller('preferencesController',
|
|||
};
|
||||
|
||||
$scope.$on("$ionicView.beforeEnter", function(event, data) {
|
||||
wallet = profileService.getWallet(data.stateParams.walletId);
|
||||
walletId = wallet.credentials.walletId;
|
||||
$scope.wallet = wallet;
|
||||
|
||||
$scope.externalSource = null;
|
||||
|
||||
if (!wallet)
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copayApp.controllers').controller('preferencesNotificationsController', function($scope, $log, $timeout, appConfigService, lodash, configService, platformInfo, pushNotificationsService, profileService, emailService) {
|
||||
angular.module('copayApp.controllers').controller('preferencesNotificationsController', function($scope, $log, $timeout, appConfigService, lodash, configService, platformInfo, pushNotificationsService, emailService) {
|
||||
var updateConfig = function() {
|
||||
var config = configService.getSync();
|
||||
$scope.appName = appConfigService.nameCase;
|
||||
|
|
@ -13,7 +13,7 @@ angular.module('copayApp.controllers').controller('preferencesNotificationsContr
|
|||
};
|
||||
|
||||
$scope.latestEmail = {
|
||||
value: getLatestEmailConfig()
|
||||
value: emailService.getEmailIfEnabled()
|
||||
};
|
||||
|
||||
$scope.newEmail = lodash.clone($scope.latestEmail);
|
||||
|
|
@ -44,33 +44,19 @@ angular.module('copayApp.controllers').controller('preferencesNotificationsContr
|
|||
|
||||
$scope.emailNotificationsChange = function() {
|
||||
var opts = {
|
||||
emailNotifications: {
|
||||
enabled: $scope.emailNotifications.value
|
||||
}
|
||||
enabled: $scope.emailNotifications.value,
|
||||
email: $scope.newEmail.value
|
||||
};
|
||||
configService.set(opts, function(err) {
|
||||
if (err) $log.debug(err);
|
||||
});
|
||||
|
||||
$scope.latestEmail = {
|
||||
value: getLatestEmailConfig()
|
||||
value: emailService.getEmailIfEnabled()
|
||||
};
|
||||
|
||||
$scope.newEmail = lodash.clone($scope.latestEmail);
|
||||
|
||||
if (!$scope.emailNotifications.value) {
|
||||
emailService.enableEmailNotifications({
|
||||
enabled: $scope.emailNotifications.value,
|
||||
email: null
|
||||
});
|
||||
}
|
||||
$timeout(function() {
|
||||
$scope.$apply();
|
||||
});
|
||||
emailService.updateEmail(opts);
|
||||
};
|
||||
|
||||
$scope.save = function() {
|
||||
emailService.enableEmailNotifications({
|
||||
emailService.updateEmail({
|
||||
enabled: $scope.emailNotifications.value,
|
||||
email: $scope.newEmail.value
|
||||
});
|
||||
|
|
@ -84,11 +70,6 @@ angular.module('copayApp.controllers').controller('preferencesNotificationsContr
|
|||
});
|
||||
};
|
||||
|
||||
function getLatestEmailConfig() {
|
||||
var config = configService.getSync();
|
||||
return config.emailFor ? lodash.values(config.emailFor)[0] : null;
|
||||
};
|
||||
|
||||
$scope.$on("$ionicView.enter", function(event, data) {
|
||||
updateConfig();
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue