<commit_before>import React from "react";
import Translate from "react-translate-component";
import SettingsActions from "actions/SettingsActions";
import notify from "actions/NotificationActions";
import counterpart from "counterpart";

class RestoreFavorites extends React.Component {
    constructor(props) {
        super(props);

        this.state = {
            json: null,
            error: null
        };
    }

    upload(evt) {
        this.setState({error: false, json: null});

        let file = evt.target.files[0];
        let reader = new FileReader();
        reader.onload = evt => {
            let contents = evt.target.result;

            try {
                let json = JSON.parse(contents);

                for (var key in json) {
                    let market = json[key];
                    let {quote, base} = market;

                    if (!quote || !base)
                        throw new Error("Cannot parse json data.");
                }

                this.setState({json});
                // this.finish();
            } catch (message) {
                this.setState({error: true});
            }
        };
        reader.readAsText(file);
    }

    finish() {
        const {json} = this.state;

        SettingsActions.clearStarredMarkets();

        for (var key in json) {
            let market = json[key];
            let {quote, base} = market;

            SettingsActions.addStarMarket(quote, base);
        }

        notify.addNotification({
            message: counterpart("settings.backup_favorites_success"),
            level: "success",
            autoDismiss: 2
        });
    }

    render() {
        const {state} = this;

        return (
            <div>
                <input
                    type="file"
                    id="file_input"
                    accept=".json"
                    style={{
                        border: "solid",
                        marginBottom: 15
                    }}
                    onChange={this.upload.bind(this)}
                />

                {state.error && (
                    <h5>
                        <Translate content="settings.backup_favorites_error" />
                    </h5>
                )}

                {state.json && (
                    <p>
                        <button
                            onClick={this.finish.bind(this)}
                            className="button success"
                        >
                            <Translate content="settings.backup_favorites_finish" />
                        </button>
                    </p>
                )}
            </div>
        );
    }
}

export default RestoreFavorites;
<commit_msg>#1966 Replace Notification on RestoreFavorites<commit_after>import React from "react";
import Translate from "react-translate-component";
import SettingsActions from "actions/SettingsActions";
import counterpart from "counterpart";
import {Notification} from "bitshares-ui-style-guide";

class RestoreFavorites extends React.Component {
    constructor(props) {
        super(props);

        this.state = {
            json: null,
            error: null
        };
    }

    upload(evt) {
        this.setState({error: false, json: null});

        let file = evt.target.files[0];
        let reader = new FileReader();
        reader.onload = evt => {
            let contents = evt.target.result;

            try {
                let json = JSON.parse(contents);

                for (var key in json) {
                    let market = json[key];
                    let {quote, base} = market;

                    if (!quote || !base)
                        throw new Error("Cannot parse json data.");
                }

                this.setState({json});
                // this.finish();
            } catch (message) {
                this.setState({error: true});
            }
        };
        reader.readAsText(file);
    }

    finish() {
        const {json} = this.state;

        SettingsActions.clearStarredMarkets();

        for (var key in json) {
            let market = json[key];
            let {quote, base} = market;

            SettingsActions.addStarMarket(quote, base);
        }

        Notification.success({
            message: counterpart("settings.backup_favorites_success")
        });
    }

    render() {
        const {state} = this;

        return (
            <div>
                <input
                    type="file"
                    id="file_input"
                    accept=".json"
                    style={{
                        border: "solid",
                        marginBottom: 15
                    }}
                    onChange={this.upload.bind(this)}
                />

                {state.error && (
                    <h5>
                        <Translate content="settings.backup_favorites_error" />
                    </h5>
                )}

                {state.json && (
                    <p>
                        <button
                            onClick={this.finish.bind(this)}
                            className="button success"
                        >
                            <Translate content="settings.backup_favorites_finish" />
                        </button>
                    </p>
                )}
            </div>
        );
    }
}

export default RestoreFavorites;

{'fraction_non_alphanumeric': 0.10349264705882352, 'fraction_numerical': 0.0027573529411764708, 'mean_word_length': 1.1113698098564222, 'pattern_counts': {'":': 0, '<': 25, '<?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': '4142731', 'n_tokens_mistral': 1372, 'n_tokens_neox': 1271, 'n_words': 282}