<commit_before>import React, {Component} from "react";
import {connect} from "react-redux";
import Users from '../../components/user/Users';
import {
    notifyMeAction,
    notifyMeWithDelayAction
} from "../../actions/users";

import "./home.css";

class Home extends Component {

    constructor() {
        super();
        this.notifyMe = this.notifyMe.bind(this);
        this.notifyMeWithDelay = this.notifyMeWithDelay.bind(this);
    }

    notifyMe(){
        const { dispatch } = this.props;
        dispatch(notifyMeAction("cVE7cjmnmSU:APA91bHAnuvYp_0wbHIA5BaA6z6E_DaLLUDstnKfTU7RlKykAFLJWQdyDF2iV2gtZygmPnuYox0dwgLgjQlnqNBfz9IW2JTXip5Ms6ui44Vq9sao_0YPnxaxdPgtZ5dXrjRxhxRo50vB"));
    }

    notifyMeWithDelay(){
        const { dispatch } = this.props;
        dispatch(notifyMeWithDelayAction("cVE7cjmnmSU:APA91bHAnuvYp_0wbHIA5BaA6z6E_DaLLUDstnKfTU7RlKykAFLJWQdyDF2iV2gtZygmPnuYox0dwgLgjQlnqNBfz9IW2JTXip5Ms6ui44Vq9sao_0YPnxaxdPgtZ5dXrjRxhxRo50vB"));
    }

    render() {
        return (
            <div>
                <Users users={this.props.users}/>
                <button onClick={()=>this.notifyMe()}>Notify me!</button>
                <button onClick={()=>this.notifyMeWithDelay()}>Notify me with delay!</button>
            </div>
        );
    }<commit_msg>add getToken & requestPermission functions to home container<commit_after>import React, {Component} from "react";
import {connect} from "react-redux";
import Users from '../../components/user/Users';
import Permission from '../../components/permission/Permission';
import {
    notifyMeAction,
    notifyMeWithDelayAction,
    updateFcmTokenAction
} from "../../actions/users";
/*global firebase*/
import "./home.css";

class Home extends Component {

    constructor() {
        super();

        this.state = {
            messaging : firebase.messaging()
        };

        this.notifyMe = this.notifyMe.bind(this);
        this.notifyMeWithDelay = this.notifyMeWithDelay.bind(this);
        this.requestPermission = this.requestPermission.bind(this);
        this.getToken = this.getToken.bind(this);
    }

    notifyMe(){
        const { dispatch } = this.props;
        dispatch(notifyMeAction("cVE7cjmnmSU:APA91bHAnuvYp_0wbHIA5BaA6z6E_DaLLUDstnKfTU7RlKykAFLJWQdyDF2iV2gtZygmPnuYox0dwgLgjQlnqNBfz9IW2JTXip5Ms6ui44Vq9sao_0YPnxaxdPgtZ5dXrjRxhxRo50vB"));
    }

    notifyMeWithDelay(){
        const { dispatch } = this.props;
        dispatch(notifyMeWithDelayAction("cVE7cjmnmSU:APA91bHAnuvYp_0wbHIA5BaA6z6E_DaLLUDstnKfTU7RlKykAFLJWQdyDF2iV2gtZygmPnuYox0dwgLgjQlnqNBfz9IW2JTXip5Ms6ui44Vq9sao_0YPnxaxdPgtZ5dXrjRxhxRo50vB"));
    }

    requestPermission(){
        this.state.messaging.requestPermission()
            .then(()=>{
                console.log('Notification permission granted.');
                // TODO(developer): Retrieve an Instance ID token for use with FCM.
                // ...
                this.getToken();
            })
            .catch(function(err) {
                console.log('Unable to get permission to notify.', err);
            });
    }

    getToken(){
        // [START get_token]
        // Get Instance ID token. Initially this makes a network call, once retrieved
        // subsequent calls to getToken will return from cache.
        const { dispatch } = this.props;
        this.state.messaging.getToken()
            .then((currentToken)=>{
                if (currentToken) {
                    console.log("Token received: ", currentToken);
                    dispatch(updateFcmTokenAction(currentToken));
                    //send token to the server
                } else {
                    // Show permission request.
                    console.log('No Instance ID token available. Request permission to generate one.');
                    // this.requestPermission();
                }
            })
            .catch(function(err) {
                console.log('An error occurred while retrieving token. ', err);
                console.log('Error retrieving Instance ID token. ', err);
                // send false to server
            });
    }

    render() {
        return (
            <div>
                <Users users={this.props.users}/>
                <Permission requestPermissionFunc={this.requestPermission}/>
                <button onClick={()=>this.notifyMe()}>Notify me!</button>
                <button onClick={()=>this.notifyMeWithDelay()}>Notify me with delay!</button>
            </div>
        );
    }
{'fraction_non_alphanumeric': 0.11284219897618518, 'fraction_numerical': 0.01958602270198086, 'mean_word_length': 2.3512304250559284, 'pattern_counts': {'":': 0, '<': 18, '<?xml version=': 0, '>': 24, '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': '940554', 'n_tokens_mistral': 1473, 'n_tokens_neox': 1412, 'n_words': 227}