<commit_before>import React from 'react';
import PropTypes from 'prop-types';
import * as Constants from './Constants';
import AutoRefreshTimer from './AutoRefreshTimer';
import AutoIntervalUpdate from './AutoIntervalUpdate';

export default class Controller extends React.Component {
    static propTypes = {
        onLocalMessage: PropTypes.func,
        timer: PropTypes.object,
        socketStatus: PropTypes.string,
        timerStatus: PropTypes.number,
        lastMessage: PropTypes.string,
        lastControlPassword: PropTypes.string,
        eventOffset: PropTypes.number,
        commandQueue: PropTypes.array,
        params: PropTypes.object,
    };

    constructor(props) {
        super(props);

        this.state = {
            isControllerMode: false,
            showDiagnosticTime: true,
        };

        this.handleButtonClick = this.handleButtonClick.bind(this);
        this.onTimerDoubleClick = this.onTimerDoubleClick.bind(this);
    }

    componentDidMount() {
        setTimeout(() => {
            this.setState({ showDiagnosticTime: false });
        }, 1500);
    }

    handleButtonClick(event) {
        const command = event.target.name;
        this.props.onLocalMessage(command);
    }

    onTimerDoubleClick() {
        this.setState({ isControllerMode: !this.state.isControllerMode });
    }

    get eventOffsetString() {
        const seconds = Math.round(this.props.eventOffset / 1000);
        return `${seconds}`;
    }

    get commandQueueString() {
        if (this.props.commandQueue.length === 0) {
            return 'NIL';
        }

        const currentTime = (new Date()).getTime();<commit_msg>Hide diagnostic time when timer is running<commit_after>import React from 'react';
import PropTypes from 'prop-types';
import * as Constants from './Constants';
import AutoRefreshTimer from './AutoRefreshTimer';
import AutoIntervalUpdate from './AutoIntervalUpdate';

export default class Controller extends React.Component {
    static propTypes = {
        onLocalMessage: PropTypes.func,
        timer: PropTypes.object,
        socketStatus: PropTypes.string,
        timerStatus: PropTypes.number,
        lastMessage: PropTypes.string,
        lastControlPassword: PropTypes.string,
        eventOffset: PropTypes.number,
        commandQueue: PropTypes.array,
        params: PropTypes.object,
    };

    constructor(props) {
        super(props);

        this.state = {
            isControllerMode: false,
            showDiagnosticTime: true,
        };

        this.handleButtonClick = this.handleButtonClick.bind(this);
        this.onTimerDoubleClick = this.onTimerDoubleClick.bind(this);
    }

    componentWillReceiveProps(nextProps) {
        if (this.hideDiagnosticTime
            && nextProps.timerStatus !== Constants.TimerPhase.NOT_RUNNING) {
            // The timer has started, so stop showing the diagnostic time at once.
            clearTimeout(this.hideDiagnosticTime);
            this.hideDiagnosticTime = null;
            this.setState({ showDiagnosticTime: false });
        }
    }

    componentDidMount() {
        this.hideDiagnosticTime = setTimeout(() => {
            this.setState({ showDiagnosticTime: false });
        }, 1500);
    }

    handleButtonClick(event) {
        const command = event.target.name;
        this.props.onLocalMessage(command);
    }

    onTimerDoubleClick() {
        this.setState({ isControllerMode: !this.state.isControllerMode });
    }

    get eventOffsetString() {
        const seconds = Math.round(this.props.eventOffset / 1000);
        return `${seconds}`;
    }

    get commandQueueString() {
        if (this.props.commandQueue.length === 0) {
            return 'NIL';
        }

        const currentTime = (new Date()).getTime();
{'fraction_non_alphanumeric': 0.10508205399682372, 'fraction_numerical': 0.004764425622022234, 'mean_word_length': 2.5350795135640785, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '2438030', 'n_tokens_mistral': 993, 'n_tokens_neox': 986, 'n_words': 213}