<commit_before>/**
 * Created by ksinger on 10.05.2016.
 */
import { actionTypes } from '../actions/actions.js';
import { repeatVar } from '../utils.js';
import Immutable from 'immutable';
import { createReducer } from 'redux-immutablejs'
import { combineReducersStable } from '../redux-utils.js';
import { buildCreateMessage } from '../won-message-utils.js';
import won from '../won-es6.js';

const initialState = Immutable.fromJS({loggedIn: false});

export default function(userData = initialState, action = {}) {
    switch(action.type) {
        case actionTypes.initialPageLoad:
        case actionTypes.login:
            console.log('login called');

            //because we get payload as immutablejs-map sometimes but not always
            var immutablePayload = Immutable.fromJS(action.payload);

            var loggedIn = immutablePayload.get('loggedIn');
            var email = immutablePayload.get('email');

            if(loggedIn){
                console.log('reducers.js: received successful-login action from app-server');
                return Immutable.fromJS({loggedIn: true, email: email});
            } else {
                return userData;
            }

        case actionTypes.logout:
            console.log('logout called');
            return Immutable.fromJS({loggedIn: false});

        case actionTypes.loginFailed:
            console.log('reducers.js: received UNsuccessful-login action from app-server');
            return Immutable.fromJS({loginError: action.payload.loginError, loggedIn: false});

        case actionTypes.loginReset:
            console.log('loginReset called');
            if(!userData.get("loggedIn")){
                return Immutable.fromJS({loginError: undefined});
            } else {
                return userData
            }

        case actionTypes.registerReset:
            console.log('registerReset called');
            return Immutable.fromJS({registerError: undefined});

        case actionTypes.registerFailed:
            console.log('reducers.js: received UNsuccessful-login action from app-server');
            return Immutable.fromJS({registerError: action.payload.registerError});

        default:
            return userData;
    }
}<commit_msg>Removed console output in user-reducer.<commit_after>/**
 * Created by ksinger on 10.05.2016.
 */
import { actionTypes } from '../actions/actions.js';
import { repeatVar } from '../utils.js';
import Immutable from 'immutable';
import { createReducer } from 'redux-immutablejs'
import { combineReducersStable } from '../redux-utils.js';
import { buildCreateMessage } from '../won-message-utils.js';
import won from '../won-es6.js';

const initialState = Immutable.fromJS({loggedIn: false});

export default function(userData = initialState, action = {}) {
    switch(action.type) {
        case actionTypes.initialPageLoad:
        case actionTypes.login:
            //because we get payload as immutablejs-map sometimes but not always
            var immutablePayload = Immutable.fromJS(action.payload);

            var loggedIn = immutablePayload.get('loggedIn');
            var email = immutablePayload.get('email');

            if(loggedIn){
                return Immutable.fromJS({loggedIn: true, email: email});
            } else {
                return userData;
            }

        case actionTypes.logout:
            return Immutable.fromJS({loggedIn: false});

        case actionTypes.loginFailed:
            return Immutable.fromJS({loginError: action.payload.loginError, loggedIn: false});

        case actionTypes.loginReset:
            if(!userData.get("loggedIn")){
                return Immutable.fromJS({loginError: undefined});
            } else {
                return userData
            }

        case actionTypes.registerReset:
            return Immutable.fromJS({registerError: undefined});

        case actionTypes.registerFailed:
            return Immutable.fromJS({registerError: action.payload.registerError});

        default:
            return userData;
    }
}
{'fraction_non_alphanumeric': 0.11135747721113574, 'fraction_numerical': 0.004434589800443459, 'mean_word_length': 2.4232715008431702, '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': '3438200', 'n_tokens_mistral': 1080, 'n_tokens_neox': 1043, 'n_words': 250}