1
0
mirror of https://github.com/lensapp/lens.git synced 2025-05-20 05:10:56 +00:00

Load more logs when scrolled to top

Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com>
This commit is contained in:
Alex Andreev 2022-09-01 09:44:19 +03:00
parent 85fadc74e0
commit 88678f63a2

View File

@ -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