Skip to content

Commit

Permalink
manually load more entries if needed when pressing a keyboard shortcu…
Browse files Browse the repository at this point in the history
…t to go to the next entry (#1557)
  • Loading branch information
Athou committed Sep 18, 2024
1 parent ee7c679 commit 191574d
Showing 1 changed file with 30 additions and 22 deletions.
52 changes: 30 additions & 22 deletions commafeed-client/src/components/content/FeedEntries.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -128,28 +128,36 @@ export function FeedEntries() {
}, [dispatch, entries, viewMode, scrollMarks, scrollingToEntry])

useMousetrap("r", async () => await dispatch(reloadEntries()))
useMousetrap(
"j",
async () =>
await dispatch(
selectNextEntry({
expand: true,
markAsRead: true,
scrollToEntry: true,
})
)
)
useMousetrap(
"n",
async () =>
await dispatch(
selectNextEntry({
expand: false,
markAsRead: false,
scrollToEntry: true,
})
)
)
useMousetrap("j", async () => {
// load more entries if needed
// this can happen if the last entry is too large to fit on the screen and the infinite loader doesn't trigger
if (hasMore && !loading && selectedEntry === entries[entries.length - 1]) {
await dispatch(loadMoreEntries())
}

await dispatch(
selectNextEntry({
expand: true,
markAsRead: true,
scrollToEntry: true,
})
)
})
useMousetrap("n", async () => {
// load more entries if needed
// this can happen if the last entry is too large to fit on the screen and the infinite loader doesn't trigger
if (hasMore && !loading && selectedEntry === entries[entries.length - 1]) {
await dispatch(loadMoreEntries())
}

await dispatch(
selectNextEntry({
expand: false,
markAsRead: false,
scrollToEntry: true,
})
)
})
useMousetrap(
"k",
async () =>
Expand Down

0 comments on commit 191574d

Please sign in to comment.