Commit ca77e8b7 authored by csillag's avatar csillag

Fix extremely slow auto-update of ancient timestamps

When a timestamp is several months old, and we leave
the application around (in a forgotten tab) for
more than three weeks, the usual method of updating
the timestamp fails.

This change works around that by maxing out our timeouts
at 24 days. (This will simply cause us to check the
time in every 24 days.)

Fixes #1952.

I also moved the 5-second minimum to the same time helper.
parent 254a069a
......@@ -237,7 +237,6 @@ AnnotationController = [
updateTimestamp = (repeat=false) =>
@timestamp = timeHelpers.toFuzzyString model.updated
fuzzyUpdate = timeHelpers.nextFuzzyUpdate model.updated
fuzzyUpdate = 5 if fuzzyUpdate < 5 # minimum 5 seconds
nextUpdate = (1000 * fuzzyUpdate) + 500
return unless repeat
$timeout =>
......
......@@ -49,7 +49,15 @@ createTimeHelpers = ->
return null if not date
{_, breakpoint} = getBreakpoint(date)
return null unless breakpoint
return breakpoint[2]
secs = breakpoint[2]
# We don't want to refresh anything more often than 5 seconds
secs = Math.max secs, 5
# setTimeout limit is MAX_INT32=(2^31-1) (in ms),
# which is about 24.8 days. So we don't set up any timeouts
# longer than 24 days, that is, 2073600 seconds.
secs = Math.min secs, 2073600
angular.module('h.helpers')
.factory('timeHelpers', createTimeHelpers)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment