mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-19 15:48:04 +01:00
[#1977] APIv2 WIP - start of a framework where operations are shared
between client & server. If the op is called on the client, it updates the user & then POSTs to the server with op of the same name. If called on server, it updates the user and user.save()s
This commit is contained in:
@@ -16,13 +16,13 @@ habitrpg.controller('SettingsCtrl',
|
||||
// }
|
||||
|
||||
$scope.showTour = function(){
|
||||
User.set('flags.showTour',true);
|
||||
User.set({'flags.showTour':true});
|
||||
Guide.initTour();
|
||||
$location.path('/tasks');
|
||||
}
|
||||
|
||||
$scope.showBailey = function(){
|
||||
User.set('flags.newStuff',true);
|
||||
User.set({'flags.newStuff':true});
|
||||
}
|
||||
|
||||
$scope.saveDayStart = function(){
|
||||
@@ -31,7 +31,7 @@ habitrpg.controller('SettingsCtrl',
|
||||
dayStart = 0;
|
||||
return alert('Please enter a number between 0 and 24');
|
||||
}
|
||||
User.set('preferences.dayStart', dayStart);
|
||||
User.set({'preferences.dayStart': dayStart});
|
||||
}
|
||||
|
||||
$scope.language = window.env.language;
|
||||
@@ -41,7 +41,7 @@ habitrpg.controller('SettingsCtrl',
|
||||
$rootScope.$on('userSynced', function(){
|
||||
location.reload();
|
||||
});
|
||||
User.set('preferences.language', $scope.language.code);
|
||||
User.set({'preferences.language': $scope.language.code});
|
||||
}
|
||||
|
||||
$scope.reroll = function(){
|
||||
@@ -74,24 +74,18 @@ habitrpg.controller('SettingsCtrl',
|
||||
$rootScope.$watch('modals.restore', function(value){
|
||||
if(value === true){
|
||||
$scope.restoreValues.stats = angular.copy(User.user.stats);
|
||||
// $scope.restoreValues.items = angular.copy(User.user.items);
|
||||
$scope.restoreValues.achievements = {streak: User.user.achievements.streak || 0};
|
||||
}
|
||||
})
|
||||
|
||||
$scope.restore = function(){
|
||||
var stats = $scope.restoreValues.stats,
|
||||
// items = $scope.restoreValues.items,
|
||||
achievements = $scope.restoreValues.achievements;
|
||||
User.setMultiple({
|
||||
User.set({
|
||||
"stats.hp": stats.hp,
|
||||
"stats.exp": stats.exp,
|
||||
"stats.gp": stats.gp,
|
||||
"stats.lvl": stats.lvl,
|
||||
// "items.weapon": items.weapon,
|
||||
// "items.armor": items.armor,
|
||||
// "items.head": items.head,
|
||||
// "items.shield": items.shield,
|
||||
"achievements.streak": achievements.streak
|
||||
});
|
||||
$rootScope.modals.restore = false;
|
||||
|
||||
Reference in New Issue
Block a user