<commit_before>import * as React from "react";
import * as e from "../Enums";
import JobModel from "../Job";
import {keys} from "./ViewUtils";
import PromptComponent from "./4_PromptComponent";
import BufferComponent from "./BufferComponent";

interface Props {
    job: JobModel;
    hasLocusOfAttention: boolean;
}

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

export default class JobComponent extends React.Component<Props, State> implements KeyDownReceiver {
    constructor(props: Props) {
        super(props);

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

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

        // FIXME: find a better design to propagate events.
        if (this.props.hasLocusOfAttention) {
            window.jobUnderAttention = this;
        }
    }

    componentDidUpdate() {
        // FIXME: find a better design to propagate events.
        if (this.props.hasLocusOfAttention) {
            window.jobUnderAttention = this;
        }
    }<commit_msg>Don't set state in constructor.<commit_after>import * as React from "react";
import * as e from "../Enums";
import JobModel from "../Job";
import {keys} from "./ViewUtils";
import PromptComponent from "./4_PromptComponent";
import BufferComponent from "./BufferComponent";

interface Props {
    job: JobModel;
    hasLocusOfAttention: boolean;
}

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

export default class JobComponent extends React.Component<Props, State> implements KeyDownReceiver {
    constructor(props: Props) {
        super(props);

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

        // FIXME: find a better design to propagate events.
        if (this.props.hasLocusOfAttention) {
            window.jobUnderAttention = this;
        }
    }

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

    componentDidUpdate() {
        // FIXME: find a better design to propagate events.
        if (this.props.hasLocusOfAttention) {
            window.jobUnderAttention = this;
        }
    }
{'fraction_non_alphanumeric': 0.11948249619482496, 'fraction_numerical': 0.00076103500761035, 'mean_word_length': 2.5288590604026844, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7561813', 'n_tokens_mistral': 753, 'n_tokens_neox': 746, 'n_words': 191}