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

adding missing mobx.makeObservable(this) -- part 1

Signed-off-by: Roman <ixrock@gmail.com>
This commit is contained in:
Roman 2021-04-23 16:32:17 +03:00
parent 671e7c26ca
commit 484ab443a2
4 changed files with 18 additions and 14 deletions

View File

@ -1,13 +1,18 @@
import React from "react"; import React from "react";
import { observer } from "mobx-react"; import { observer } from "mobx-react";
import { Select } from "../select"; import { Select } from "../select";
import { computed } from "mobx"; import { computed, makeObservable } from "mobx";
import { HotbarStore } from "../../../common/hotbar-store"; import { HotbarStore } from "../../../common/hotbar-store";
import { CommandOverlay } from "../command-palette"; import { CommandOverlay } from "../command-palette";
import { ConfirmDialog } from "../confirm-dialog"; import { ConfirmDialog } from "../confirm-dialog";
@observer @observer
export class HotbarRemoveCommand extends React.Component { export class HotbarRemoveCommand extends React.Component {
constructor(props: object) {
super(props);
makeObservable(this);
}
@computed get options() { @computed get options() {
return HotbarStore.getInstance().hotbars.map((hotbar) => { return HotbarStore.getInstance().hotbars.map((hotbar) => {
return { value: hotbar.id, label: hotbar.name }; return { value: hotbar.id, label: hotbar.name };

View File

@ -1,7 +1,7 @@
import React from "react"; import React from "react";
import { observer } from "mobx-react"; import { observer } from "mobx-react";
import { Select } from "../select"; import { Select } from "../select";
import { computed } from "mobx"; import { computed, makeObservable } from "mobx";
import { HotbarStore } from "../../../common/hotbar-store"; import { HotbarStore } from "../../../common/hotbar-store";
import { CommandOverlay } from "../command-palette"; import { CommandOverlay } from "../command-palette";
import { HotbarAddCommand } from "./hotbar-add-command"; import { HotbarAddCommand } from "./hotbar-add-command";
@ -12,6 +12,11 @@ export class HotbarSwitchCommand extends React.Component {
private static addActionId = "__add__"; private static addActionId = "__add__";
private static removeActionId = "__remove__"; private static removeActionId = "__remove__";
constructor(props: object) {
super(props);
makeObservable(this);
}
@computed get options() { @computed get options() {
const hotbarStore = HotbarStore.getInstance(); const hotbarStore = HotbarStore.getInstance();
const options = hotbarStore.hotbars.map((hotbar) => { const options = hotbarStore.hotbars.map((hotbar) => {

View File

@ -1,6 +1,6 @@
import React from "react"; import React from "react";
import debounce from "lodash/debounce"; import debounce from "lodash/debounce";
import { autorun, observable, makeObservable } from "mobx"; import { autorun, makeObservable, observable } from "mobx";
import { disposeOnUnmount, observer } from "mobx-react"; import { disposeOnUnmount, observer } from "mobx-react";
import { InputProps } from "./input"; import { InputProps } from "./input";
import { SearchInput } from "./search-input"; import { SearchInput } from "./search-input";

View File

@ -1,7 +1,6 @@
import "./search-input.scss"; import "./search-input.scss";
import React, { createRef } from "react"; import React, { createRef } from "react";
import { makeObservable } from "mobx";
import { observer } from "mobx-react"; import { observer } from "mobx-react";
import { autobind, cssNames } from "../../utils"; import { autobind, cssNames } from "../../utils";
import { Icon } from "../icon"; import { Icon } from "../icon";
@ -29,11 +28,6 @@ export class SearchInput extends React.Component<Props> {
private inputRef = createRef<Input>(); private inputRef = createRef<Input>();
constructor(props: Props) {
super(props);
makeObservable(this);
}
componentDidMount() { componentDidMount() {
if (!this.props.bindGlobalFocusHotkey) return; if (!this.props.bindGlobalFocusHotkey) return;
window.addEventListener("keydown", this.onGlobalKey); window.addEventListener("keydown", this.onGlobalKey);