Compare commits
1 Commits
v0.1.8
...
0e344de9c1
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0e344de9c1 |
@@ -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)
|
||||
</main>
|
||||
}
|
||||
|
||||
@@ -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) {
|
||||
<div
|
||||
id="connection-indicator"
|
||||
@@ -79,6 +80,12 @@ templ ConnectionIndicator(lastPing int64) {
|
||||
></div>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
|
||||
// ConnectionIndicatorWithScript renders the indicator with the staleness watcher script.
|
||||
// Use this for initial page render only.
|
||||
templ ConnectionIndicatorWithScript(lastPing int64) {
|
||||
@ConnectionIndicator(lastPing)
|
||||
@connectionWatcher()
|
||||
}
|
||||
|
||||
|
||||
@@ -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)
|
||||
</main>
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user