Preserve originating views through detail navigation
This commit is contained in:
@@ -1,4 +1,7 @@
|
||||
<script lang="ts">
|
||||
import { page } from '$app/stores';
|
||||
import { contextHref } from '$lib/navigation-context.js';
|
||||
import { goto } from '$app/navigation';
|
||||
import { timeFormat } from '$ui/stores/time-zone.js';
|
||||
import type { ServerMatch } from '$lib/match-history.js';
|
||||
import { pollVisible } from '$ui/poll.js';
|
||||
@@ -13,6 +16,12 @@
|
||||
let matches = $state<ServerMatch[]>([]);
|
||||
let total = $state(0);
|
||||
let limit = $state(25);
|
||||
$effect(() => { limit = Math.min(10000, Math.max(25, Number($page.url.searchParams.get('matches')) || 25)); });
|
||||
function saveContext() {
|
||||
const url = new URL($page.url);
|
||||
if (limit > 25) url.searchParams.set('matches', String(limit)); else url.searchParams.delete('matches');
|
||||
void goto(url, { replaceState: true, noScroll: true, keepFocus: true });
|
||||
}
|
||||
let loading = $state(true);
|
||||
let error = $state('');
|
||||
|
||||
@@ -63,7 +72,7 @@
|
||||
{#if server === undefined}<td><HistoricalServerIdentity name={match.server} deletedAt={match.server_deleted_at} href={`/servers/${encodeURIComponent(match.server)}?tab=matches`} /></td>{/if}
|
||||
<td>
|
||||
{#if match.status === 'completed'}
|
||||
<a class="match-link" href={`/matches/${match.id}`} aria-label={`View ${match.map} match from ${$timeFormat.dateTime(match.startedAt)}`}>
|
||||
<a class="match-link" href={contextHref(`/matches/${match.id}`, $page.url)} aria-label={`View ${match.map} match from ${$timeFormat.dateTime(match.startedAt)}`}>
|
||||
{match.map}<small>View match →</small>
|
||||
</a>
|
||||
{:else}{match.map}{/if}
|
||||
@@ -76,7 +85,7 @@
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<ListFooter total={Math.min(total, 10000)} bind:limit label="matches" />
|
||||
<ListFooter total={Math.min(total, 10000)} bind:limit onchange={saveContext} label="matches" />
|
||||
{#if total > 10000}<p>Showing the latest 10,000 matches.</p>{/if}
|
||||
{/if}
|
||||
</Card>
|
||||
|
||||
Reference in New Issue
Block a user