From 9a7f6e242104886b8a5da5bae12c9864f579117d Mon Sep 17 00:00:00 2001 From: Chukwuma Nwaugha Date: Mon, 11 Nov 2024 17:21:06 +0000 Subject: [PATCH] use render_media component for both audio and video elements --- ...derAudiocast.svelte => RenderMedia.svelte} | 23 +++++++------- app/src/lib/components/Sidebar.svelte | 3 +- app/src/lib/components/SidebarItem.svelte | 3 +- app/src/routes/audiocast/+page.server.ts | 2 ++ .../[sessionId=sessionId]/+page.svelte | 31 ++++++++++++++----- 5 files changed, 40 insertions(+), 22 deletions(-) rename app/src/lib/components/{RenderAudiocast.svelte => RenderMedia.svelte} (53%) create mode 100644 app/src/routes/audiocast/+page.server.ts diff --git a/app/src/lib/components/RenderAudiocast.svelte b/app/src/lib/components/RenderMedia.svelte similarity index 53% rename from app/src/lib/components/RenderAudiocast.svelte rename to app/src/lib/components/RenderMedia.svelte index e399422..97cb562 100644 --- a/app/src/lib/components/RenderAudiocast.svelte +++ b/app/src/lib/components/RenderMedia.svelte @@ -6,10 +6,10 @@ import { env } from '@env'; import Spinner from './Spinner.svelte'; - export let sessionId: String; + export let filename: String; async function getSignedURL() { - const blobname = `${BLOB_BASE_URI}/${sessionId}`; + const blobname = `${BLOB_BASE_URI}/${filename}`; return fetch(`${env.API_BASE_URL}/get-signed-url?blobname=${blobname}`).then((res) => { if (res.ok) return res.json(); throw new Error('Failed to get signed Audiocast URL'); @@ -17,13 +17,12 @@ } -{#await getSignedURL()} - -{:then audioURL} - -{:catch error} -
{String(error)}
-{/await} +
+ {#await getSignedURL()} + + {:then uri} + + {:catch error} +
{String(error)}
+ {/await} +
diff --git a/app/src/lib/components/Sidebar.svelte b/app/src/lib/components/Sidebar.svelte index 44b3b66..cc5cd8e 100644 --- a/app/src/lib/components/Sidebar.svelte +++ b/app/src/lib/components/Sidebar.svelte @@ -26,7 +26,8 @@ .map(([sessionId, item]) => ({ title: item.title || 'Untitled', nonce: item.nonce, - href: `/chat/${sessionId}?category=${item.category}` + href: `/chat/${sessionId}?category=${item.category}`, + sessionId })) .sort((a, b) => b.nonce - a.nonce); diff --git a/app/src/lib/components/SidebarItem.svelte b/app/src/lib/components/SidebarItem.svelte index 7ccf411..2bfc297 100644 --- a/app/src/lib/components/SidebarItem.svelte +++ b/app/src/lib/components/SidebarItem.svelte @@ -3,6 +3,7 @@ title: string; nonce: number; href: string; + sessionId: string; }; @@ -21,7 +22,7 @@ easing: cubicInOut }); - $: isActive = $page.url.href.includes(item.href); + $: isActive = $page.url.href.includes(item.sessionId);