From fa8f95f70576590f585472315534f69987a9b812 Mon Sep 17 00:00:00 2001 From: Nikita Galaiko Date: Fri, 24 Mar 2023 13:30:59 +0100 Subject: [PATCH] player: refactor day selector css/js --- .../projects/[projectId]/player/+page.svelte | 99 +++++++++---------- 1 file changed, 46 insertions(+), 53 deletions(-) diff --git a/src/routes/projects/[projectId]/player/+page.svelte b/src/routes/projects/[projectId]/player/+page.svelte index 195b55c9a..c8be022f2 100644 --- a/src/routes/projects/[projectId]/player/+page.svelte +++ b/src/routes/projects/[projectId]/player/+page.svelte @@ -218,23 +218,18 @@ return format(new Date(dateString), 'MMM'); } - function selectDay(day: string) { - return () => { - $currentDay = day; - showLatest = false; - currentDeltasIndex = 0; - stop(); - }; - } + const selectDay = (day: string, latest = false) => { + showLatest = latest; + currentDeltasIndex = 0; + stop(); + $page.url.searchParams.set('date', day); + goto($page.url.href); + }; - function selectLatest() { - return () => { - showLatest = true; - $currentDay = Object.keys($sessionDays)[0]; // get latest day - currentDeltasIndex = 0; - stop(); - }; - } + const selectLatestDay = () => { + const latestDay = Object.keys($sessionDays)[0]; + selectDay(latestDay, true); + }; type EditFrame = { sessionId: string; @@ -248,7 +243,7 @@ let currentPlaylist: DayVideo | null = null; let currentEdit: EditFrame | null = null; - $: if (currentDay && dayPlaylist && dayPlaylist[$currentDay]) { + $: if ($currentDay && dayPlaylist && dayPlaylist[$currentDay]) { currentPlaylist = dayPlaylist[$currentDay]; if (currentPlaylist !== null) { if (showLatest) { @@ -356,9 +351,6 @@ speed = speed * 2; start({ direction, speed }); }; - - // - function handleKey() {} {#if $sessions.length === 0} @@ -377,33 +369,35 @@ {/if}
-
-
-
+
  • +
  • - {#each Object.entries($sessionDays) as [day, sessions]} -
    + + {#each Object.keys($sessionDays) as day} +
  • +
  • - {/each} -
    -
    + + + {/each} + + {/if} {/each}
    @@ -558,15 +551,15 @@
    {#if interval} - + /> + {:else} - + {/if}