mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2026-04-22 17:23:00 +02:00
BUGFIX: Crash in theme editor modal (#1735)
This commit is contained in:
@@ -11,6 +11,7 @@ import { Modal } from "../../ui/React/Modal";
|
||||
import { OptionSwitch } from "../../ui/React/OptionSwitch";
|
||||
|
||||
import { defaultMonacoTheme } from "./themes";
|
||||
import { dialogBoxCreate } from "../../ui/React/DialogBox";
|
||||
|
||||
type ColorEditorProps = {
|
||||
label: string;
|
||||
@@ -74,12 +75,19 @@ export function ThemeEditorModal(props: ThemeEditorProps): React.ReactElement {
|
||||
|
||||
function onThemeChange(event: React.ChangeEvent<HTMLInputElement>): void {
|
||||
try {
|
||||
const importedTheme = JSON.parse(event.target.value);
|
||||
if (typeof importedTheme !== "object") return;
|
||||
const importedTheme = JSON.parse(event.target.value) as typeof Settings.EditorTheme;
|
||||
if (importedTheme == null) {
|
||||
throw new Error("Theme data must not be null or undefined.");
|
||||
}
|
||||
if (typeof importedTheme !== "object") {
|
||||
throw new Error(`Theme data is invalid.`);
|
||||
}
|
||||
Settings.EditorTheme = importedTheme;
|
||||
props.onChange();
|
||||
} catch (err) {
|
||||
// ignore
|
||||
} catch (error) {
|
||||
console.error(`Theme data is invalid. Data: ${event.target.value}.`);
|
||||
console.error(error);
|
||||
dialogBoxCreate(`Invalid theme. ${error}`);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user