1
0
mirror of https://github.com/lensapp/lens.git synced 2025-05-20 05:10:56 +00:00

Fix store crash

Signed-off-by: DMYTRO ZHARKOV <dmytrozharkov@DMYTROs-MBP.fritz.box>
This commit is contained in:
DMYTRO ZHARKOV 2022-01-14 12:16:20 +01:00
parent 6f9a675a9c
commit 402eb53aea

View File

@ -28,7 +28,11 @@ import { Switch } from "../switch";
export const Terminal = observer(() => { export const Terminal = observer(() => {
const userStore = UserStore.getInstance(); const userStore = UserStore.getInstance();
const [shell, setShell] = React.useState(userStore.shell || ""); const [terminalSettings, setTerminalSettings] = React.useState({
shell: userStore.shell || "",
terminalFontSize: userStore.terminalFontSize,
terminalFontFamily: userStore.terminalFontFamily,
});
const defaultShell = process.env.SHELL const defaultShell = process.env.SHELL
|| process.env.PTYSHELL || process.env.PTYSHELL
|| ( || (
@ -43,9 +47,12 @@ export const Terminal = observer(() => {
<Input <Input
theme="round-black" theme="round-black"
placeholder={defaultShell} placeholder={defaultShell}
value={shell} value={terminalSettings.shell}
onChange={setShell} onChange={(value) => setTerminalSettings({
onBlur={() => userStore.shell = shell} ...terminalSettings,
shell: value,
})}
onBlur={() => userStore.shell = terminalSettings.shell}
/> />
</section> </section>
@ -65,8 +72,11 @@ export const Terminal = observer(() => {
type="number" type="number"
min={10} min={10}
validators={InputValidators.isNumber} validators={InputValidators.isNumber}
value={userStore.terminalFontSize.toString()} value={terminalSettings.terminalFontSize.toString()}
onChange={value => userStore.terminalFontSize = Number(value)} onChange={(value) => setTerminalSettings({
...terminalSettings,
terminalFontSize: Number(value),
})}
/> />
</section> </section>
<section> <section>
@ -74,8 +84,11 @@ export const Terminal = observer(() => {
<Input <Input
theme="round-black" theme="round-black"
type="text" type="text"
value={userStore.terminalFontFamily} value={terminalSettings.terminalFontFamily}
onChange={value => userStore.terminalFontFamily = value} onChange={(value) => setTerminalSettings({
...terminalSettings,
terminalFontFamily: value.toString(),
})}
/> />
</section> </section>
</div>); </div>);