Skip to content
This repository has been archived by the owner on May 21, 2019. It is now read-only.

Commit

Permalink
Remove some JobComponent state attributes.
Browse files Browse the repository at this point in the history
  • Loading branch information
vlad-shatskyi committed Jun 2, 2016
1 parent ad1c323 commit 5cfee8e
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 12 deletions.
16 changes: 6 additions & 10 deletions src/views/3_JobComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ interface Props {
}

interface State {
status?: e.Status;
canBeDecorated?: boolean;
decorate?: boolean;
}

Expand All @@ -21,9 +19,7 @@ export default class JobComponent extends React.Component<Props, State> implemen
super(props);

this.state = {
status: this.props.job.status,
decorate: false,
canBeDecorated: false,
};

// FIXME: find a better design to propagate events.
Expand All @@ -34,8 +30,8 @@ export default class JobComponent extends React.Component<Props, State> implemen

componentDidMount() {
this.props.job
.on("data", () => this.setState({canBeDecorated: this.props.job.canBeDecorated()}))
.on("status", (status: e.Status) => this.setState({status: status}));
.on("data", () => this.forceUpdate())
.on("status", () => this.forceUpdate())
}

componentDidUpdate() {
Expand All @@ -47,16 +43,16 @@ export default class JobComponent extends React.Component<Props, State> implemen

render() {
let buffer: React.ReactElement<any>;
if (this.state.canBeDecorated && this.state.decorate) {
if (this.props.job.canBeDecorated() && this.state.decorate) {
buffer = this.props.job.decorate();
} else {
buffer = <BufferComponent job={this.props.job}/>;
}

return (
<div className={"job " + this.state.status}>
<div className={"job"}>
<PromptComponent job={this.props.job}
status={this.state.status}
status={this.props.job.status}
hasLocusOfAttention={this.props.hasLocusOfAttention}
jobView={this}/>
{buffer}
Expand All @@ -70,7 +66,7 @@ export default class JobComponent extends React.Component<Props, State> implemen
return;
}

if (this.state.status === e.Status.InProgress && !event.metaKey && !isModifierKey(event)) {
if (this.props.job.status === e.Status.InProgress && !event.metaKey && !isModifierKey(event)) {
if (keys.interrupt(event)) {
this.props.job.interrupt();
} else {
Expand Down
2 changes: 1 addition & 1 deletion src/views/4_PromptComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ export default class PromptComponent extends React.Component<Props, State> imple
}
}

if (this.props.jobView.state.canBeDecorated) {
if (this.props.job.canBeDecorated()) {
decorationToggle = <DecorationToggleComponent job={this.props.jobView}/>;
}

Expand Down
1 change: 0 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
"experimentalDecorators": true,
"noImplicitAny": true,
"noEmitOnError": true,
"pretty": true,
"jsx": "react",
"outDir": "compiled/src"
},
Expand Down

0 comments on commit 5cfee8e

Please sign in to comment.