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

Add reaction to update terminals. Cleanup

Signed-off-by: DMYTRO ZHARKOV <dmytrozharkov@DMYTROs-MBP.fritz.box>
This commit is contained in:
DMYTRO ZHARKOV 2022-01-18 14:59:09 +01:00
parent 5beb4f18bc
commit 2ca1973add
3 changed files with 8 additions and 27 deletions

View File

@ -25,13 +25,9 @@ import { SubTitle } from "../layout/sub-title";
import { Input, InputValidators } from "../input"; import { Input, InputValidators } from "../input";
import { isWindows } from "../../../common/vars"; import { isWindows } from "../../../common/vars";
import { Switch } from "../switch"; import { Switch } from "../switch";
import { TerminalStore } from "../dock/terminal.store";
import { dockStore, TabKind } from "../dock/dock.store";
export const Terminal = observer(() => { export const Terminal = observer(() => {
const userStore = UserStore.getInstance(); const userStore = UserStore.getInstance();
const terminalStore = TerminalStore.getInstance();
const { tabs, selectedTab, isOpen } = dockStore;
const [terminalSettings, setTerminalSettings] = React.useState({ const [terminalSettings, setTerminalSettings] = React.useState({
shell: userStore.shell || "", shell: userStore.shell || "",
terminalFontSize: userStore.terminalConfig.fontSize, terminalFontSize: userStore.terminalConfig.fontSize,
@ -81,17 +77,7 @@ export const Terminal = observer(() => {
...terminalSettings, ...terminalSettings,
terminalFontSize: Number(value), terminalFontSize: Number(value),
})} })}
onBlur={() => { onBlur={() => userStore.terminalConfig.fontSize = terminalSettings.terminalFontSize}
userStore.terminalConfig.fontSize = terminalSettings.terminalFontSize;
console.log("tabs", tabs);
console.log("selectedTab", selectedTab);
if (selectedTab?.kind === TabKind.TERMINAL && isOpen) {
terminalStore.reconnect(selectedTab.id);
}
terminalStore.reconnectTerminals();
}}
/> />
</section> </section>
<section> <section>
@ -104,10 +90,7 @@ export const Terminal = observer(() => {
...terminalSettings, ...terminalSettings,
terminalFontFamily: value.toString(), terminalFontFamily: value.toString(),
})} })}
onBlur={() => { onBlur={() => userStore.terminalConfig.fontFamily = terminalSettings.terminalFontFamily}
userStore.terminalConfig.fontFamily = terminalSettings.terminalFontFamily;
terminalStore.reconnectTerminals();
}}
/> />
</section> </section>
</div>); </div>);

View File

@ -107,14 +107,6 @@ export class TerminalStore extends Singleton {
return this.connections.get(tabId)?.readyState === WebSocketApiState.CLOSED; return this.connections.get(tabId)?.readyState === WebSocketApiState.CLOSED;
} }
reconnectTerminals() {
console.log("Reconencting connections", this.connections);
console.log("Reconencting terminals", this.terminals);
this.connections.forEach(cn => {
console.log("cn", cn);
});
}
async sendCommand(command: string, options: { enter?: boolean; newTab?: boolean; tabId?: TabId } = {}) { async sendCommand(command: string, options: { enter?: boolean; newTab?: boolean; tabId?: TabId } = {}) {
const { enter, newTab, tabId } = options; const { enter, newTab, tabId } = options;

View File

@ -101,6 +101,12 @@ export class Terminal {
}, { }, {
fireImmediately: true, fireImmediately: true,
}), }),
reaction(() => UserStore.getInstance().terminalConfig.fontSize, this.setFontSize, {
fireImmediately: true,
}),
reaction(() => UserStore.getInstance().terminalConfig.fontFamily, this.setFontFamily, {
fireImmediately: true,
}),
dependencies.dockStore.onResize(this.onResize), dependencies.dockStore.onResize(this.onResize),
() => onDataHandler.dispose(), () => onDataHandler.dispose(),
() => this.fitAddon.dispose(), () => this.fitAddon.dispose(),