From 9664ba0824b5a1999c4aa128167e03cfb48f65df Mon Sep 17 00:00:00 2001 From: Hristo Nedelkov Date: Thu, 16 Nov 2023 12:11:14 +0200 Subject: [PATCH] Update LogsTerminal.tsx --- src/pages/LogsPage/LogsTerminal.tsx | 70 +++++++++-------------------- 1 file changed, 20 insertions(+), 50 deletions(-) diff --git a/src/pages/LogsPage/LogsTerminal.tsx b/src/pages/LogsPage/LogsTerminal.tsx index 6b8cc3b6..b4207b47 100644 --- a/src/pages/LogsPage/LogsTerminal.tsx +++ b/src/pages/LogsPage/LogsTerminal.tsx @@ -1,4 +1,4 @@ -import { Text } from '@status-im/components' +import { Button, Text } from '@status-im/components' import { FixedSizeList, FixedSizeList as List } from 'react-window' import InfiniteLoader from 'react-window-infinite-loader' @@ -6,55 +6,17 @@ import './scroller.css' import { Stack, XStack } from 'tamagui' import { exampleData } from './exampleData' import { useEffect, useRef, useState } from 'react' +import TerminalRow from './TerminalRow' type DataType = { option: string description: string } -interface RowProps { - data: DataType | undefined - index: number +type LogsTerminalProps = { + windowWidth: number } - -const Row = ({ data, index }: RowProps) => { - if (!data) { - return Loading... - } - - const { option, description } = data - return ( - - - {index} - - {new Date(Date.now()).toLocaleDateString()} - - {option} - - {description} - - ) -} -const LogsTerminal = () => { +const LogsTerminal = ({ windowWidth }: LogsTerminalProps) => { const [data, setData] = useState([]) const [isScrolling, setIsScrolling] = useState(false) const [loadedIndexes, setLoadedIndexes] = useState<{ [key: number]: boolean }>({}) @@ -63,8 +25,8 @@ const LogsTerminal = () => { useEffect(() => { const interval = setInterval(() => { - // addNewLog() - }, 2000) + // addNewLog() + }, 3000) return () => clearInterval(interval) }, [isScrolling]) @@ -90,7 +52,6 @@ const LogsTerminal = () => { }, 5000) }) } - const isItemLoaded = (index: number) => !!loadedIndexes[index] const addNewLog = () => { @@ -120,7 +81,12 @@ const LogsTerminal = () => { } return ( - + { ref={(list: FixedSizeList | null) => { listRef.current = list ref(list) + console.log(list) }} className="custom-scroll" height={650} - width={1100} + width={windowWidth - 500} itemCount={data.length} - itemSize={20} + itemSize={150} itemData={data} onItemsRendered={onItemsRendered} onScroll={handleScroll} @@ -147,12 +114,15 @@ const LogsTerminal = () => { > {({ index, style }) => ( - + )} )} + ) }