From 708828c2a3caa5e6d9b95ef42c9abd4079fec406 Mon Sep 17 00:00:00 2001 From: Chris-1010 <122332721@umail.ucc.ie> Date: Wed, 5 Mar 2025 22:39:21 +0000 Subject: [PATCH] FIX: Time display on dashboard; REFACTOR: Styling on `ResultsPage` --- frontend/src/components/Layout/ListItem.tsx | 2 +- frontend/src/components/Stream/StreamDashboard.tsx | 4 ++-- frontend/src/pages/ResultsPage.tsx | 1 - web_server/blueprints/streams.py | 9 +++++++-- 4 files changed, 10 insertions(+), 6 deletions(-) diff --git a/frontend/src/components/Layout/ListItem.tsx b/frontend/src/components/Layout/ListItem.tsx index 380f601..6d24a40 100644 --- a/frontend/src/components/Layout/ListItem.tsx +++ b/frontend/src/components/Layout/ListItem.tsx @@ -80,7 +80,7 @@ const UserListItem: React.FC = ({ title, username, isLive, on return (
= ({ username, userId, isL }); const time = Math.floor( - (Date.now() - new Date(data.startTime).getTime()) / 60000 // Convert to minutes + (Date.now() - new Date(data.start_time).getTime()) / 60000 // Convert to minutes ); if (time < 60) setTimeStarted(`${time}m ago`); @@ -371,7 +371,7 @@ const StreamDashboard: React.FC = ({ username, userId, isL username={username || ""} streamCategory={streamData.streamCategory || "Category"} viewers={streamData.viewers} - thumbnail={thumbnailPreview.url || ""} + thumbnail={thumbnailPreview.url || `/stream/${username}/index.png`} onItemClick={() => { window.open(`/${username}`, "_blank"); }} diff --git a/frontend/src/pages/ResultsPage.tsx b/frontend/src/pages/ResultsPage.tsx index 532d0cd..261c63e 100644 --- a/frontend/src/pages/ResultsPage.tsx +++ b/frontend/src/pages/ResultsPage.tsx @@ -7,7 +7,6 @@ import DynamicPageContent from "../components/Layout/DynamicPageContent"; import { getCategoryThumbnail } from "../utils/thumbnailUtils"; const ResultsPage: React.FC = () => { - const [overflow, setOverflow] = useState(false); const location = useLocation(); const navigate = useNavigate(); diff --git a/web_server/blueprints/streams.py b/web_server/blueprints/streams.py index 755639e..9f72649 100644 --- a/web_server/blueprints/streams.py +++ b/web_server/blueprints/streams.py @@ -304,8 +304,9 @@ def publish_stream(): db.execute("""UPDATE users SET is_live = 1 WHERE user_id = ?""", (user_id,)) - # Update thumbnail periodically - update_thumbnail.apply_async((user_id, + # Update thumbnail periodically only if a custom thumbnail is not provided + if not stream_thumbnail: + update_thumbnail.apply_async((user_id, path_manager.get_stream_file_path(username), path_manager.get_current_stream_thumbnail_file_path(username), THUMBNAIL_GENERATION_INTERVAL), countdown=10) @@ -348,6 +349,8 @@ def update_stream(): SET title = ?, category_id = ? WHERE user_id = ?""", (stream_title, get_category_id(stream_category), user_id)) + print("GOT: " + stream_thumbnail, flush=True) + if stream_thumbnail: # Set custom thumbnail status to true db.execute("""UPDATE streams @@ -362,6 +365,8 @@ def update_stream(): image.convert('RGB') image.save(thumbnail_path, "PNG") + print(f"Should have saved it to {thumbnail_path}", flush=True) + return "Stream updated", 200