fixes #2119 close open scripts that exist on deleted servers

this prevents a crash by trying to open the script editor with a script
open that exists on a server that has been deleted

this is achieved by filtering the list of open scripts whenever the
editor is opened and removing any that exist on a server that has been
deleted
it also handles the case of the selected script being one that was
removed in which case it defaults to selecting the first script
This commit is contained in:
TheMas3212 2022-01-02 02:10:10 +11:00
parent b578e09986
commit a20dd47ec6
No known key found for this signature in database
GPG Key ID: 62A173A4FDA683CA

@ -120,6 +120,15 @@ export function Root(props: IProps): React.ReactElement {
vim: props.vim || Settings.MonacoVim, vim: props.vim || Settings.MonacoVim,
}); });
// Prevent Crash if script is open on deleted server
openScripts = openScripts.filter((script) => {
return GetServer(script.hostname) !== null;
})
if (currentScript && (GetServer(currentScript.hostname) === null)) {
currentScript = openScripts[0];
}
const [dimensions, setDimensions] = useState({ const [dimensions, setDimensions] = useState({
height: window.innerHeight, height: window.innerHeight,
width: window.innerWidth, width: window.innerWidth,