mirror of
https://github.com/omnivore-app/omnivore.git
synced 2026-03-11 08:54:26 +00:00
Update current item when deleting items if current item is deleted
This commit is contained in:
parent
6043d08046
commit
e2bf22f3ae
1 changed files with 9 additions and 1 deletions
|
|
@ -55,9 +55,17 @@ export function HighlightItemsLayout(
|
|||
(h) => h.id !== action.highlightId
|
||||
)
|
||||
}
|
||||
return state.filter(
|
||||
const result = state.filter(
|
||||
(item) => item.node.highlights && item.node.highlights.length > 0
|
||||
)
|
||||
if (
|
||||
item &&
|
||||
item == currentItem &&
|
||||
(item.node.highlights?.length ?? 0) < 1
|
||||
) {
|
||||
setCurrentItem(result.length > 0 ? result[0] : undefined)
|
||||
}
|
||||
return result
|
||||
default:
|
||||
throw new Error()
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue