mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-19 15:48:04 +01:00
fixes: appliedTags, add moment to rootScope (repeat i18n issues). Also,
discard the sync-queue if errors were detected. Previously, if an op triggered server error, the op is still in the queue and will keep trying. Thus, in-browser user is corrupt - they'll need to logout / clear localStorage. This *should* fix that, while still allowing the sync-queue to build up when offline (status appears to == 0 in those cases). @paglias just FYI - should be good, but wanna loop you in just in case.
This commit is contained in:
@@ -11,6 +11,7 @@ habitrpg.controller("RootCtrl", ['$scope', '$rootScope', '$location', 'User', '$
|
||||
$rootScope.modals.achievements = {};
|
||||
$rootScope.User = User;
|
||||
$rootScope.user = user;
|
||||
$rootScope.moment = window.moment;
|
||||
$rootScope.settings = User.settings;
|
||||
$rootScope.Shared = window.habitrpgShared;
|
||||
$rootScope.Content = window.habitrpgShared.content;
|
||||
|
||||
@@ -97,19 +97,26 @@ angular.module('userServices', []).
|
||||
syncQueue(); // call syncQueue to check if anyone pushed more actions to the queue while we were talking to server.
|
||||
})
|
||||
.error(function (data, status, headers, config) {
|
||||
if(status === 400 && data.needRefresh === true){
|
||||
alert("The site has been updated and the page needs to refresh. " +
|
||||
"The last action has not been recorded, please do it again once the page reloads."
|
||||
);
|
||||
// In the case of errors, discard the corrupt queue
|
||||
if (status >= 400) {
|
||||
data =
|
||||
data.needRefresh ? "The site has been updated and the page needs to refresh. The last action has not been recorded, please refresh and try again." :
|
||||
data ? data :
|
||||
'Something went wrong, please refresh your browser or upgrade the mobile app';
|
||||
alert(data);
|
||||
// Clear the queue. Better if we can hunt down the problem op, but this is the easiest solution
|
||||
settings.sync.queue = settings.sync.sent = [];
|
||||
save();
|
||||
|
||||
return location.reload();
|
||||
}
|
||||
// But if we're offline, queue up offline actions so we can send when we're back online
|
||||
} else {
|
||||
//move sent actions back to queue
|
||||
_.times(sent.length, function () {
|
||||
queue.push(sent.shift())
|
||||
});
|
||||
settings.fetching = false;
|
||||
//Notification.push({type:'text', text:"We're offline"})
|
||||
//Notification.text("No Connection");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ li(bindonce='list', ng-repeat='task in obj[list.type+"s"]', class='task {{Shared
|
||||
|
||||
// Icons only available if you own the tasks (aka, hidden from challenge stats)
|
||||
span(ng-if='!obj._locked')
|
||||
i.icon-tags(tooltip='{{appliedTags(user.tags, task.tags)}}', ng-hide='noTags(task.tags)')
|
||||
i.icon-tags(tooltip='{{appliedTags(user.tags, task.tags)}}', ng-hide='Shared.noTags(task.tags)')
|
||||
// edit
|
||||
a(ng-hide='task._editing', ng-click='editTask(task)', tooltip='Edit')
|
||||
i.icon-pencil(ng-hide='task._editing')
|
||||
|
||||
Reference in New Issue
Block a user