From 88b400b464bc9d09acbf6a3a95bbd7751bcdb7ea Mon Sep 17 00:00:00 2001 From: Stephanie Gredell Date: Fri, 12 Dec 2025 04:40:52 -0800 Subject: [PATCH] remove time limit feature --- .../src/components/VideoCard/VideoCard.tsx | 9 +- .../src/components/VideoGrid/VideoGrid.tsx | 11 +-- .../components/VideoPlayer/VideoPlayer.tsx | 84 +++---------------- frontend/src/pages/AdminPage.tsx | 2 +- .../src/pages/SettingsProfilesAdminPage.tsx | 39 +-------- frontend/src/pages/VideoApp.tsx | 12 --- frontend/src/pages/VideosAdminPage.tsx | 12 +-- 7 files changed, 26 insertions(+), 143 deletions(-) diff --git a/frontend/src/components/VideoCard/VideoCard.tsx b/frontend/src/components/VideoCard/VideoCard.tsx index 9a4c054..697b457 100644 --- a/frontend/src/components/VideoCard/VideoCard.tsx +++ b/frontend/src/components/VideoCard/VideoCard.tsx @@ -3,10 +3,9 @@ import { Video } from '../../types/api'; interface VideoCardProps { video: Video; onClick: () => void; - disabled?: boolean; } -export function VideoCard({ video, onClick, disabled = false }: VideoCardProps) { +export function VideoCard({ video, onClick }: VideoCardProps) { const formatViews = (count: number): string => { if (count >= 1000000) { return `${(count / 1000000).toFixed(1)}M`; @@ -32,10 +31,8 @@ export function VideoCard({ video, onClick, disabled = false }: VideoCardProps) return (
void; - disabled?: boolean; } export function VideoGrid({ @@ -19,12 +18,11 @@ export function VideoGrid({ onVideoClick, page, totalPages, - onPageChange, - disabled = false + onPageChange }: VideoGridProps) { if (loading) { return ( -
+
{Array.from({ length: 12 }).map((_, i) => (
@@ -60,13 +58,12 @@ export function VideoGrid({ return (
-
+
{videos.map(video => ( !disabled && onVideoClick(video.id)} - disabled={disabled} + onClick={() => onVideoClick(video.id)} /> ))}
diff --git a/frontend/src/components/VideoPlayer/VideoPlayer.tsx b/frontend/src/components/VideoPlayer/VideoPlayer.tsx index 86e2c95..b53a915 100644 --- a/frontend/src/components/VideoPlayer/VideoPlayer.tsx +++ b/frontend/src/components/VideoPlayer/VideoPlayer.tsx @@ -1,5 +1,4 @@ import { useEffect, useRef } from 'react'; -import { useTimeLimit } from '../../hooks/useTimeLimit'; import { setCurrentVideo } from '../../services/connectionTracker'; interface VideoPlayerProps { @@ -10,9 +9,7 @@ interface VideoPlayerProps { } export function VideoPlayer({ videoId, videoTitle, channelName, onClose }: VideoPlayerProps) { - const { limitReached, startTracking, stopTracking, remainingTime } = useTimeLimit(); const iframeRef = useRef(null); - const checkLimitIntervalRef = useRef(null); useEffect(() => { // Set video info for connection tracking @@ -24,56 +21,21 @@ export function VideoPlayer({ videoId, videoTitle, channelName, onClose }: Video // Handle Escape key const handleEscape = (e: KeyboardEvent) => { if (e.key === 'Escape') { - stopTracking(); setCurrentVideo(null); onClose(); } }; window.addEventListener('keydown', handleEscape); - // Start tracking time when player opens - if (!limitReached) { - startTracking(); - } - - // Check limit periodically and stop video if reached - checkLimitIntervalRef.current = setInterval(() => { - if (limitReached && iframeRef.current) { - // Stop the video by removing autoplay and reloading with paused state - if (iframeRef.current.src.includes('autoplay=1')) { - iframeRef.current.src = iframeRef.current.src.replace('autoplay=1', 'autoplay=0'); - } - stopTracking(); - setCurrentVideo(null); - } - }, 1000); - return () => { // Clear video info when player closes setCurrentVideo(null); document.body.style.overflow = 'unset'; window.removeEventListener('keydown', handleEscape); - stopTracking(); - if (checkLimitIntervalRef.current) { - clearInterval(checkLimitIntervalRef.current); - } }; - }, [videoId, videoTitle, channelName, onClose, limitReached, startTracking, stopTracking]); - - // Stop video immediately if limit reached - useEffect(() => { - if (limitReached && iframeRef.current) { - // Change iframe src to stop autoplay - const currentSrc = iframeRef.current.src; - if (currentSrc.includes('autoplay=1')) { - iframeRef.current.src = currentSrc.replace('autoplay=1', 'autoplay=0'); - } - stopTracking(); - } - }, [limitReached, stopTracking]); + }, [videoId, videoTitle, channelName, onClose]); const handleClose = () => { - stopTracking(); setCurrentVideo(null); onClose(); }; @@ -93,38 +55,18 @@ export function VideoPlayer({ videoId, videoTitle, channelName, onClose }: Video > × - {limitReached ? ( -
-

Daily Time Limit Reached

-

- You've reached your daily video watching limit. Come back tomorrow! -

- -
- ) : ( - <> -
- {Math.floor(remainingTime)} min remaining today -
-
-