import { useCallback, useContext, useEffect, useState } from 'react'; import CollapseBar from '../../common/components/collapseBar/CollapseBar'; import { LoggingContext } from '../../common/context/LoggingContext'; import style from './InfoLogger.module.scss'; export default function InfoLogger() { const { logData, clearLog } = useContext(LoggingContext); const [data, setData] = useState([]); const [collapsed, setCollapsed] = useState(false); // Todo: save in local storage const [showClient, setShowClient] = useState(true); const [showServer, setShowServer] = useState(true); const [showRx, setShowRx] = useState(true); const [showTx, setShowTx] = useState(true); const [showPlayback, setShowPlayback] = useState(true); const [showUser, setShowUser] = useState(true); useEffect(() => { if (!logData) { return; } const matchers = []; if (showUser) { matchers.push('USER'); } if (showClient) { matchers.push('CLIENT'); } if (showServer) { matchers.push('SERVER'); } if (showRx) { matchers.push('RX'); } if (showTx) { matchers.push('TX'); } if (showPlayback) { matchers.push('PLAYBACK'); } const d = logData.filter((d) => matchers.some((m) => d.origin === m)); setData(d); }, [logData, showUser, showClient, showServer, showPlayback, showRx, showTx]); const disableOthers = useCallback((toEnable) => { toEnable === 'USER' ? setShowUser(true) : setShowUser(false); toEnable === 'CLIENT' ? setShowClient(true) : setShowClient(false); toEnable === 'SERVER' ? setShowServer(true) : setShowServer(false); toEnable === 'RX' ? setShowRx(true) : setShowRx(false); toEnable === 'TX' ? setShowTx(true) : setShowTx(false); toEnable === 'PLAYBACK' ? setShowPlayback(true) : setShowPlayback(false); }, []); return (