mirror of
https://github.com/omnivore-app/omnivore.git
synced 2026-03-11 08:54:26 +00:00
Update the selected highlight item when using keyboard controls
This commit is contained in:
parent
94286c6676
commit
976a0cb88c
2 changed files with 15 additions and 3 deletions
|
|
@ -119,7 +119,9 @@ export function LibraryItemMetadata(
|
|||
props: LibraryItemMetadataProps
|
||||
): JSX.Element {
|
||||
const highlightCount = useMemo(() => {
|
||||
return props.item.highlights?.length ?? 0
|
||||
return (
|
||||
props.item.highlights?.filter((h) => h.type == 'HIGHLIGHT').length ?? 0
|
||||
)
|
||||
}, [props.item.highlights])
|
||||
|
||||
return (
|
||||
|
|
|
|||
|
|
@ -205,6 +205,11 @@ export function HomeFeedContainer(): JSX.Element {
|
|||
}
|
||||
setActiveCardId(id)
|
||||
scrollToActiveCard(id, true)
|
||||
|
||||
const newItem = getItem(id)
|
||||
if (notebookTarget && newItem) {
|
||||
setNotebookTarget(newItem)
|
||||
}
|
||||
},
|
||||
[libraryItems]
|
||||
)
|
||||
|
|
@ -259,6 +264,13 @@ export function HomeFeedContainer(): JSX.Element {
|
|||
return libraryItems.find((item) => item.node.id === activeCardId)
|
||||
}, [libraryItems, activeCardId])
|
||||
|
||||
const getItem = useCallback(
|
||||
(itemId) => {
|
||||
return libraryItems.find((item) => item.node.id === itemId)
|
||||
},
|
||||
[libraryItems]
|
||||
)
|
||||
|
||||
const activeItemIndex = useMemo(() => {
|
||||
if (!activeCardId) {
|
||||
return undefined
|
||||
|
|
@ -276,8 +288,6 @@ export function HomeFeedContainer(): JSX.Element {
|
|||
alreadyScrolled.current = true
|
||||
|
||||
if (activeItem) {
|
||||
console.log('refreshing')
|
||||
// refresh items on home feed
|
||||
performActionOnItem('refresh', activeItem)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue