mirror of
https://github.com/supermemoryai/supermemory.git
synced 2026-10-21 05:18:00 +00:00
fix(web): keep highlights card active index in range on refresh
The Daily Brief refreshes on its own every few hours, replacing the items array, and the paging controls also let the user sit on a later index. When a refresh returns fewer highlights than before, activeIndex was left pointing past the end of the new list, so currentItem became undefined and the card rendered the "Add some documents" empty state even though highlights existed, with no pagination shown to recover from it. Clamp activeIndex back into range whenever items changes, alongside the existing reply/expansion reset. Also drops a now-unnecessary useExhaustiveDependencies suppression, since the effect body now reads items.length so items is a real dependency.
This commit is contained in:
parent
90f709bf8d
commit
34b0b3db59
1 changed files with 5 additions and 1 deletions
|
|
@ -92,8 +92,12 @@ export function HighlightsCard({
|
|||
if (isReplyOpen) replyInputRef.current?.focus()
|
||||
}, [isReplyOpen])
|
||||
|
||||
// biome-ignore lint/correctness/useExhaustiveDependencies: intentionally re-run when items changes
|
||||
useEffect(() => {
|
||||
// The Daily Brief refreshes on its own every few hours, so items can be
|
||||
// replaced with a shorter list while the user is on a later page. Pull the
|
||||
// active index back into range, otherwise currentItem is undefined and the
|
||||
// card falls through to the empty state even though highlights exist.
|
||||
setActiveIndex((i) => Math.min(i, Math.max(items.length - 1, 0)))
|
||||
setIsReplyOpen(false)
|
||||
setReplyText("")
|
||||
setIsExpanded(false)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue