Merge pull request #3273 from danielyxie/dev

Remove tail window search
This commit is contained in:
hydroflame 2022-03-29 17:20:20 -04:00 committed by GitHub
commit c793965a4b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 39 additions and 45 deletions

26
dist/vendor.bundle.js vendored

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

@ -119,7 +119,7 @@ export const logBoxBaseZIndex = 1500;
function LogWindow(props: IProps): React.ReactElement { function LogWindow(props: IProps): React.ReactElement {
const draggableRef = useRef<HTMLDivElement>(null); const draggableRef = useRef<HTMLDivElement>(null);
const rootRef = useRef<Draggable>(null) const rootRef = useRef<Draggable>(null);
const [script, setScript] = useState(props.script); const [script, setScript] = useState(props.script);
const classes = useStyles(); const classes = useStyles();
const container = useRef<HTMLDivElement>(null); const container = useRef<HTMLDivElement>(null);
@ -129,22 +129,22 @@ function LogWindow(props: IProps): React.ReactElement {
setRerender((old) => !old); setRerender((old) => !old);
} }
useEffect( // useEffect(
() => // () =>
WorkerScriptStartStopEventEmitter.subscribe(() => { // WorkerScriptStartStopEventEmitter.subscribe(() => {
setTimeout(() => { // setTimeout(() => {
const server = GetServer(script.server); // const server = GetServer(script.server);
if (server === null) return; // if (server === null) return;
const exisitingScript = findRunningScript(script.filename, script.args, server); // const exisitingScript = findRunningScript(script.filename, script.args, server);
if (exisitingScript) { // if (exisitingScript) {
exisitingScript.logs = script.logs.concat(exisitingScript.logs) // exisitingScript.logs = script.logs.concat(exisitingScript.logs)
setScript(exisitingScript) // setScript(exisitingScript)
} // }
rerender(); // rerender();
}, 100) // }, 100)
}), // }),
[], // [],
); // );
useEffect(() => { useEffect(() => {
updateLayer(); updateLayer();
@ -224,11 +224,8 @@ function LogWindow(props: IProps): React.ReactElement {
const isOnScreen = (node: HTMLDivElement): boolean => { const isOnScreen = (node: HTMLDivElement): boolean => {
const bounds = node.getBoundingClientRect(); const bounds = node.getBoundingClientRect();
return !(bounds.right < 0 || return !(bounds.right < 0 || bounds.bottom < 0 || bounds.left > innerWidth || bounds.top > outerWidth);
bounds.bottom < 0 || };
bounds.left > innerWidth ||
bounds.top > outerWidth);
}
const resetPosition = (): void => { const resetPosition = (): void => {
const node = rootRef?.current; const node = rootRef?.current;
@ -237,14 +234,11 @@ function LogWindow(props: IProps): React.ReactElement {
state.x = 0; state.x = 0;
state.y = 0; state.y = 0;
node.setState(state); node.setState(state);
} };
const boundToBody = (e: any): void | false => { const boundToBody = (e: any): void | false => {
if (e.clientX < 0 || if (e.clientX < 0 || e.clientY < 0 || e.clientX > innerWidth || e.clientY > innerHeight) return false;
e.clientY < 0 || };
e.clientX > innerWidth ||
e.clientY > innerHeight) return false;
}
return ( return (
<Draggable handle=".drag" onDrag={boundToBody} ref={rootRef}> <Draggable handle=".drag" onDrag={boundToBody} ref={rootRef}>