From 07305f05135fa4ab814a969c36f558b671689499 Mon Sep 17 00:00:00 2001 From: Dylan De Faoite Date: Sat, 20 Jun 2026 14:49:10 +0100 Subject: [PATCH] fix(frontend): add no auth screen for clips --- frontend/src/pages/VideoPlayer.tsx | 35 ++++++++++++++++++++++++++---- frontend/src/utils/endpoints.ts | 8 ++++++- 2 files changed, 38 insertions(+), 5 deletions(-) diff --git a/frontend/src/pages/VideoPlayer.tsx b/frontend/src/pages/VideoPlayer.tsx index ff6186e..d91f3eb 100644 --- a/frontend/src/pages/VideoPlayer.tsx +++ b/frontend/src/pages/VideoPlayer.tsx @@ -1,8 +1,8 @@ import { useCallback, useEffect, useRef, useState } from "react"; import { useNavigate, useParams } from "react-router-dom"; -import { ArrowLeft, Maximize, Minimize, Pause, Play, Volume1, Volume2, VolumeX } from "lucide-react"; +import { ArrowLeft, Lock, Maximize, Minimize, Pause, Play, Volume1, Volume2, VolumeX } from "lucide-react"; import type { Clip } from "../utils/types"; -import { getClipById, getVideoBlob } from "../utils/endpoints.ts"; +import { AuthError, getClipById, getVideoBlob } from "../utils/endpoints.ts"; import Box from "../components/Box.tsx"; import { dateToTimeAgo, formatTime, stringToDate } from "../utils/utils.ts"; @@ -18,6 +18,7 @@ const VideoPlayer = () => { // Data const [videoUrl, setVideoUrl] = useState(undefined); const [error, setError] = useState(null); + const [notAuthenticated, setNotAuthenticated] = useState(false); const [clip, setClip] = useState(null); const [timeAgo, setTimeAgo] = useState(""); @@ -41,11 +42,16 @@ const VideoPlayer = () => { useEffect(() => { if (!id) { setError("Clip ID is required."); return; } - getVideoBlob(id).then((blob) => setVideoUrl(URL.createObjectURL(blob))); + getVideoBlob(id) + .then((blob) => setVideoUrl(URL.createObjectURL(blob))) + .catch((e) => { if (e instanceof AuthError) setNotAuthenticated(true); }); getClipById(id) .then(setClip) - .catch(() => setError("Failed to load clip details.")); + .catch((e) => { + if (e instanceof AuthError) setNotAuthenticated(true); + else setError("Failed to load clip details."); + }); }, [id]); useEffect(() => { @@ -177,6 +183,27 @@ const VideoPlayer = () => { const effectiveVolume = isMuted ? 0 : volume; const VolumeIcon = effectiveVolume === 0 ? VolumeX : effectiveVolume < 0.5 ? Volume1 : Volume2; + if (notAuthenticated) { + return ( +
+
+ +
+
+

Not authenticated

+

You don't have access to this clip.

+
+ +
+ ); + } + return (