<commit_before>import debug from "debug";
import React, { Component, PropTypes } from "react";
import moment from "moment";
import Presenter from "../presenter";

const log = debug("schedule:components:session");

export class Session extends Component {
    render() {
        const { session } = this.props;
        return (
            <div className="session">
                <h4><a href={session.link}>{session.title}</a></h4><commit_msg>Add favourite widget in session component<commit_after>import debug from "debug";
import React, { Component, PropTypes } from "react";
import moment from "moment";
import { getState, updateState } from "../../store";
import Presenter from "../presenter";
import Favourite from "../favourite";

const log = debug("schedule:components:session");

export class Session extends Component {
    resolveIsFavourite(props) {
        const { session } = props;
        const { favourites } = getState();

        this.setState({ isFavourite: favourites.sessions.some(id => id === session.id) });
    }

    componentWillMount() {
        this.resolveIsFavourite(this.props);
    }

    componentWillReceiveProps(newProps) {
        this.resolveIsFavourite(newProps);
    }

    toggleFavourite() {
        const { isFavourite } = this.state;
        const { favourites } = getState();
        const { session } = this.props;

        if (isFavourite) {
            updateState("favourites", { sessions: favourites.sessions.filter(id => id !== session.id) });
        } else {
            updateState("favourites", { sessions: [...favourites.sessions, session.id] });
        }
    }

    render() {
        const { isFavourite } = this.state;
        const { session } = this.props;

        return (
            <div className={"session " + (isFavourite ? "session--favourite" : "")}>
                <h4><a href={session.link}>{session.title}</a></h4>
                <div class="session__favourite">
                    <Favourite selected={isFavourite} onClick={() => this.toggleFavourite() } />
                </div>
{'fraction_non_alphanumeric': 0.14285714285714285, 'fraction_numerical': 0.001943634596695821, 'mean_word_length': 2.6833631484794274, 'pattern_counts': {'":': 0, '<': 16, '<?xml version=': 0, '>': 19, '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': '6326945', 'n_tokens_mistral': 597, 'n_tokens_neox': 570, 'n_words': 133}