<commit_before>import { ActionTypes } from '../config/constants';
import { ref } from '../config/constants';

export const addItem = payload => {
	return {
		type: ActionTypes.BUDGETS_ADD_ITEM,
		payload,
	}
}

export const removeItem = payload => {
	return {
		type: ActionTypes.BUDGETS_REMOVE_ITEM,
		payload,
	}
}

export const subscribe = payload => {
	return dispatch => {

		dispatch({
			type: ActionTypes.BUDGETS_SUBSCRIBE,	
		})
		
    const itemsRef = ref.child(`items`);
    itemsRef.on('value', snapshot => {
      const itemList = snapshot.val();

      dispatch({
        type: ActionTypes.BUDGETS_UPDATE,
        payload: { 
          itemList: itemList,
        }
      });
    });   
	}
}

export const search = payload => {
	return {
		type: ActionTypes.BUDGETS_SEARCH,
		payload,
	}
}

export const toggleColumn = payload => {
	return {
		type: ActionTypes.BUDGETS_TOGGLE_COL,
		payload,
	}
}

export const updateItem = payload => {
	return {
		type: ActionTypes.BUDGETS_UPDATE_ITEM,
		payload,
	}
}<commit_msg>Update items in Firebase on change<commit_after>import { ActionTypes } from '../config/constants';
import { ref } from '../config/constants';

export const addItem = payload => {
	return dispatch => {
		const itemRef =	ref.child(`items/${payload.item.id}`);

		itemRef.set( payload.item );

		dispatch({
			type: ActionTypes.BUDGETS_ADD_ITEM,
			payload,
		});
	}
}

export const removeItem = payload => {
	return dispatch => {
		const itemRef =	ref.child(`items/${payload.itemId}`);

		itemRef.remove();

		dispatch({
			type: ActionTypes.BUDGETS_REMOVE_ITEM,
			payload,
		});
	}
}

export const subscribe = payload => {
	return dispatch => {

		dispatch({
			type: ActionTypes.BUDGETS_SUBSCRIBE,	
		})
		
    const itemsRef = ref.child(`items`);
    itemsRef.on('value', snapshot => {
      const itemList = snapshot.val();

      dispatch({
        type: ActionTypes.BUDGETS_UPDATE,
        payload: { 
          itemList: itemList,
        }
      });
    });   
	}
}

export const search = payload => {
	return {
		type: ActionTypes.BUDGETS_SEARCH,
		payload,
	}
}

export const toggleColumn = payload => {
	return {
		type: ActionTypes.BUDGETS_TOGGLE_COL,
		payload,
	}
}

export const updateItem = payload => {
	return dispatch => {
		const itemRef =	ref.child(`items/${payload.updatedItem.id}`);		

		itemRef.update(payload.updatedItem);

		dispatch({
			type: ActionTypes.BUDGETS_UPDATE_ITEM,
			payload,	
		})
	}
}
{'fraction_non_alphanumeric': 0.13360488798370673, 'fraction_numerical': 0.0, 'mean_word_length': 3.066225165562914, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 22, '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': '318411', 'n_tokens_mistral': 887, 'n_tokens_neox': 832, 'n_words': 166}