Call makeObservable for all cmdInput classes (#619)

This commit is contained in:
Evan Simkowitz
2024-04-30 13:58:54 -07:00
committed by GitHub
parent c53e0a99f6
commit 35e0488f7b
6 changed files with 30 additions and 6 deletions
+2
View File
@@ -61,9 +61,11 @@ class AIChat extends React.Component<{}, {}> {
constructor(props: any) {
super(props);
mobx.makeObservable(this);
this.chatWindowScrollRef = React.createRef();
this.textAreaRef = React.createRef();
}
componentDidMount() {
const inputModel = GlobalModel.inputModel;
if (this.chatWindowScrollRef?.current != null) {
+5
View File
@@ -29,6 +29,11 @@ class CmdInput extends React.Component<{}, {}> {
cmdInputRef: React.RefObject<any> = React.createRef();
promptRef: React.RefObject<any> = React.createRef();
constructor(props) {
super(props);
mobx.makeObservable(this);
}
componentDidMount() {
this.updateCmdInputHeight();
}
@@ -42,6 +42,11 @@ class HItem extends React.Component<
},
{}
> {
constructor(props) {
super(props);
mobx.makeObservable(this);
}
renderRemote(hitem: HistoryItem): any {
if (hitem.remote == null || isBlank(hitem.remote.remoteid)) {
return sprintf("%-15s ", "");
+6
View File
@@ -3,6 +3,7 @@
import * as React from "react";
import * as mobxReact from "mobx-react";
import * as mobx from "mobx";
import { If, For } from "tsx-control-statements/components";
import cn from "classnames";
import dayjs from "dayjs";
@@ -17,6 +18,11 @@ dayjs.extend(localizedFormat);
@mobxReact.observer
class InfoMsg extends React.Component<{}, {}> {
constructor(props) {
super(props);
mobx.makeObservable(this);
}
getAfterSlash(s: string): string {
if (s.startsWith("^/")) {
return s.substring(1);
+11 -2
View File
@@ -250,6 +250,11 @@ class TextAreaInput extends React.Component<{ screen: Screen; onHeightChange: ()
lastSP: StrWithPos = { str: "", pos: appconst.NoStrPos };
version: OV<number> = mobx.observable.box(0, { name: "textAreaInput-version" }); // forces render updates
constructor(props) {
super(props);
mobx.makeObservable(this);
}
@mobx.action
incVersion(): void {
const v = this.version.get();
@@ -313,8 +318,8 @@ class TextAreaInput extends React.Component<{ screen: Screen; onHeightChange: ()
}
}
@mobx.action
componentDidMount() {
@mobx.action.bound
handleComponentDidMount() {
const activeScreen = GlobalModel.getActiveScreen();
if (activeScreen != null) {
const focusType = activeScreen.focusType.get();
@@ -327,6 +332,10 @@ class TextAreaInput extends React.Component<{ screen: Screen; onHeightChange: ()
this.updateSP();
}
componentDidMount() {
this.handleComponentDidMount();
}
@mobx.action
componentDidUpdate() {
const activeScreen = GlobalModel.getActiveScreen();
+1 -4
View File
@@ -3,7 +3,6 @@
import type React from "react";
import * as mobx from "mobx";
import { boundMethod } from "autobind-decorator";
import { isBlank } from "@/util/util";
import * as appconst from "@/app/appconst";
import type { Model } from "./model";
@@ -75,6 +74,7 @@ class InputModel {
constructor(globalModel: Model) {
this.globalModel = globalModel;
mobx.makeObservable(this);
mobx.action(() => {
this.codeSelectSelectedIndex.set(-1);
this.codeSelectBlockRefArray = [];
@@ -459,7 +459,6 @@ class InputModel {
this.giveFocus();
}
@mobx.computed
shouldRenderAuxViewKeybindings(view: InputAuxViewType): boolean {
if (view != null && this.getActiveAuxView() != view) {
return false;
@@ -723,7 +722,6 @@ class InputModel {
}
}
@boundMethod
uiSubmitCommand(): void {
const commandStr = this.curLine;
if (commandStr.trim() == "") {
@@ -757,7 +755,6 @@ class InputModel {
}
@mobx.action
@boundMethod
toggleExpandInput(): void {
this.inputExpanded.set(!this.inputExpanded.get());
this.forceInputFocus = true;