
import {
SHOW_POMODARIO,
HIDE_POMODARIO,
TOGLE_POMODARIO,
CHANGE_REF_KEY
} from "./action-types"



//const pomodarioRef = new Firebase(C.FIREBASE).child('pomodarios'); 
const pomodarioActions = {

  setPomodarioDone(qid, article){
    return (dispatch, getState) => {
      const {pomodario, firebase } = getState();
      var pomodarioRef = firebase.pomodario.child("pomodarios")
      console.log("pomodarioRef: ", qid)
      if (pomodario.refkey != null){
        console.log("push to server: ", qid)
        pomodarioRef.push({qid, date: (new Date()).getTime()})
      }
    }
  },

  toglePomodarioOff(qid, article){
    return (dispatch) => {
      //pomodarioRef.push({article})
      dispatch({type: HIDE_POMODARIO})
    }
  },

  changePomodarioKey(qid){
    return (dispatch) => {
      dispatch({type: CHANGE_REF_KEY, data: qid})
    }
  },

  toglePomodario(qid, article){
    return (dispatch) => {
      //pomodarioRef.push({article})
      dispatch({type: TOGLE_POMODARIO})
      dispatch({type: CHANGE_REF_KEY, data: qid})
    }
  },


}

export default pomodarioActions;

@@ -295,16 +295,26 @@
 firebase
+, articles
  %7D = get
@@ -569,16 +569,46 @@
 etTime()
+, type:articles.data%5Bqid%5D.type
 %7D)%0A     
@@ -932,32 +932,42 @@
 return (dispatch
+, getState
 ) =%3E %7B%0A      //p

add pomodario type