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:
Tyler Renelle
2013-12-15 12:11:25 -07:00
parent bc0034f022
commit 774775de7a
3 changed files with 20 additions and 12 deletions

View File

@@ -11,6 +11,7 @@ habitrpg.controller("RootCtrl", ['$scope', '$rootScope', '$location', 'User', '$
$rootScope.modals.achievements = {}; $rootScope.modals.achievements = {};
$rootScope.User = User; $rootScope.User = User;
$rootScope.user = user; $rootScope.user = user;
$rootScope.moment = window.moment;
$rootScope.settings = User.settings; $rootScope.settings = User.settings;
$rootScope.Shared = window.habitrpgShared; $rootScope.Shared = window.habitrpgShared;
$rootScope.Content = window.habitrpgShared.content; $rootScope.Content = window.habitrpgShared.content;

View File

@@ -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. 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) { .error(function (data, status, headers, config) {
if(status === 400 && data.needRefresh === true){ // In the case of errors, discard the corrupt queue
alert("The site has been updated and the page needs to refresh. " + if (status >= 400) {
"The last action has not been recorded, please do it again once the page reloads." 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.text("No Connection");
} }
//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"})
}); });
} }

View File

@@ -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) // Icons only available if you own the tasks (aka, hidden from challenge stats)
span(ng-if='!obj._locked') 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 // edit
a(ng-hide='task._editing', ng-click='editTask(task)', tooltip='Edit') a(ng-hide='task._editing', ng-click='editTask(task)', tooltip='Edit')
i.icon-pencil(ng-hide='task._editing') i.icon-pencil(ng-hide='task._editing')