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-signals="{chatMsg: ''}"
|
||||||
data-init={ fmt.Sprintf("@get('/games/%s/events',{requestCancellation:'disabled'})", g.ID) }
|
data-init={ fmt.Sprintf("@get('/games/%s/events',{requestCancellation:'disabled'})", g.ID) }
|
||||||
>
|
>
|
||||||
@sharedcomponents.ConnectionIndicator(0)
|
@sharedcomponents.ConnectionIndicatorWithScript(0)
|
||||||
@GameContent(g, myColor, messages, chatCfg)
|
@GameContent(g, myColor, messages, chatCfg)
|
||||||
</main>
|
</main>
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -54,6 +54,7 @@ func isStale(lastPing int64) bool {
|
|||||||
|
|
||||||
// ConnectionIndicator shows a small dot indicating SSE connection status.
|
// ConnectionIndicator shows a small dot indicating SSE connection status.
|
||||||
// Server patches this with a timestamp; client JS detects staleness.
|
// Server patches this with a timestamp; client JS detects staleness.
|
||||||
|
// Use ConnectionIndicatorWithScript for initial render, ConnectionIndicator for patches.
|
||||||
templ ConnectionIndicator(lastPing int64) {
|
templ ConnectionIndicator(lastPing int64) {
|
||||||
<div
|
<div
|
||||||
id="connection-indicator"
|
id="connection-indicator"
|
||||||
@@ -79,6 +80,12 @@ templ ConnectionIndicator(lastPing int64) {
|
|||||||
></div>
|
></div>
|
||||||
</div>
|
</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()
|
@connectionWatcher()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ templ GamePage(sg *snake.SnakeGame, mySlot int, messages []chat.Message, chatCfg
|
|||||||
data-on:keydown__throttle.100ms={ keydownScript(gameID) }
|
data-on:keydown__throttle.100ms={ keydownScript(gameID) }
|
||||||
tabindex="0"
|
tabindex="0"
|
||||||
>
|
>
|
||||||
@components.ConnectionIndicator(0)
|
@components.ConnectionIndicatorWithScript(0)
|
||||||
@GameContent(sg, mySlot, messages, chatCfg, gameID)
|
@GameContent(sg, mySlot, messages, chatCfg, gameID)
|
||||||
</main>
|
</main>
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user