From c5c46e8a252ec1edb9afa26af87582306cb4f5a3 Mon Sep 17 00:00:00 2001 From: Kiril Videlov Date: Wed, 15 Feb 2023 14:53:14 +0100 Subject: [PATCH] Increase selection and recording functionality - Added a button to each delta for selection - Updated the `session` store to return the first session if the sessionId is not found - Updated the `previousSession` store to return the session before the current one if it exists - Updated the `docsNext` derived store to include the `selection` store - Added an `if` statement for `files` in `+page.svelte` [src/routes/projects/[projectId]/sessions/[sessionId]/+page.ts] - Changed the import of `svelte/store` to include `writable` - Changed the `session` store to return the first session if the sessionId is not found - Changed the `previousSession` store to return the session before the current one if it exists [src/routes/projects/[projectId]/sessions/[sessionId]/+page.svelte] - Move the `Timeline` component import from `+page.svelte` - Initialize `selection` store in `+page.svelte` - Update `docsNext` derived store to include the `selection` store - Add a button to each delta for selection - Add an `if` statement for `files` in `+page.svelte` - Delete `contentWithDeltasApplied` function from `+page. --- .../sessions/[sessionId]/+page.svelte | 110 +++++++----------- .../[projectId]/sessions/[sessionId]/+page.ts | 8 +- 2 files changed, 50 insertions(+), 68 deletions(-) diff --git a/src/routes/projects/[projectId]/sessions/[sessionId]/+page.svelte b/src/routes/projects/[projectId]/sessions/[sessionId]/+page.svelte index d0b4c2abe..7cd30b38b 100644 --- a/src/routes/projects/[projectId]/sessions/[sessionId]/+page.svelte +++ b/src/routes/projects/[projectId]/sessions/[sessionId]/+page.svelte @@ -1,9 +1,8 @@
@@ -78,36 +64,30 @@ previousSesssion={$previousSesssion} />
+
- {#each Object.entries(files) as [filepath, contentAtSessionStart]} - {#if $deltas[filepath]} -
- - {filepath} - - -
- {/if} - {/each} -
-
- {#each Object.entries($deltas) as [filepath, deltas]} -
-
{filepath}
-
- {#each deltas as delta} -
- {delta.operations.length} -
- {/each} + {#each Object.entries($docsNext) as [filepath, content]} +
+ {filepath} +
+
+ {#each $deltas[filepath] as delta, i} + + {/each} +
+
-
+ {/each}
diff --git a/src/routes/projects/[projectId]/sessions/[sessionId]/+page.ts b/src/routes/projects/[projectId]/sessions/[sessionId]/+page.ts index c43f58d8c..57d138cf3 100644 --- a/src/routes/projects/[projectId]/sessions/[sessionId]/+page.ts +++ b/src/routes/projects/[projectId]/sessions/[sessionId]/+page.ts @@ -1,5 +1,5 @@ import type { PageLoad } from "./$types"; -import { derived, readable } from "svelte/store"; +import { derived, readable, writable } from "svelte/store"; import { building } from "$app/environment"; import type { Delta } from "$lib/deltas"; @@ -19,8 +19,10 @@ export const load: PageLoad = async ({ parent, params }) => { sessionId: params.sessionId, }); return { - session: derived(sessions, (sessions) => - sessions.find((session) => session.id === params.sessionId) + session: derived(sessions, (sessions) => { + const result = sessions.find((session) => session.id === params.sessionId) + return result ? result : sessions[0]; + } ), previousSesssion: derived(sessions, (sessions) => { const currentSessionIndex = sessions.findIndex(