[object Object]

← back to Crazy News Channel

Re-anchor saved story offsets on load so admin stories keep escalating after a reload

4459222b1927e1ebaab2961b697e96b05966830b · 2026-09-23 15:43:26 -0700 · Steve Abrams

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VLjoHsyGTDeVCa1rdrAxnk

Files touched

Diff

commit 4459222b1927e1ebaab2961b697e96b05966830b
Author: Steve Abrams <steve@designerwallcoverings.com>
Date:   Wed Sep 23 15:43:26 2026 -0700

    Re-anchor saved story offsets on load so admin stories keep escalating after a reload
    
    Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
    Claude-Session: https://claude.ai/code/session_01VLjoHsyGTDeVCa1rdrAxnk
---
 index.html | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/index.html b/index.html
index 445df7a..1f67b2b 100644
--- a/index.html
+++ b/index.html
@@ -798,7 +798,16 @@ function loadStories() {
       Array.isArray(s.stages) && s.stages.length > 0 &&
       typeof s.stageIndex === "number"
     );
-    return isValidShape ? parsed : cloneStories(DEFAULT_STORIES);
+    if (!isValidShape) return cloneStories(DEFAULT_STORIES);
+    // offsetSec was measured against the PREVIOUS session's clock, but
+    // state.elapsedSec restarts at 0 on every load. Fold it back into one
+    // interval so the story keeps its phase instead of stalling for
+    // offsetSec seconds after a reload.
+    parsed.forEach((s) => {
+      const interval = s.intervalSec > 0 ? s.intervalSec : 1;
+      s.offsetSec = (Number(s.offsetSec) || 0) % interval;
+    });
+    return parsed;
   } catch (err) {
     return cloneStories(DEFAULT_STORIES);
   }

← c180c52 Add admin panel: create/delete/reset controls for breaking s  ·  back to Crazy News Channel  ·  Add full Onion-style articles: hash-routed article view + fe ad547da →