clean-up #15

Merged
gpatti merged 3 commits from clean-up into main 2026-04-11 01:33:11 +00:00
Showing only changes of commit 5d4d11512d - Show all commits

View File

@@ -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])