Load more logs when scrolled to top

Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com>
This commit is contained in:
Alex Andreev committed 2022-09-01 09:44:19 +03:00
1 parent 85fadc74e0
commit 88678f63a2
1 file changed
+12
@@ -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