From 88678f63a212ce5aeec5bdf14b590b1ebe871a23 Mon Sep 17 00:00:00 2001 From: Alex Andreev Date: Thu, 1 Sep 2022 09:44:19 +0300 Subject: [PATCH] Load more logs when scrolled to top Signed-off-by: Alex Andreev --- src/renderer/components/dock/logs/log-list.tsx | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/renderer/components/dock/logs/log-list.tsx b/src/renderer/components/dock/logs/log-list.tsx index c2a84ce7b0..61d2fa85cd 100644 --- a/src/renderer/components/dock/logs/log-list.tsx +++ b/src/renderer/components/dock/logs/log-list.tsx @@ -32,6 +32,7 @@ export const LogList = observer(({ model }: LogListProps) => { setToBottomVisibility(); setLastLineVisibility(); + checkLoadIntent(); } // TODO: Move to its own hook @@ -55,6 +56,17 @@ export const LogList = observer(({ model }: LogListProps) => { } } + /** + * Check if user scrolled to top and new logs should be loaded + */ + const checkLoadIntent = () => { + const { scrollTop } = parentRef.current as HTMLDivElement; + + if (scrollTop === 0) { + model.loadLogs(); + } + }; + useEffect(() => { setTimeout(() => { // Initial scroll to bottom