Skip to content

Commit

Permalink
Prevent needless call to collages.recordAnnotatedItemState on page load
Browse files Browse the repository at this point in the history
Now that we are invalidating caches correctly, this needless call would
invalidate the cached version of a collage when it was viewed in a
browser.
  • Loading branch information
bgadoury committed Mar 24, 2017
1 parent 5d631e1 commit f363cd8
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions app/assets/javascripts/collages.js
Expand Up @@ -442,10 +442,14 @@ var collages = {
setInterval(function(i) {
var data = collages.retrieveState();
if(JSON.stringify(data) != JSON.stringify(last_data)) {
if (last_data) {
// Only fire this if it is *not* the first pass through this method.
// This prevents this method from being called on page load for no reason.
collages.recordAnnotatedItemState(JSON.stringify(data), true);
}
last_data = data;
collages.recordAnnotatedItemState(JSON.stringify(data), true);
}
}, 1000);
}, 1000);
},
loadState: function(collage_id, data) {
$.each(data, function(i, e) {
Expand Down

0 comments on commit f363cd8

Please sign in to comment.