This repository has been archived on 2026-05-06. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
tippspiel/frontend/src/hooks/useRevealQueue.js
T
Ronny 002296daf7 style: CSS polish, light mode verification, build fixes
- Add --primary-rgb, --transition-fast, --transition-normal CSS tokens to :root
- Add --primary-rgb override in [data-theme="light"] section
- Fix TS error: remove unused devUser prop from Route elements in App.tsx (API patching via window._devUser makes props redundant)
- Fix TS error: remove unused 'api' import from DevPanel.tsx

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-11 19:16:13 +02:00

31 lines
957 B
JavaScript

import { useState, useEffect } from 'react';
const SEEN_KEY = 'tippspiel_seen_results';
function getSeenIds() {
try {
return new Set(JSON.parse(localStorage.getItem(SEEN_KEY) || '[]'));
}
catch {
return new Set();
}
}
function markSeen(matchId) {
const seen = getSeenIds();
seen.add(matchId);
localStorage.setItem(SEEN_KEY, JSON.stringify([...seen]));
}
export function useRevealQueue(matches) {
const [queue, setQueue] = useState([]);
useEffect(() => {
const seen = getSeenIds();
const unseen = matches.filter(m => m.status === 'FINISHED' && m.userTip && m.userTip.points !== null && !seen.has(m.id));
setQueue(unseen);
}, [matches]);
function dismissCurrent() {
if (queue.length === 0)
return;
markSeen(queue[0].id);
setQueue(q => q.slice(1));
}
return { current: queue[0] || null, remaining: queue.length, dismissCurrent };
}