From ab8d1306504bfefdea293172d7e645f83114d50f Mon Sep 17 00:00:00 2001 From: Pinapelz Date: Fri, 3 Oct 2025 03:51:40 -0700 Subject: add topic based stubs for notifications --- site/src/pages/Homepage.tsx | 103 ++++++++++++++++++++++++++++++++++++-------- 1 file changed, 85 insertions(+), 18 deletions(-) (limited to 'site/src/pages') diff --git a/site/src/pages/Homepage.tsx b/site/src/pages/Homepage.tsx index db658ca..f9ccaa2 100644 --- a/site/src/pages/Homepage.tsx +++ b/site/src/pages/Homepage.tsx @@ -1,6 +1,6 @@ import { useEffect, useState } from "react"; import { NewsData, NewsFeed } from "../components/NewsFeed"; -import { useParams, useSearchParams } from "react-router-dom"; +import { Link, useParams, useSearchParams } from "react-router-dom"; import { getGameTitle } from "../utils.ts"; import TitleBar from "../components/TitleBar"; import { GameNotes } from "../components/GameNotes"; @@ -24,6 +24,29 @@ export default function Home() { ); const [loading, setLoading] = useState(true); const [error, setError] = useState(false); + const [subscribedGames, setSubscribedGames] = useState([]); + const [showSubscribedDropdown, setShowSubscribedDropdown] = useState(false); + + useEffect(() => { + // Load subscribed games from localStorage + const loadSubscribedGames = () => { + const topics = JSON.parse(localStorage.getItem('subscribed_topics') || '[]'); + setSubscribedGames(topics); + }; + + loadSubscribedGames(); + + // Listen for storage changes to update subscribed games list + const handleStorageChange = () => { + loadSubscribedGames(); + }; + + window.addEventListener('storage', handleStorageChange); + + return () => { + window.removeEventListener('storage', handleStorageChange); + }; + }, []); useEffect(() => { const fetchNews = async () => { @@ -47,6 +70,17 @@ export default function Home() { fetchNews(); }, [gameId, newsAPIBase]); // Re-fetch when gameId changes + // Update subscribed games when localStorage changes locally + useEffect(() => { + const checkSubscriptions = () => { + const topics = JSON.parse(localStorage.getItem('subscribed_topics') || '[]'); + setSubscribedGames(topics); + }; + + const interval = setInterval(checkSubscriptions, 500); + return () => clearInterval(interval); + }, []); + if (loading) { return ( <> @@ -130,6 +164,9 @@ export default function Home() { {GameNotes(isMoe)[gameId] && (
{GameNotes(isMoe)[gameId]}
)} +
+ +
Subscribe via RSS @@ -173,23 +210,53 @@ export default function Home() { for API information

-
- - Receive Notifications - -
- -

- Enables notifications for the main feed -

-
-
+
+ + + {/* Subscribed Games Display */} + {subscribedGames.length > 0 && ( +
+ + + {showSubscribedDropdown && ( +
+
+ {subscribedGames.map((gameId) => ( + + {getGameTitle(gameId)} + + ))} +
+
+ )} +
+ )} +
-- cgit v1.2.3