From 6b00cfe970c05c15da876890f6ba52cd0c0393d2 Mon Sep 17 00:00:00 2001 From: SergeantPanda Date: Tue, 8 Apr 2025 11:11:46 -0500 Subject: [PATCH] Add description to program. --- frontend/src/pages/Guide.jsx | 119 ++++++++++++++++++++++------------- 1 file changed, 76 insertions(+), 43 deletions(-) diff --git a/frontend/src/pages/Guide.jsx b/frontend/src/pages/Guide.jsx index 0cfc4b87..47196f0e 100644 --- a/frontend/src/pages/Guide.jsx +++ b/frontend/src/pages/Guide.jsx @@ -132,16 +132,17 @@ export default function TVChannelGuide({ startDate, endDate }) { return hours; }, [start, end]); - // Scroll to "now" on load + // Scroll to the nearest half-hour mark on load useEffect(() => { if (guideRef.current) { - const nowOffset = dayjs().diff(start, 'minute'); + // Round the current time to the nearest half-hour mark + const roundedNow = now.minute() < 30 ? now.startOf('hour') : now.startOf('hour').add(30, 'minute'); + const nowOffset = roundedNow.diff(start, 'minute'); const scrollPosition = - (nowOffset / MINUTE_INCREMENT) * MINUTE_BLOCK_WIDTH - - MINUTE_BLOCK_WIDTH; + (nowOffset / MINUTE_INCREMENT) * MINUTE_BLOCK_WIDTH - MINUTE_BLOCK_WIDTH; guideRef.current.scrollLeft = Math.max(scrollPosition, 0); } - }, [programs]); + }, [programs, now, start]); // Update “now” every 60s useEffect(() => { @@ -241,6 +242,13 @@ export default function TVChannelGuide({ startDate, endDate }) { // Highlight if currently live const isLive = now.isAfter(programStart) && now.isBefore(programEnd); + // Determine if the program has ended + const isPast = now.isAfter(programEnd); + + // Calculate how much of the program is cut off + const cutOffMinutes = Math.max(0, channelStart.diff(programStart, 'minute')); + const cutOffPx = (cutOffMinutes / MINUTE_INCREMENT) * MINUTE_BLOCK_WIDTH; + return ( - - - {recording && ( -
- )} - {program.title} -
-
- - {programStart.format('h:mma')} - {programEnd.format('h:mma')} - + + + + {recording && ( +
+ )} + {program.title} +
+
+ + {programStart.format('h:mma')} - {programEnd.format('h:mma')} + +
+ {program.description && ( + + {program.description} + + )}
);