From a8579ef34b55e857b291381ab089602b542e5e75 Mon Sep 17 00:00:00 2001 From: Hristo Nedelkov Date: Wed, 8 Nov 2023 02:05:54 +0200 Subject: [PATCH] Fix loading new rows logic --- src/pages/LogsPage/LogsTerminal.tsx | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/src/pages/LogsPage/LogsTerminal.tsx b/src/pages/LogsPage/LogsTerminal.tsx index 9e22d653..d1b292df 100644 --- a/src/pages/LogsPage/LogsTerminal.tsx +++ b/src/pages/LogsPage/LogsTerminal.tsx @@ -571,7 +571,34 @@ function Row({ data, index }: { data: DataType | undefined, index: number }) { } function LogsTerminal() { - + const [data, setData] = useState([]); + + + useEffect(() => { + setData(exampleData.concat(Array.from({ length: 500 - exampleData.length }).map(_ => undefined))); + }, []); + + const isItemLoaded = (index: number) => index < data.length && data[index] !== undefined; + + const loadMoreItems = (startIndex: number, stopIndex: number) => { + return new Promise((resolve) => { + + setTimeout(() => { + setData(prevData => { + const newData = [...prevData]; + for (let i = startIndex; i <= stopIndex; i++) { + if (!newData[i]) { + + newData[i] = { option: `Option ${i}`, description: `Description for ${i}` }; + } + } + return newData; + }); + resolve(); + }, 1000); + }); + }; + return (