Bug #1211 When click Open Devtools turns already-opened devtools white

This commit is contained in:
TankistPro 2024-04-06 23:54:00 +03:00
parent e32d1c309a
commit 0b87dd750e

View file

@ -205,10 +205,15 @@ const Device = ({ isPrimary, device, setIndividualDevice }: Props) => {
return; return;
} }
const webview = ref.current as Electron.WebviewTag; const webview = ref.current as Electron.WebviewTag;
const isOpenedCurrentDevTool =
if (webview == null) { devtoolsOpenForWebviewId === webview.getWebContentsId();
if (webview == null || isOpenedCurrentDevTool) {
return; return;
} }
if (!isOpenedCurrentDevTool && devtoolsOpenForWebviewId !== -1) {
await window.electron.ipcRenderer.invoke('close-devtools');
dispatch(setDevtoolsClose());
}
await window.electron.ipcRenderer.invoke< await window.electron.ipcRenderer.invoke<
OpenDevtoolsArgs, OpenDevtoolsArgs,
OpenDevtoolsResult OpenDevtoolsResult
@ -217,7 +222,7 @@ const Device = ({ isPrimary, device, setIndividualDevice }: Props) => {
dockPosition, dockPosition,
}); });
dispatch(setDevtoolsOpen(webview.getWebContentsId())); dispatch(setDevtoolsOpen(webview.getWebContentsId()));
}, [dispatch, dockPosition]); }, [devtoolsOpenForWebviewId, dispatch, dockPosition]);
const inspectElement = useCallback( const inspectElement = useCallback(
async (deviceX: number, deviceY: number) => { async (deviceX: number, deviceY: number) => {