<commit_before>import React from "react";
import ChainTypes from "../Utility/ChainTypes";
import BindToChainState from "../Utility/BindToChainState";
import {ChainTypes as GraphChainTypes, ChainStore} from "bitsharesjs/es";
import counterpart from "counterpart";
import utils from "common/utils";
import Notify from "notifyjs";
let {operations} = GraphChainTypes;

let OPERATIONS = Object.keys(operations);

class BrowserNotifications extends React.Component {

    static propTypes = {
        account: ChainTypes.ChainAccount.isRequired,
        settings: React.PropTypes.object,
    };

    componentWillReceiveProps(nextProps) {

        // if browser notifications disabled on settings we can skip all checks
        if(!nextProps.settings.get("browser_notifications").allow) {
            console.log("browser notifications disabled by settings");
            return false;
        }

        // if app not permitted to send notifications skip all checks
        if(Notify.needsPermission) {
            console.log("browser notifications disabled by Browser Permissions");
            return false;
        }

        if (nextProps.account.size && this.props.account.get("history")) {

            let lastOperationOld = this.props.account.get("history").first();
            let lastOperationNew = nextProps.account.get("history").first();
<commit_msg>Ask for permission for browser notifications when user opens app #686<commit_after>import React from "react";
import ChainTypes from "../Utility/ChainTypes";
import BindToChainState from "../Utility/BindToChainState";
import {ChainTypes as GraphChainTypes, ChainStore} from "bitsharesjs/es";
import counterpart from "counterpart";
import utils from "common/utils";
import Notify from "notifyjs";
let {operations} = GraphChainTypes;

let OPERATIONS = Object.keys(operations);

class BrowserNotifications extends React.Component {

    static propTypes = {
        account: ChainTypes.ChainAccount.isRequired,
        settings: React.PropTypes.object,
    };

    componentWillMount() {
        if(Notify.needsPermission) {
            Notify.requestPermission();
        }
    }

    componentWillReceiveProps(nextProps) {

        // if browser notifications disabled on settings we can skip all checks
        if(!nextProps.settings.get("browser_notifications").allow) {
            console.log("browser notifications disabled by settings");
            return false;
        }

        // if app not permitted to send notifications skip all checks
        if(Notify.needsPermission) {
            console.log("browser notifications disabled by Browser Permissions");
            return false;
        }

        if (nextProps.account.size && this.props.account.get("history")) {

            let lastOperationOld = this.props.account.get("history").first();
            let lastOperationNew = nextProps.account.get("history").first();

{'fraction_non_alphanumeric': 0.09803244735933725, 'fraction_numerical': 0.0010355540214014498, 'mean_word_length': 3.230656934306569, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '3137836', 'n_tokens_mistral': 733, 'n_tokens_neox': 699, 'n_words': 203}