diff --git a/src/components/DoomScrollView.tsx b/src/components/DoomScrollView.tsx index af00d73..4de737d 100644 --- a/src/components/DoomScrollView.tsx +++ b/src/components/DoomScrollView.tsx @@ -16,6 +16,8 @@ interface Props { onClose: () => void } +const HISTORY_CAP = 100 + function pickRandom(items: DoomScrollItem[], excludeRecent: DoomScrollItem[]): DoomScrollItem { const excludeCount = Math.min(excludeRecent.length, items.length - 1) const recentUrls = new Set(excludeRecent.slice(-excludeCount).map((i) => i.url)) @@ -55,9 +57,9 @@ export default function DoomScrollView({ items, videoContext = 'mixed', onClose const next = pickRandom(items, history) setHistory((h) => { const updated = [...h, next] - return updated.length > 100 ? updated.slice(-100) : updated + return updated.length > HISTORY_CAP ? updated.slice(-HISTORY_CAP) : updated }) - return idx + 1 + return Math.min(idx + 1, HISTORY_CAP - 1) }) }, [items, history])