diff --git a/packages/app/app/[organization]/watch/page.tsx b/packages/app/app/[organization]/watch/page.tsx index 8ca7c8bac..83d853987 100644 --- a/packages/app/app/[organization]/watch/page.tsx +++ b/packages/app/app/[organization]/watch/page.tsx @@ -52,15 +52,20 @@ export default async function Watch({ session: searchParams.session, }); - if (!session || !session.playbackId) return notFound(); + // Check if session exists and has a playbackId. If not, return a 'not found' response. + if (!session?.playbackId) return notFound(); + // Determine which identifier to use. Prioritize assetId if it exists, otherwise use playbackId. + const identifier = session.assetId || session.playbackId; + // Set the idType based on which identifier we're using. + // This ternary operation will set 'assetId' if session.assetId exists, otherwise 'playbackId'. + const idType = session.assetId ? 'assetId' : 'playbackId'; + // Log which type of identifier we're using for debugging purposes. + // console.log(`Using ${idType} for video retrieval: ${identifier}`); - const videoUrl = await getVideoUrlAction( - session.assetId || session.playbackId - ); - - if (!videoUrl) { - return notFound(); - } + // Attempt to get the video URL using the determined identifier and type. + const videoUrl = await getVideoUrlAction(identifier, idType); + // If we couldn't get a video URL, return a 'not found' response. + if (!videoUrl) return notFound(); const thumbnail = await generateThumbnailAction(session); diff --git a/packages/app/app/studio/[organization]/library/[session]/page.tsx b/packages/app/app/studio/[organization]/library/[session]/page.tsx index 9cfbc2707..1fdfed003 100644 --- a/packages/app/app/studio/[organization]/library/[session]/page.tsx +++ b/packages/app/app/studio/[organization]/library/[session]/page.tsx @@ -32,13 +32,22 @@ const EditSession = async ({ params, searchParams }: studioPageParams) => { session: params.session, }); - if (!session || !session.playbackId) return notFound(); + // Check if session exists and has a playbackId. If not, return a 'not found' response. + if (!session?.playbackId) return notFound(); + // Determine which identifier to use. Prioritize assetId if it exists, otherwise use playbackId. + const identifier = session.assetId || session.playbackId; + // Set the idType based on which identifier we're using. + // This ternary operation will set 'assetId' if session.assetId exists, otherwise 'playbackId'. + const idType = session.assetId ? 'assetId' : 'playbackId'; - const videoUrl = await getVideoUrlAction(session.assetId as string); + // Log which type of identifier we're using for debugging purposes. + // console.log(`Using ${idType} for video retrieval: ${identifier}`); - if (!videoUrl) { - return notFound(); - } + // Attempt to get the video URL using the determined identifier and type. + const videoUrl = await getVideoUrlAction(identifier, idType); + + // If we couldn't get a video URL, return a 'not found' response. + if (!videoUrl) return notFound(); return (