2015-04-22 15:19:08 -03:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
|
|
angular.module('copayApp.controllers').controller('preferencesLanguageController',
|
2016-09-22 11:55:23 -03:00
|
|
|
function($scope, $log, $ionicHistory, gettextCatalog, configService, profileService, uxLanguage, walletService, externalLinkService) {
|
|
|
|
|
|
|
|
|
|
$scope.availableLanguages = uxLanguage.getLanguages();
|
2015-04-22 15:19:08 -03:00
|
|
|
|
2016-12-08 16:00:03 -03:00
|
|
|
$scope.openExternalLink = function(url, optIn, title, message, okText, cancelText) {
|
|
|
|
|
externalLinkService.open(url, optIn, title, message, okText, cancelText);
|
2016-09-05 14:59:11 -03:00
|
|
|
};
|
|
|
|
|
|
2016-06-10 09:35:44 -03:00
|
|
|
$scope.save = function(newLang) {
|
2015-06-29 21:46:34 -03:00
|
|
|
var opts = {
|
|
|
|
|
wallet: {
|
|
|
|
|
settings: {
|
|
|
|
|
defaultLanguage: newLang
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
configService.set(opts, function(err) {
|
|
|
|
|
if (err) $log.warn(err);
|
2016-06-06 18:26:45 -03:00
|
|
|
|
2016-08-29 16:48:15 -03:00
|
|
|
$ionicHistory.goBack();
|
2016-09-05 11:54:14 -03:00
|
|
|
uxLanguage.init(function() {
|
2016-08-23 12:01:09 -03:00
|
|
|
walletService.updateRemotePreferences(profileService.getWallets(), {}, function() {
|
2016-06-09 17:20:17 -03:00
|
|
|
$log.debug('Remote preferences saved');
|
|
|
|
|
});
|
2016-06-06 18:26:45 -03:00
|
|
|
});
|
2015-06-29 21:46:34 -03:00
|
|
|
});
|
2015-04-22 15:19:08 -03:00
|
|
|
};
|
2016-09-22 11:55:23 -03:00
|
|
|
|
2016-12-08 16:00:03 -03:00
|
|
|
$scope.$on("$ionicView.enter", function(event, data) {
|
2016-09-22 11:55:23 -03:00
|
|
|
$scope.currentLanguage = uxLanguage.getCurrentLanguage();
|
|
|
|
|
});
|
2015-04-22 15:19:08 -03:00
|
|
|
});
|