Some minor code quality improvements
parent
f7fe3162c3
commit
547a5224b5
|
@ -43,22 +43,23 @@ const LogEntryRenderer = React.memo((props: { entry: LogMessage }) => {
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
const ServerLogRenderer = () => {
|
const ServerLogRenderer = (props: { backlog?: number }) => {
|
||||||
|
const backlog = typeof props.backlog === "number" ? props.backlog : 100;
|
||||||
const handlerId = useContext(HandlerIdContext);
|
const handlerId = useContext(HandlerIdContext);
|
||||||
const events = useContext(EventsContext);
|
const events = useContext(EventsContext);
|
||||||
|
|
||||||
|
const refContainer = useRef<HTMLDivElement>();
|
||||||
|
const scrollOffset = useRef<number | "bottom">("bottom");
|
||||||
|
|
||||||
|
const [ , setRevision ] = useState(0);
|
||||||
const [ logs, setLogs ] = useDependentState<LogMessage[] | "loading">(() => {
|
const [ logs, setLogs ] = useDependentState<LogMessage[] | "loading">(() => {
|
||||||
events.fire_react("query_log");
|
events.fire_react("query_log");
|
||||||
return "loading";
|
return "loading";
|
||||||
}, [ handlerId ]);
|
}, [ handlerId ]);
|
||||||
|
|
||||||
const [ revision, setRevision ] = useState(0);
|
|
||||||
|
|
||||||
const refContainer = useRef<HTMLDivElement>();
|
|
||||||
const scrollOffset = useRef<number | "bottom">("bottom");
|
|
||||||
|
|
||||||
events.reactUse("notify_log", event => {
|
events.reactUse("notify_log", event => {
|
||||||
const logs = event.events.slice(0);
|
const logs = event.events.slice(0);
|
||||||
logs.splice(0, Math.max(0, logs.length - 100));
|
logs.splice(0, Math.max(0, logs.length - backlog));
|
||||||
logs.sort((a, b) => a.timestamp - b.timestamp);
|
logs.sort((a, b) => a.timestamp - b.timestamp);
|
||||||
setLogs(logs);
|
setLogs(logs);
|
||||||
});
|
});
|
||||||
|
@ -69,9 +70,9 @@ const ServerLogRenderer = () => {
|
||||||
}
|
}
|
||||||
|
|
||||||
logs.push(event.event);
|
logs.push(event.event);
|
||||||
logs.splice(0, Math.max(0, logs.length - 100));
|
logs.splice(0, Math.max(0, logs.length - backlog));
|
||||||
logs.sort((a, b) => a.timestamp - b.timestamp);
|
logs.sort((a, b) => a.timestamp - b.timestamp);
|
||||||
setRevision(revision + 1);
|
setRevision(performance.now());
|
||||||
});
|
});
|
||||||
|
|
||||||
const fixScroll = () => {
|
const fixScroll = () => {
|
||||||
|
|
|
@ -116,7 +116,7 @@ const BlockPing = () => {
|
||||||
return undefined;
|
return undefined;
|
||||||
});
|
});
|
||||||
|
|
||||||
events.reactUse("notify_ping", event => setPingInfo(event.ping));
|
events.reactUse("notify_ping", event => setPingInfo(event.ping), undefined, [ ]);
|
||||||
|
|
||||||
let value, title;
|
let value, title;
|
||||||
if(!pingInfo) {
|
if(!pingInfo) {
|
||||||
|
|
|
@ -41,7 +41,7 @@ const ExpendArrow = React.memo(() => {
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
|
|
||||||
events.reactUse("notify_expended", event => setExpended(event.expended), undefined, [ setExpended ]);
|
events.reactUse("notify_expended", event => setExpended(event.expended), undefined, []);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={cssStyle.expendArrow} onClick={() => events.fire("action_toggle_expended", { expended: !expended })}>
|
<div className={cssStyle.expendArrow} onClick={() => events.fire("action_toggle_expended", { expended: !expended })}>
|
||||||
|
@ -776,8 +776,8 @@ const VisibilityHandler = React.memo((props: {
|
||||||
return false;
|
return false;
|
||||||
})
|
})
|
||||||
|
|
||||||
events.reactUse("notify_videos", event => setStreamingCount(event.videoActiveCount));
|
events.reactUse("notify_videos", event => setStreamingCount(event.videoActiveCount), []);
|
||||||
events.reactUse("notify_expended", event => setExpanded(event.expended));
|
events.reactUse("notify_expended", event => setExpanded(event.expended), []);
|
||||||
return (
|
return (
|
||||||
<div className={joinClassList(cssStyle.container, streamingCount === 0 && cssStyle.hidden, expanded && cssStyle.expended)}>
|
<div className={joinClassList(cssStyle.container, streamingCount === 0 && cssStyle.hidden, expanded && cssStyle.expended)}>
|
||||||
{props.children}
|
{props.children}
|
||||||
|
|
Loading…
Reference in New Issue