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
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 30 additions and 6 deletions

View File

@ -61,9 +61,11 @@ class AIChat extends React.Component<{}, {}> {
constructor(props: any) { constructor(props: any) {
super(props); super(props);
mobx.makeObservable(this);
this.chatWindowScrollRef = React.createRef(); this.chatWindowScrollRef = React.createRef();
this.textAreaRef = React.createRef(); this.textAreaRef = React.createRef();
} }
componentDidMount() { componentDidMount() {
const inputModel = GlobalModel.inputModel; const inputModel = GlobalModel.inputModel;
if (this.chatWindowScrollRef?.current != null) { if (this.chatWindowScrollRef?.current != null) {

View File

@ -29,6 +29,11 @@ class CmdInput extends React.Component<{}, {}> {
cmdInputRef: React.RefObject<any> = React.createRef(); cmdInputRef: React.RefObject<any> = React.createRef();
promptRef: React.RefObject<any> = React.createRef(); promptRef: React.RefObject<any> = React.createRef();
constructor(props) {
super(props);
mobx.makeObservable(this);
}
componentDidMount() { componentDidMount() {
this.updateCmdInputHeight(); this.updateCmdInputHeight();
} }

View File

@ -42,6 +42,11 @@ class HItem extends React.Component<
}, },
{} {}
> { > {
constructor(props) {
super(props);
mobx.makeObservable(this);
}
renderRemote(hitem: HistoryItem): any { renderRemote(hitem: HistoryItem): any {
if (hitem.remote == null || isBlank(hitem.remote.remoteid)) { if (hitem.remote == null || isBlank(hitem.remote.remoteid)) {
return sprintf("%-15s ", ""); return sprintf("%-15s ", "");

View File

@ -3,6 +3,7 @@
import * as React from "react"; import * as React from "react";
import * as mobxReact from "mobx-react"; import * as mobxReact from "mobx-react";
import * as mobx from "mobx";
import { If, For } from "tsx-control-statements/components"; import { If, For } from "tsx-control-statements/components";
import cn from "classnames"; import cn from "classnames";
import dayjs from "dayjs"; import dayjs from "dayjs";
@ -17,6 +18,11 @@ dayjs.extend(localizedFormat);
@mobxReact.observer @mobxReact.observer
class InfoMsg extends React.Component<{}, {}> { class InfoMsg extends React.Component<{}, {}> {
constructor(props) {
super(props);
mobx.makeObservable(this);
}
getAfterSlash(s: string): string { getAfterSlash(s: string): string {
if (s.startsWith("^/")) { if (s.startsWith("^/")) {
return s.substring(1); return s.substring(1);

View File

@ -250,6 +250,11 @@ class TextAreaInput extends React.Component<{ screen: Screen; onHeightChange: ()
lastSP: StrWithPos = { str: "", pos: appconst.NoStrPos }; lastSP: StrWithPos = { str: "", pos: appconst.NoStrPos };
version: OV<number> = mobx.observable.box(0, { name: "textAreaInput-version" }); // forces render updates version: OV<number> = mobx.observable.box(0, { name: "textAreaInput-version" }); // forces render updates
constructor(props) {
super(props);
mobx.makeObservable(this);
}
@mobx.action @mobx.action
incVersion(): void { incVersion(): void {
const v = this.version.get(); const v = this.version.get();
@ -313,8 +318,8 @@ class TextAreaInput extends React.Component<{ screen: Screen; onHeightChange: ()
} }
} }
@mobx.action @mobx.action.bound
componentDidMount() { handleComponentDidMount() {
const activeScreen = GlobalModel.getActiveScreen(); const activeScreen = GlobalModel.getActiveScreen();
if (activeScreen != null) { if (activeScreen != null) {
const focusType = activeScreen.focusType.get(); const focusType = activeScreen.focusType.get();
@ -327,6 +332,10 @@ class TextAreaInput extends React.Component<{ screen: Screen; onHeightChange: ()
this.updateSP(); this.updateSP();
} }
componentDidMount() {
this.handleComponentDidMount();
}
@mobx.action @mobx.action
componentDidUpdate() { componentDidUpdate() {
const activeScreen = GlobalModel.getActiveScreen(); const activeScreen = GlobalModel.getActiveScreen();

View File

@ -3,7 +3,6 @@
import type React from "react"; import type React from "react";
import * as mobx from "mobx"; import * as mobx from "mobx";
import { boundMethod } from "autobind-decorator";
import { isBlank } from "@/util/util"; import { isBlank } from "@/util/util";
import * as appconst from "@/app/appconst"; import * as appconst from "@/app/appconst";
import type { Model } from "./model"; import type { Model } from "./model";
@ -75,6 +74,7 @@ class InputModel {
constructor(globalModel: Model) { constructor(globalModel: Model) {
this.globalModel = globalModel; this.globalModel = globalModel;
mobx.makeObservable(this);
mobx.action(() => { mobx.action(() => {
this.codeSelectSelectedIndex.set(-1); this.codeSelectSelectedIndex.set(-1);
this.codeSelectBlockRefArray = []; this.codeSelectBlockRefArray = [];
@ -459,7 +459,6 @@ class InputModel {
this.giveFocus(); this.giveFocus();
} }
@mobx.computed
shouldRenderAuxViewKeybindings(view: InputAuxViewType): boolean { shouldRenderAuxViewKeybindings(view: InputAuxViewType): boolean {
if (view != null && this.getActiveAuxView() != view) { if (view != null && this.getActiveAuxView() != view) {
return false; return false;
@ -723,7 +722,6 @@ class InputModel {
} }
} }
@boundMethod
uiSubmitCommand(): void { uiSubmitCommand(): void {
const commandStr = this.curLine; const commandStr = this.curLine;
if (commandStr.trim() == "") { if (commandStr.trim() == "") {
@ -757,7 +755,6 @@ class InputModel {
} }
@mobx.action @mobx.action
@boundMethod
toggleExpandInput(): void { toggleExpandInput(): void {
this.inputExpanded.set(!this.inputExpanded.get()); this.inputExpanded.set(!this.inputExpanded.get());
this.forceInputFocus = true; this.forceInputFocus = true;