fix email onboarding
This commit is contained in:
parent
3a933959c1
commit
314532c62a
2 changed files with 18 additions and 8 deletions
|
|
@ -1,22 +1,33 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
angular.module('copayApp.controllers').controller('collectEmailController', function($scope, $state, $stateParams, profileService, walletService, platformInfo) {
|
angular.module('copayApp.controllers').controller('collectEmailController', function($scope, $state, $stateParams, profileService, configService, walletService, platformInfo) {
|
||||||
|
|
||||||
var isCordova = platformInfo.isCordova;
|
var isCordova = platformInfo.isCordova;
|
||||||
var isWP = platformInfo.isWP;
|
var isWP = platformInfo.isWP;
|
||||||
var usePushNotifications = isCordova && !isWP;
|
var usePushNotifications = isCordova && !isWP;
|
||||||
|
|
||||||
|
var wallet = profileService.getWallet($stateParams.walletId);
|
||||||
|
var walletId = wallet.credentials.walletId;
|
||||||
|
|
||||||
|
var config = configService.getSync();
|
||||||
|
config.emailFor = config.emailFor || {};
|
||||||
|
$scope.email = config.emailFor && config.emailFor[walletId];
|
||||||
|
|
||||||
$scope.save = function(form) {
|
$scope.save = function(form) {
|
||||||
var wallet = profileService.getWallet($stateParams.walletId);
|
var opts = {
|
||||||
var email = $scope.email || '';
|
emailFor: {}
|
||||||
|
};
|
||||||
|
opts.emailFor[walletId] = $scope.email;
|
||||||
|
|
||||||
walletService.updateRemotePreferences(wallet, {
|
walletService.updateRemotePreferences(wallet, {
|
||||||
email: email,
|
email: $scope.email,
|
||||||
}, function(err) {
|
}, function(err) {
|
||||||
if (err) $log.warn(err);
|
if (err) $log.warn(err);
|
||||||
if (!usePushNotifications) $state.go('onboarding.backupRequest');
|
configService.set(opts, function(err) {
|
||||||
else $state.go('onboarding.notifications');
|
if (err) $log.warn(err);
|
||||||
|
if (!usePushNotifications) $state.go('onboarding.backupRequest');
|
||||||
|
else $state.go('onboarding.notifications');
|
||||||
|
});
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,6 @@ angular.module('copayApp.controllers').controller('preferencesEmailController',
|
||||||
$scope.email = config.emailFor && config.emailFor[walletId];
|
$scope.email = config.emailFor && config.emailFor[walletId];
|
||||||
|
|
||||||
$scope.save = function(form) {
|
$scope.save = function(form) {
|
||||||
var email = $scope.email || '';
|
|
||||||
var opts = {
|
var opts = {
|
||||||
emailFor: {}
|
emailFor: {}
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue