diff --git a/features/c4game/pages/game.templ b/features/c4game/pages/game.templ index 455c91d..7d49eaf 100644 --- a/features/c4game/pages/game.templ +++ b/features/c4game/pages/game.templ @@ -18,7 +18,7 @@ templ GamePage(g *connect4.Game, myColor int, messages []chat.Message, chatCfg c data-signals="{chatMsg: ''}" data-init={ fmt.Sprintf("@get('/games/%s/events',{requestCancellation:'disabled'})", g.ID) } > - @sharedcomponents.ConnectionIndicator(0) + @sharedcomponents.ConnectionIndicatorWithScript(0) @GameContent(g, myColor, messages, chatCfg) } diff --git a/features/common/components/shared.templ b/features/common/components/shared.templ index a9b783b..a5fc089 100644 --- a/features/common/components/shared.templ +++ b/features/common/components/shared.templ @@ -54,6 +54,7 @@ func isStale(lastPing int64) bool { // ConnectionIndicator shows a small dot indicating SSE connection status. // Server patches this with a timestamp; client JS detects staleness. +// Use ConnectionIndicatorWithScript for initial render, ConnectionIndicator for patches. templ ConnectionIndicator(lastPing int64) {
+} + +// ConnectionIndicatorWithScript renders the indicator with the staleness watcher script. +// Use this for initial page render only. +templ ConnectionIndicatorWithScript(lastPing int64) { + @ConnectionIndicator(lastPing) @connectionWatcher() } diff --git a/features/snakegame/pages/game.templ b/features/snakegame/pages/game.templ index a1b2cd4..0a83165 100644 --- a/features/snakegame/pages/game.templ +++ b/features/snakegame/pages/game.templ @@ -37,7 +37,7 @@ templ GamePage(sg *snake.SnakeGame, mySlot int, messages []chat.Message, chatCfg data-on:keydown__throttle.100ms={ keydownScript(gameID) } tabindex="0" > - @components.ConnectionIndicator(0) + @components.ConnectionIndicatorWithScript(0) @GameContent(sg, mySlot, messages, chatCfg, gameID) }