Merge pull request #38 from gabrielbazan7/fix/walletPref
fix update wallet settings
This commit is contained in:
commit
dfb213d175
3 changed files with 26 additions and 12 deletions
|
|
@ -1,17 +1,30 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
angular.module('copayApp.controllers').controller('preferencesEmailController', function($rootScope, $scope, $ionicHistory, $stateParams, $ionicNavBarDelegate, gettextCatalog, profileService, walletService) {
|
angular.module('copayApp.controllers').controller('preferencesEmailController', function($scope, $ionicHistory, $stateParams, $ionicNavBarDelegate, gettextCatalog, profileService, walletService, configService) {
|
||||||
$ionicNavBarDelegate.title(gettextCatalog.getString('Email Notifications'));
|
$ionicNavBarDelegate.title(gettextCatalog.getString('Email Notifications'));
|
||||||
|
|
||||||
|
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 email = $scope.email || '';
|
var email = $scope.email || '';
|
||||||
|
var opts = {
|
||||||
|
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);
|
||||||
$ionicHistory.goBack();
|
configService.set(opts, function(err) {
|
||||||
|
if (err) $log.warn(err);
|
||||||
|
$ionicHistory.goBack();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -122,6 +122,7 @@ angular.module('copayApp.services').factory('configService', function(storageSer
|
||||||
configCache.bwsFor = configCache.bwsFor || {};
|
configCache.bwsFor = configCache.bwsFor || {};
|
||||||
configCache.colorFor = configCache.colorFor || {};
|
configCache.colorFor = configCache.colorFor || {};
|
||||||
configCache.aliasFor = configCache.aliasFor || {};
|
configCache.aliasFor = configCache.aliasFor || {};
|
||||||
|
configCache.emailFor = configCache.emailFor || {};
|
||||||
|
|
||||||
// Coinbase
|
// Coinbase
|
||||||
// Disabled for testnet
|
// Disabled for testnet
|
||||||
|
|
|
||||||
|
|
@ -32,10 +32,11 @@ angular.module('copayApp.services')
|
||||||
var defaults = configService.getDefaults();
|
var defaults = configService.getDefaults();
|
||||||
var config = configService.getSync();
|
var config = configService.getSync();
|
||||||
|
|
||||||
wallet.usingCustomBWS = config.bwsFor[wallet.id] && (config.bwsFor[wallet.id] != defaults.bws.url);
|
wallet.usingCustomBWS = config.bwsFor && config.bwsFor[wallet.id] && (config.bwsFor[wallet.id] != defaults.bws.url);
|
||||||
|
|
||||||
wallet.name = config.aliasFor[wallet.id] || wallet.credentials.walletName;
|
wallet.name = config.aliasFor && (config.aliasFor[wallet.id] || wallet.credentials.walletName);
|
||||||
wallet.color = config.colorFor[wallet.id] || '#4A90E2';
|
wallet.color = config.colorFor && (config.colorFor[wallet.id] || '#4A90E2');
|
||||||
|
wallet.email = config.emailFor && config.emailFor[wallet.id];
|
||||||
}
|
}
|
||||||
|
|
||||||
root.setBackupFlag = function(walletId) {
|
root.setBackupFlag = function(walletId) {
|
||||||
|
|
@ -431,8 +432,8 @@ angular.module('copayApp.services')
|
||||||
|
|
||||||
// check if exist
|
// check if exist
|
||||||
if (lodash.find(root.profile.credentials, {
|
if (lodash.find(root.profile.credentials, {
|
||||||
'walletId': walletData.walletId
|
'walletId': walletData.walletId
|
||||||
})) {
|
})) {
|
||||||
return cb(gettext('Cannot join the same wallet more that once'));
|
return cb(gettext('Cannot join the same wallet more that once'));
|
||||||
}
|
}
|
||||||
} catch (ex) {
|
} catch (ex) {
|
||||||
|
|
@ -822,7 +823,6 @@ angular.module('copayApp.services')
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
var finale = shown; // GROUPING DISABLED!
|
var finale = shown; // GROUPING DISABLED!
|
||||||
|
|
||||||
// var finale = [],
|
// var finale = [],
|
||||||
|
|
@ -885,7 +885,7 @@ angular.module('copayApp.services')
|
||||||
}
|
}
|
||||||
if (j == l) {
|
if (j == l) {
|
||||||
notifications = lodash.sortBy(notifications, 'createdOn');
|
notifications = lodash.sortBy(notifications, 'createdOn');
|
||||||
notifications = lodash.compact(lodash.flatten(notifications)).slice(0,MAX);
|
notifications = lodash.compact(lodash.flatten(notifications)).slice(0, MAX);
|
||||||
return cb(null, process(notifications));
|
return cb(null, process(notifications));
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue