<commit_before>// @flow
import type { ChooMiddleware } from "./app";
export type User = {
    id: string | null,
    name?: string,
    email?: string,
    groups?: string[],
    webPushInfo?: {
        endpoint: string,
        key: string,
        auth: string
    }
}

const extend = require('xtend');

const USER_LOGIN = "user:login";
const USER_UPDATED = "user:updated";

const userReducer: ChooMiddleware = (state, emitter) => {
    state.user = ({
        id: null
    }: User);

    state.events.USER_LOGIN = USER_LOGIN;
    state.events.USER_UPDATED = USER_UPDATED;

    emitter.on(state.events.USER_LOGIN, id => {
        state.user.id = id;
        emitter.emit(state.events.WORKER_REGISTER);
    });

    emitter.on(state.events.USER_UPDATED, user => {
        console.log({user});
        state.user = extend(state.user, user);
        emitter.emit(state.events.RENDER);
    });
};

module.exports = userReducer;
<commit_msg>minor lint<commit_after>// @flow
import type { ChooMiddleware } from "./app";
export type User = {
    id: string | null,
    name?: string,
    email?: string,
    groups?: string[],
    webPushInfo?: {
        endpoint: string,
        key: string,
        auth: string
    }
}

const extend = require('xtend');

const USER_LOGIN = "user:login";
const USER_UPDATED = "user:updated";

const userReducer: ChooMiddleware = (state, emitter) => {
    state.user = ({
        id: null
    }: User);

    state.events.USER_LOGIN = USER_LOGIN;
    state.events.USER_UPDATED = USER_UPDATED;

    emitter.on(state.events.USER_LOGIN, id => {
        state.user.id = id;
        emitter.emit(state.events.WORKER_REGISTER);
    });

    emitter.on(state.events.USER_UPDATED, user => {
        state.user = extend(state.user, user);
        emitter.emit(state.events.RENDER);
    });
};

module.exports = userReducer;

{'fraction_non_alphanumeric': 0.1442516268980477, 'fraction_numerical': 0.0, 'mean_word_length': 2.7048192771084336, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, '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': '3651737', 'n_tokens_mistral': 640, 'n_tokens_neox': 622, 'n_words': 124}