From 18a5737b9c36418fedf1fff67d4d0e8e6977d465 Mon Sep 17 00:00:00 2001 From: greatsamist Date: Wed, 7 Aug 2024 09:44:22 +0100 Subject: [PATCH 1/2] =?UTF-8?q?=F0=9F=90=9B=20hotfix:=20broken=20clip=20pa?= =?UTF-8?q?ge=20and=20=20generate=20thumbnails=20repeated=20requests?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/app/app/studio/[organization]/clips/page.tsx | 4 ---- .../components/misc/VideoCard/VideoCardWithMenu.tsx | 10 +++++----- packages/app/lib/services/sessionService.ts | 2 +- 3 files changed, 6 insertions(+), 10 deletions(-) diff --git a/packages/app/app/studio/[organization]/clips/page.tsx b/packages/app/app/studio/[organization]/clips/page.tsx index 218fdd993..a2c82b86d 100644 --- a/packages/app/app/studio/[organization]/clips/page.tsx +++ b/packages/app/app/studio/[organization]/clips/page.tsx @@ -176,10 +176,6 @@ const EventClips = async ({ params, searchParams }: ClipsPageParams) => { return undefined; })(); - if (!previewAsset) { - return notFound(); - } - return ( {previewAsset && ( diff --git a/packages/app/components/misc/VideoCard/VideoCardWithMenu.tsx b/packages/app/components/misc/VideoCard/VideoCardWithMenu.tsx index bde85f379..df7cc60c7 100644 --- a/packages/app/components/misc/VideoCard/VideoCardWithMenu.tsx +++ b/packages/app/components/misc/VideoCard/VideoCardWithMenu.tsx @@ -12,7 +12,7 @@ import { IExtendedSession } from '@/lib/types'; import { formatDate } from '@/lib/utils/time'; import { EllipsisVertical } from 'lucide-react'; import Link from 'next/link'; -import React, { ReactNode } from 'react'; +import React, { ReactNode, useMemo } from 'react'; import { useEffect, useState } from 'react'; const VideoCardWithMenu = ({ @@ -27,7 +27,7 @@ const VideoCardWithMenu = ({ link: string; }) => { const [thumbnail, setThumbnail] = useState(undefined); - + const memoizedSession = useMemo(() => session, []); useEffect(() => { const getThumbnail = async (session: IExtendedSession) => { try { @@ -38,10 +38,10 @@ const VideoCardWithMenu = ({ } }; - if (session) { - getThumbnail(session); + if (memoizedSession && !memoizedSession.coverImage) { + getThumbnail(memoizedSession); } - }, [session]); + }, [memoizedSession]); return (
diff --git a/packages/app/lib/services/sessionService.ts b/packages/app/lib/services/sessionService.ts index e7d0845da..ab8dfdbb2 100644 --- a/packages/app/lib/services/sessionService.ts +++ b/packages/app/lib/services/sessionService.ts @@ -186,7 +186,7 @@ export const fetchSessionMetrics = async ({ const response = await fetch(`${apiUrl()}/streams/metric/${playbackId}`, { cache: 'no-store', }); - console.log('response', response); + if (!response.ok) { return { viewCount: 0, From 866f9d5f5351973dfd1816920dd92483861f68b0 Mon Sep 17 00:00:00 2001 From: greatsamist Date: Wed, 7 Aug 2024 09:44:22 +0100 Subject: [PATCH 2/2] =?UTF-8?q?=F0=9F=90=9B=20hotfix:=20broken=20clip=20pa?= =?UTF-8?q?ge=20and=20=20generate=20thumbnails=20repeated=20requests?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/app/app/studio/[organization]/clips/page.tsx | 4 ---- .../components/misc/VideoCard/VideoCardWithMenu.tsx | 10 +++++----- packages/app/lib/services/sessionService.ts | 2 +- 3 files changed, 6 insertions(+), 10 deletions(-) diff --git a/packages/app/app/studio/[organization]/clips/page.tsx b/packages/app/app/studio/[organization]/clips/page.tsx index 218fdd993..a2c82b86d 100644 --- a/packages/app/app/studio/[organization]/clips/page.tsx +++ b/packages/app/app/studio/[organization]/clips/page.tsx @@ -176,10 +176,6 @@ const EventClips = async ({ params, searchParams }: ClipsPageParams) => { return undefined; })(); - if (!previewAsset) { - return notFound(); - } - return ( {previewAsset && ( diff --git a/packages/app/components/misc/VideoCard/VideoCardWithMenu.tsx b/packages/app/components/misc/VideoCard/VideoCardWithMenu.tsx index bde85f379..df7cc60c7 100644 --- a/packages/app/components/misc/VideoCard/VideoCardWithMenu.tsx +++ b/packages/app/components/misc/VideoCard/VideoCardWithMenu.tsx @@ -12,7 +12,7 @@ import { IExtendedSession } from '@/lib/types'; import { formatDate } from '@/lib/utils/time'; import { EllipsisVertical } from 'lucide-react'; import Link from 'next/link'; -import React, { ReactNode } from 'react'; +import React, { ReactNode, useMemo } from 'react'; import { useEffect, useState } from 'react'; const VideoCardWithMenu = ({ @@ -27,7 +27,7 @@ const VideoCardWithMenu = ({ link: string; }) => { const [thumbnail, setThumbnail] = useState(undefined); - + const memoizedSession = useMemo(() => session, []); useEffect(() => { const getThumbnail = async (session: IExtendedSession) => { try { @@ -38,10 +38,10 @@ const VideoCardWithMenu = ({ } }; - if (session) { - getThumbnail(session); + if (memoizedSession && !memoizedSession.coverImage) { + getThumbnail(memoizedSession); } - }, [session]); + }, [memoizedSession]); return (
diff --git a/packages/app/lib/services/sessionService.ts b/packages/app/lib/services/sessionService.ts index e7d0845da..ab8dfdbb2 100644 --- a/packages/app/lib/services/sessionService.ts +++ b/packages/app/lib/services/sessionService.ts @@ -186,7 +186,7 @@ export const fetchSessionMetrics = async ({ const response = await fetch(`${apiUrl()}/streams/metric/${playbackId}`, { cache: 'no-store', }); - console.log('response', response); + if (!response.ok) { return { viewCount: 0,