2015-05-14 10:39:22 -03:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
|
|
angular.module('copayApp.controllers').controller('preferencesAliasController',
|
2016-09-22 11:55:23 -03:00
|
|
|
function($scope, $timeout, $stateParams, $ionicHistory, gettextCatalog, configService, profileService, walletService) {
|
2016-08-17 15:53:17 -03:00
|
|
|
var wallet = profileService.getWallet($stateParams.walletId);
|
|
|
|
|
var walletId = wallet.credentials.walletId;
|
2015-05-14 10:39:22 -03:00
|
|
|
var config = configService.getSync();
|
2016-06-13 16:13:35 -03:00
|
|
|
|
2016-08-17 15:53:17 -03:00
|
|
|
$scope.walletName = wallet.credentials.walletName;
|
2016-09-23 13:30:58 -03:00
|
|
|
$scope.alias = {
|
|
|
|
|
value: (config.aliasFor && config.aliasFor[walletId]) || wallet.credentials.walletName
|
|
|
|
|
};
|
2015-05-14 10:39:22 -03:00
|
|
|
|
2016-06-13 16:13:35 -03:00
|
|
|
$scope.save = function() {
|
2015-05-14 10:39:22 -03:00
|
|
|
var opts = {
|
|
|
|
|
aliasFor: {}
|
|
|
|
|
};
|
2016-09-23 13:30:58 -03:00
|
|
|
|
|
|
|
|
opts.aliasFor[walletId] = $scope.alias.value;
|
2015-05-14 10:39:22 -03:00
|
|
|
|
|
|
|
|
configService.set(opts, function(err) {
|
2016-08-17 15:53:17 -03:00
|
|
|
if (err) $log.warn(err);
|
2016-08-29 16:48:15 -03:00
|
|
|
$ionicHistory.goBack();
|
2015-05-14 10:39:22 -03:00
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
});
|