<commit_before>import Firebase from 'firebase';
const ref = new Firebase('https://pandoras-wall.firebaseio.com/users');

const api = {
  'GET_USER': function (next, action) {
    if (action.response) {
      const user = ref.child(action.response.uid);
      return user.child('tasks').once('value').then(function(snapshot) {
        const newAction = {
          type: 'GET_USER',
          response: action.response,
          tasks: snapshot.val()
        };
        return next(newAction);
      });
    }
    return next(action);
  }
};

const firebaseMiddleware = store => next => {

  return function (action) {
    if (typeof api[action.type] === 'function') {
      return api[action.type](next, action);
    }
    return next(action);<commit_msg>set initial tasks state on firebase<commit_after>import Firebase from 'firebase';
const ref = new Firebase('https://pandoras-wall.firebaseio.com/users');

const api = {
  'GET_USER': function (next, action) {
    if (action.response) {
      const user = ref.child(action.response.uid);
      return user.child('tasks').once('value').then(function(snapshot) {
        const newAction = {
          type: 'GET_USER',
          response: action.response,
          tasks: snapshot.val()
        };
        if (!snapshot.val()) {
          user.child('tasks').set({
            toDo: [],
            inProgress: [],
            Done: []
          });
        }
        return next(newAction);
      });
    }
    return next(action);
  }
};

const firebaseMiddleware = store => next => {

  return function (action) {
    if (typeof api[action.type] === 'function') {
      return api[action.type](next, action);
    }
    return next(action);
{'fraction_non_alphanumeric': 0.1509433962264151, 'fraction_numerical': 0.0, 'mean_word_length': 2.470347648261759, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 2, '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': '7077503', 'n_tokens_mistral': 502, 'n_tokens_neox': 503, 'n_words': 108}