fix(live-state): eliminate flash on poll by switching to innerHTML swap
outerHTML removes and re-inserts the section on each tick, causing a blank frame. Keeping the <section> as a stable DOM container and swapping only innerHTML means avatars and text update in-place without any teardown/reconstruct cycle. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
096d18ac64
commit
175e4e653c
2 changed files with 59 additions and 64 deletions
|
|
@ -1,11 +1,7 @@
|
||||||
<section class="panel live-state"
|
<h2 class="section-title">Live state</h2>
|
||||||
hx-get="/servers/{{ server.id }}/live-state"
|
{% if not snapshot or not snapshot_fresh %}
|
||||||
hx-trigger="every {{ poll_seconds }}s"
|
|
||||||
hx-swap="outerHTML">
|
|
||||||
<h2 class="section-title">Live state</h2>
|
|
||||||
{% if not snapshot or not snapshot_fresh %}
|
|
||||||
<p class="muted">No data — server is not currently reporting.</p>
|
<p class="muted">No data — server is not currently reporting.</p>
|
||||||
{% else %}
|
{% else %}
|
||||||
<p class="server-live-summary">
|
<p class="server-live-summary">
|
||||||
{{ snapshot.players }}/{{ snapshot.max_players }}
|
{{ snapshot.players }}/{{ snapshot.max_players }}
|
||||||
{% if snapshot.hibernating %}· idle{% endif %}
|
{% if snapshot.hibernating %}· idle{% endif %}
|
||||||
|
|
@ -14,9 +10,9 @@
|
||||||
polled {{ ((now - snapshot.last_seen_at).total_seconds() | int) }}s ago
|
polled {{ ((now - snapshot.last_seen_at).total_seconds() | int) }}s ago
|
||||||
</small>
|
</small>
|
||||||
</p>
|
</p>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{% if current_players %}
|
{% if current_players %}
|
||||||
<h3 class="section-subtitle">Current players</h3>
|
<h3 class="section-subtitle">Current players</h3>
|
||||||
<ul class="player-grid">
|
<ul class="player-grid">
|
||||||
{% for session, profile in current_players %}
|
{% for session, profile in current_players %}
|
||||||
|
|
@ -38,9 +34,9 @@
|
||||||
</li>
|
</li>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</ul>
|
</ul>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{% if recent_players %}
|
{% if recent_players %}
|
||||||
<h3 class="section-subtitle">Recent players</h3>
|
<h3 class="section-subtitle">Recent players</h3>
|
||||||
<ul class="player-grid recent">
|
<ul class="player-grid recent">
|
||||||
{% for row in recent_players %}
|
{% for row in recent_players %}
|
||||||
|
|
@ -61,5 +57,4 @@
|
||||||
</li>
|
</li>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</ul>
|
</ul>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</section>
|
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@
|
||||||
<section class="panel live-state"
|
<section class="panel live-state"
|
||||||
hx-get="/servers/{{ server.id }}/live-state"
|
hx-get="/servers/{{ server.id }}/live-state"
|
||||||
hx-trigger="load, every 5s"
|
hx-trigger="load, every 5s"
|
||||||
hx-swap="outerHTML">
|
hx-swap="innerHTML">
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
<h2 class="section-title">Files</h2>
|
<h2 class="section-title">Files</h2>
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue