<commit_before>
'use strict';

import {profileReducer} from '../redux/reducers.js';
import {getUserInfo, getAllImages, actionClicked,
    likeImage, linkImage, addImage, removeImage} from '../redux/actions';

import ThunkMiddleware from 'redux-thunk';
import {createStore, applyMiddleware, combineReducers} from 'redux';

const React = require('react');
const ReactDOM = require('react-dom');

const ReactRedux = require('react-redux');

const ProfileTop = require('./profile-top');
const ImagesTop = require('./images-top');

const Provider = ReactRedux.Provider;

let imgTopElem = document.querySelector('#images-top');
let profTopElem = document.querySelector('#profile-app');

let store = createStore(
    combineReducers({
        profileReducer: profileReducer
    }),
    applyMiddleware(
        ThunkMiddleware // Lets us dispatch functions
    )
);

//---------------
// MAP FUNCTIONS
//---------------

let mapDispatchToProps = dispatch => ({
    onClickButton: () => dispatch(actionClicked()),
    onClickRemoveImage: (img) => dispatch(removeImage(img)),
    getUserInfo: () => dispatch(getUserInfo()),
    addImage: (obj) => dispatch(addImage(obj)),
    getAllImages: () => dispatch(getAllImages()),
    linkImage: (img) => dispatch(linkImage(img)),
    likeImage: (img) => dispatch(likeImage(img))
});

let mapStateToProps = (state) => {
    console.log('mapStateToProps with ' + JSON.stringify(state));
    return {
        userData: state.profileReducer.userData,
        images: state.profileReducer.images
    };
};


if (profTopElem) {

    let ProfileTopConnected = ReactRedux.connect(
        mapStateToProps, mapDispatchToProps
    )(ProfileTop);

        ReactDOM.render(
            <Provider store={store}>
                <ProfileTopConnected />
            </Provider>
            ,
            profTopElem);
}
else if (imgTopElem) {

    let ImagesTopConnected = ReactRedux.connect(
        mapStateToProps, mapDispatchToProps
    )(ImagesTop);

        ReactDOM.render(
            <Provider store={store}>
                <ImagesTopConnected />
            </Provider>
            ,
            imgTopElem);
}

<commit_msg>Added unlink/unlikeImage to dispatchToProps.<commit_after>
'use strict';

import {profileReducer} from '../redux/reducers.js';

import {getUserInfo, getAllImages, actionClicked,
    likeImage, linkImage, addImage, removeImage,
    unlikeImage, unlinkImage
} from '../redux/actions';

import ThunkMiddleware from 'redux-thunk';
import {createStore, applyMiddleware, combineReducers} from 'redux';

const React = require('react');
const ReactDOM = require('react-dom');

const ReactRedux = require('react-redux');

const ProfileTop = require('./profile-top');
const ImagesTop = require('./images-top');
const WallsTop = require('./walls-top');

const Provider = ReactRedux.Provider;

let imgTopElem = document.querySelector('#images-top');
let profTopElem = document.querySelector('#profile-app');
let wallsTopElem = document.querySelector('#walls-top');

let store = createStore(
    combineReducers({
        profileReducer: profileReducer
    }),
    applyMiddleware(
        ThunkMiddleware // Lets us dispatch functions
    )
);

//---------------
// MAP FUNCTIONS
//---------------

let mapDispatchToProps = dispatch => ({
    onClickButton: () => dispatch(actionClicked()),
    onClickRemoveImage: (img) => dispatch(removeImage(img)),
    getUserInfo: () => dispatch(getUserInfo()),
    addImage: (obj) => dispatch(addImage(obj)),
    getAllImages: () => dispatch(getAllImages()),
    linkImage: (img) => dispatch(linkImage(img)),
    likeImage: (img) => dispatch(likeImage(img)),
    unlinkImage: (img) => dispatch(unlinkImage(img)),
    unlikeImage: (img) => dispatch(unlikeImage(img))
});

let mapStateToProps = (state) => {
    console.log('mapStateToProps with ' + JSON.stringify(state));
    return {
        userData: state.profileReducer.userData,
        images: state.profileReducer.images
    };
};

// Select which React component is rendered  based on which element was found
// with querySelector()

if (profTopElem) {

    let ProfileTopConnected = ReactRedux.connect(
        mapStateToProps, mapDispatchToProps
    )(ProfileTop);

    ReactDOM.render(
        <Provider store={store}>
            <ProfileTopConnected />
        </Provider>
        ,
        profTopElem);
}
else if (imgTopElem) {

    let ImagesTopConnected = ReactRedux.connect(
        mapStateToProps, mapDispatchToProps
    )(ImagesTop);

    ReactDOM.render(
        <Provider store={store}>
            <ImagesTopConnected />
        </Provider>
        ,
        imgTopElem);
}
else if (wallsTopElem) {

    let WallsTopConnected = ReactRedux.connect(
        mapStateToProps, mapDispatchToProps
    )(WallsTop);

    ReactDOM.render(
        <Provider store={store}>
            <WallsTopConnected />
        </Provider>
        ,
        wallsTopElem);
}


{'fraction_non_alphanumeric': 0.1426242868785656, 'fraction_numerical': 0.0, 'mean_word_length': 3.1743197278911564, 'pattern_counts': {'":': 0, '<': 18, '<?xml version=': 0, '>': 38, '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': '464129', 'n_tokens_mistral': 1430, 'n_tokens_neox': 1415, 'n_words': 298}