Simplify leaderboard rows and defer disruptive refreshes

This commit is contained in:
2026-10-06 19:12:25 -04:00
parent 01d764946c
commit 1370873cba
6 changed files with 234 additions and 70 deletions
+27
View File
@@ -0,0 +1,27 @@
import type { LeaderboardResponse } from './leaderboard.js';
export const leaderboardPageSize = 25;
/** Keep a viewed ranking stable until the reader chooses to apply new results. */
export function createLeaderboardUpdates(scope: string, current: LeaderboardResponse) {
let pending: LeaderboardResponse | null = null;
return {
reset(nextScope: string, report: LeaderboardResponse) {
scope = nextScope;
current = report;
pending = null;
},
receive(requestScope: string, report: LeaderboardResponse, inspecting: boolean) {
if (requestScope !== scope) return null;
if (JSON.stringify(current) === JSON.stringify(report)) pending = null;
else if (inspecting || pending) pending = report;
else current = report;
return { current, pending };
},
apply() {
if (pending) current = pending;
pending = null;
return current;
}
};
}
+8 -6
View File
@@ -1,23 +1,25 @@
<script lang="ts">
import type { RecordEvidence } from '$lib/leaderboard.js';
import { timeFormat } from '$ui/stores/time-zone.js';
import { contextHref } from '$lib/navigation-context.js';
let { evidence }: { evidence: RecordEvidence } = $props();
let { evidence, returnTo, disclosure = true }: { evidence: RecordEvidence; returnTo?: string; disclosure?: boolean } = $props();
const gameName = $derived(evidence.game === 't5' ? 'Black Ops I' : 'Black Ops II');
</script>
<div class="record-source">
<a href={`/matches/${evidence.matchId}`}>{evidence.mapName} · {gameName}</a>
<a href={returnTo ? contextHref(`/matches/${evidence.matchId}`, returnTo) : `/matches/${evidence.matchId}`}>{evidence.mapName} · {gameName}</a>
<span>{#if evidence.endedAt}Completed <time datetime={evidence.endedAt}>{$timeFormat.dateTime(evidence.endedAt)}</time>{:else}Completed · End time unknown{/if}</span>
<details>
<summary>Run details</summary>
{#snippet runDetails()}
<dl>
<div><dt>Server</dt><dd>{evidence.server}</dd></div>
<div><dt>Instance</dt><dd>{evidence.server}</dd></div>
<div><dt>{evidence.startObserved ? 'Match started' : 'Match first observed'}</dt><dd><time datetime={evidence.startedAt}>{$timeFormat.dateTime(evidence.startedAt)}</time></dd></div>
<div><dt>Player participation</dt><dd>{evidence.presentAtStart ? 'Present at recorded start' : evidence.firstObservedRound === null ? 'Participation start unknown' : `First observed at round ${evidence.firstObservedRound}`}</dd></div>
</dl>
<p>Recorded presence does not establish continuous survival.</p>
</details>
{/snippet}
{#if disclosure}<details><summary>Run details</summary>{@render runDetails()}</details>
{:else}{@render runDetails()}{/if}
</div>
<style>