<commit_before>import React from "react";

import {emitter, getFlash, clearFlash} from "../utils/flash";
import {isEmpty} from "../utils/utils";

export default class Flash extends React.Component {

    constructor() {
        super();
        this.state = {flash: {}, className: "hide", type: "info"};
        this.callback = flash => {
            this.setState({flash: flash, className: isEmpty(flash) || isEmpty(flash.message) ? "hide" : ""});
            if (flash && (!flash.type || flash.type !== "error")) {
                setTimeout(() => this.setState({className: "hide"}), flash.type === "info" ? 3500 : 5500);
            }
        };
    }

    componentWillMount() {
        this.setState({flash: getFlash()});
        emitter.addListener("flash", this.callback);
    }

    componentWillUnmount() {
        emitter.removeListener("flash", this.callback);
    }

    render() {
        const {flash, className} = this.state;

        return (
            <div className={`flash ${className} ${flash.type}`}>
                {className !== "hide" &&
                <div className="message-container">
                    <p dangerouslySetInnerHTML={{__html: flash.message}}>
                    </p>
                    <a className="close" href="#" onClick={clearFlash}>
                        <i className="fa fa-remove"></i>
                    </a>
                </div>}
            </div>
        );
    }
}<commit_msg>Fixed animation bug in flash<commit_after>import React from "react";

import {emitter, getFlash, clearFlash} from "../utils/flash";
import {isEmpty} from "../utils/utils";

export default class Flash extends React.Component {

    constructor() {
        super();
        this.state = {flash: {}, className: "hide", type: "info"};
        this.callback = flash => {
            this.setState({flash: flash, className: isEmpty(flash) || isEmpty(flash.message) ? "hide" : ""});
            if (flash && (!flash.type || flash.type !== "error")) {
                setTimeout(() => this.setState({className: "hide"}), flash.type === "info" ? 3500 : 5500);
            }
        };
    }

    componentWillMount() {
        this.setState({flash: getFlash()});
        emitter.addListener("flash", this.callback);
    }

    componentWillUnmount() {
        emitter.removeListener("flash", this.callback);
    }

    render() {
        const {flash, className} = this.state;

        return (
            <div className={`flash ${className} ${flash.type}`}>
                <div className="message-container">
                    <p dangerouslySetInnerHTML={{__html: flash.message}}>
                    </p>
                    <a className="close" href="#" onClick={clearFlash}>
                        <i className="fa fa-remove"></i>
                    </a>
                </div>
            </div>
        );
    }
}
{'fraction_non_alphanumeric': 0.16474291710388247, 'fraction_numerical': 0.005596362364463099, 'mean_word_length': 1.9273285568065506, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 27, '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': '6194034', 'n_tokens_mistral': 798, 'n_tokens_neox': 751, 'n_words': 170}