From 191574dace919802abc704a71861d9911215c05e Mon Sep 17 00:00:00 2001 From: Athou Date: Wed, 18 Sep 2024 16:23:53 +0200 Subject: [PATCH] manually load more entries if needed when pressing a keyboard shortcut to go to the next entry (#1557) --- .../src/components/content/FeedEntries.tsx | 52 +++++++++++-------- 1 file changed, 30 insertions(+), 22 deletions(-) diff --git a/commafeed-client/src/components/content/FeedEntries.tsx b/commafeed-client/src/components/content/FeedEntries.tsx index 76bb909b..20d8ecd4 100644 --- a/commafeed-client/src/components/content/FeedEntries.tsx +++ b/commafeed-client/src/components/content/FeedEntries.tsx @@ -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 () =>