/* ============================================================ INDIC LEAGUE NEWS — Main feed (the home screen) Top nav + swipe card stack + bottom dock. Owns: sheet state, liked/saved sets, theme toggle, toast. ============================================================ */ function Feed({ articles, user, onLogout, theme, onToggleTheme }) { const [sheetOpen, setSheetOpen] = React.useState(false); const [sheetArticle, setSheetArticle] = React.useState(null); const [liked, setLiked] = React.useState(() => { const stored = window.IL_Util.Storage.get(window.IL_KEYS.liked, []); return new Set(Array.isArray(stored) ? stored : []); }); const [saved, setSaved] = React.useState(() => { const stored = window.IL_Util.Storage.get('il_saved', []); return new Set(Array.isArray(stored) ? stored : []); }); const [toast, setToast] = React.useState(null); const toastTimer = React.useRef(null); const showToast = (msg) => { if (!msg) { if (toastTimer.current) clearTimeout(toastTimer.current); setToast(null); return; } setToast(msg); if (toastTimer.current) clearTimeout(toastTimer.current); toastTimer.current = setTimeout(() => setToast(null), 1800); }; // Persist liked/saved React.useEffect(() => { window.IL_Util.Storage.set(window.IL_KEYS.liked, Array.from(liked)); }, [liked]); React.useEffect(() => { window.IL_Util.Storage.set('il_saved', Array.from(saved)); }, [saved]); const openArticle = (a) => { if (!a || a.is_sponsored) return; window.IL_Sounds && window.IL_Sounds.tap(); window.IL_Util && window.IL_Util.Haptics.light(); setSheetArticle(a); setSheetOpen(true); }; const closeSheet = () => { setSheetOpen(false); // delay clearing article so transition runs setTimeout(() => setSheetArticle(null), 400); }; const toggleLike = (a) => { setLiked(prev => { const next = new Set(prev); if (next.has(a.id)) { next.delete(a.id); showToast('Removed from liked'); } else { next.add(a.id); showToast('Saved to liked ♥'); } return next; }); }; const toggleSave = (a) => { setSaved(prev => { const next = new Set(prev); if (next.has(a.id)) { next.delete(a.id); showToast('Removed from saved'); } else { next.add(a.id); showToast('Saved'); } return next; }); }; const shareArticle = (a) => { showToast('Creating image…'); window.IL_Util.shareArticle(a, (msg) => { if (msg) showToast(msg); }); }; const onRead = (a) => { // Could increment TIL score; skipped for focused scope }; // Tab/dock state (for For-you vs others). Only For-you is wired. const [tab, setTab] = React.useState('home'); return (
Topic browsing arrives in v1.1. For now, swipe the main feed — it already adapts to your topics.
Tap the heart while reading to save stories here.