Skip to content

Commit

Permalink
🎨 Improved new getVideoUrl function calls and checks
Browse files Browse the repository at this point in the history
  • Loading branch information
Mario-SO committed Aug 10, 2024
1 parent a62e49c commit 8b37a2e
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 13 deletions.
21 changes: 13 additions & 8 deletions packages/app/app/[organization]/watch/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
19 changes: 14 additions & 5 deletions packages/app/app/studio/[organization]/library/[session]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
<div className="h-full overflow-auto p-4">
Expand Down

0 comments on commit 8b37a2e

Please sign in to comment.