2016-08-25 16:31:47 -03:00
|
|
|
'use strict';
|
|
|
|
|
|
2017-04-27 12:03:32 -03:00
|
|
|
angular.module('copayApp.controllers').controller('collectEmailController', function($scope, $state, $timeout, profileService, configService, walletService) {
|
2016-08-29 11:56:31 -03:00
|
|
|
|
2017-04-27 12:03:32 -03:00
|
|
|
var wallet, walletId;
|
|
|
|
|
$scope.data = {};
|
2017-02-23 14:26:05 -05:00
|
|
|
|
2017-04-27 12:03:32 -03:00
|
|
|
$scope.$on("$ionicView.beforeEnter", function(event, data) {
|
|
|
|
|
walletId = data.stateParams.walletId;
|
|
|
|
|
wallet = profileService.getWallet(walletId);
|
|
|
|
|
$scope.data.accept = true;
|
2017-02-23 14:26:05 -05:00
|
|
|
});
|
|
|
|
|
|
2016-09-09 11:14:04 -03:00
|
|
|
$scope.save = function() {
|
2016-09-02 11:15:03 -03:00
|
|
|
var opts = {
|
|
|
|
|
emailFor: {}
|
|
|
|
|
};
|
2017-04-27 12:03:32 -03:00
|
|
|
opts.emailFor[walletId] = $scope.data.email;
|
2016-08-25 16:31:47 -03:00
|
|
|
walletService.updateRemotePreferences(wallet, {
|
2017-04-27 12:03:32 -03:00
|
|
|
email: $scope.data.email,
|
2016-08-25 16:31:47 -03:00
|
|
|
}, function(err) {
|
|
|
|
|
if (err) $log.warn(err);
|
2016-09-02 11:15:03 -03:00
|
|
|
configService.set(opts, function(err) {
|
|
|
|
|
if (err) $log.warn(err);
|
2016-09-13 23:25:50 -03:00
|
|
|
$scope.goNextView();
|
2016-09-02 11:15:03 -03:00
|
|
|
});
|
2016-08-25 16:31:47 -03:00
|
|
|
});
|
|
|
|
|
};
|
2016-09-02 13:00:38 -03:00
|
|
|
|
2016-09-13 23:25:50 -03:00
|
|
|
$scope.goNextView = function() {
|
2017-04-18 11:26:15 -03:00
|
|
|
$state.go('onboarding.backupRequest', {
|
|
|
|
|
walletId: walletId
|
|
|
|
|
});
|
2016-09-13 17:12:17 -03:00
|
|
|
};
|
|
|
|
|
|
2016-09-09 11:14:04 -03:00
|
|
|
$scope.confirm = function(emailForm) {
|
|
|
|
|
if (emailForm.$invalid) return;
|
|
|
|
|
$scope.confirmation = true;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
$scope.cancel = function() {
|
|
|
|
|
$scope.confirmation = false;
|
|
|
|
|
$timeout(function() {
|
|
|
|
|
$scope.$digest();
|
|
|
|
|
}, 1);
|
|
|
|
|
};
|
|
|
|
|
|
2016-08-25 16:31:47 -03:00
|
|
|
});
|