mirror of
https://github.com/status-im/nimbus-gui.git
synced 2025-02-23 00:28:19 +00:00
Update LogsTerminal.tsx
This commit is contained in:
parent
920d70d230
commit
8c5397ac11
@ -32,19 +32,12 @@ const fetchMoreData = () => {
|
|||||||
|
|
||||||
const LogsTerminal = ({ windowWidth, timestamps }: LogsTerminalProps) => {
|
const LogsTerminal = ({ windowWidth, timestamps }: LogsTerminalProps) => {
|
||||||
const [data, setData] = useState<DataType[]>([])
|
const [data, setData] = useState<DataType[]>([])
|
||||||
const [isScrolling, setIsScrolling] = useState(false)
|
|
||||||
const [loadedIndexes, setLoadedIndexes] = useState<{ [key: number]: boolean }>({})
|
const [loadedIndexes, setLoadedIndexes] = useState<{ [key: number]: boolean }>({})
|
||||||
const listRef = useRef<List | null>(null)
|
const listRef = useRef<List | null>(null)
|
||||||
|
|
||||||
const [shouldAutoScroll, setShouldAutoScroll] = useState(true)
|
const [shouldAutoScroll, setShouldAutoScroll] = useState(true)
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
const interval = setInterval(() => {
|
|
||||||
//addNewLog()
|
|
||||||
}, 3000)
|
|
||||||
|
|
||||||
return () => clearInterval(interval)
|
|
||||||
}, [isScrolling])
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (shouldAutoScroll) {
|
if (shouldAutoScroll) {
|
||||||
@ -62,7 +55,6 @@ const LogsTerminal = ({ windowWidth, timestamps }: LogsTerminalProps) => {
|
|||||||
const isItemLoaded = (index: number) => !!loadedIndexes[index]
|
const isItemLoaded = (index: number) => !!loadedIndexes[index]
|
||||||
|
|
||||||
const addNewLog = () => {
|
const addNewLog = () => {
|
||||||
if (!isScrolling) {
|
|
||||||
const newLog: DataType = {
|
const newLog: DataType = {
|
||||||
option: `--new-option-${data.length + 1}`,
|
option: `--new-option-${data.length + 1}`,
|
||||||
description: `New log entry ${data.length + 1} ${Math.random()}`,
|
description: `New log entry ${data.length + 1} ${Math.random()}`,
|
||||||
@ -75,7 +67,6 @@ const LogsTerminal = ({ windowWidth, timestamps }: LogsTerminalProps) => {
|
|||||||
listRef.current?.scrollToItem(data.length, 'end')
|
listRef.current?.scrollToItem(data.length, 'end')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
const handleScroll = ({ scrollTop, scrollHeight, clientHeight }: any) => {
|
const handleScroll = ({ scrollTop, scrollHeight, clientHeight }: any) => {
|
||||||
const isAtBottom = scrollTop + clientHeight >= scrollHeight
|
const isAtBottom = scrollTop + clientHeight >= scrollHeight
|
||||||
|
Loading…
x
Reference in New Issue
Block a user