mirror of
https://github.com/sudoxnym/habitica-self-host.git
synced 2026-07-21 21:34:15 +00:00
emit event when user is synced and update code to use it
This commit is contained in:
parent
5ddf54466c
commit
d797c21075
2 changed files with 6 additions and 4 deletions
|
|
@ -37,11 +37,10 @@ habitrpg.controller('SettingsCtrl',
|
|||
$scope.avalaibleLanguages = window.env.avalaibleLanguages;
|
||||
|
||||
$scope.changeLanguage = function(){
|
||||
User.set('preferences.language', $scope.language);
|
||||
// FIXME we wait 1sec hoping that in the meantime the server has responded to the `set`
|
||||
setTimeout(function(){
|
||||
$rootScope.$on('userSynced', function(){
|
||||
location.reload();
|
||||
}, 1000);
|
||||
});
|
||||
User.set('preferences.language', $scope.language);
|
||||
}
|
||||
|
||||
$scope.reroll = function(){
|
||||
|
|
|
|||
|
|
@ -68,6 +68,9 @@ angular.module('userServices', []).
|
|||
_.extend(user, data);
|
||||
$rootScope.$emit('userUpdated', user);
|
||||
}
|
||||
|
||||
// Emit event when user syncing ended
|
||||
$rootScope.$emit('userSynced');
|
||||
user._v = data._v;
|
||||
|
||||
// FIXME handle this somewhere else, we don't need to check every single time
|
||||
|
|
|
|||
Loading…
Reference in a new issue