mischief: tighten the detail page's live poll and drop dead state

The who-page poll now keeps the location line honest both ways (a mark
that came back to town stops showing its old expedition) and stops
polling once the adventurer leaves the board. Also collapses a redundant
branch in ResolveMischiefOrder and removes the always-false whoPage.Stale.
This commit is contained in:
prosolis
2026-07-14 23:12:01 -07:00
parent 16711e13e6
commit 4189c03a82
3 changed files with 18 additions and 11 deletions

View File

@@ -167,13 +167,17 @@
function txt(id, v) { var el = document.getElementById(id); if (el && v != null) el.textContent = v; }
var timer = null;
function refresh() {
fetch('/api/adventure/who/' + encodeURIComponent(token), { headers: { 'Accept': 'application/json' } })
.then(function (r) { return r.ok ? r.json() : null; })
.then(function (data) {
if (!data) return;
if (!data.live) {
// Off the board entirely (expedition ended, opted out): nothing more to
// poll for, so stop the timer rather than hammer a token that's gone.
txt('who-where', 'Back in town');
if (timer) clearInterval(timer);
return;
}
var d = data.detail || {};
@@ -187,11 +191,17 @@
txt('who-threat', d.threat_level);
setBar();
}
if (mark.OnRun) txt('who-where', mark.Where);
// Keep the location line honest in both directions: a mark that came back
// to town while still on the board must stop showing its old expedition.
if (mark.OnRun) {
txt('who-where', mark.Where);
} else {
txt('who-where', 'In town' + (mark.Idle ? ' · ' + mark.Idle : ''));
}
})
.catch(function () { /* transient — next tick will do */ });
}
setInterval(refresh, 60000);
timer = setInterval(refresh, 60000);
})();
</script>
{{end}}