web/js/store/log_reducer.js
/**
 * Adds current active timer to log as a lap.
 */
Adds current active timer to log as a lap.
Adds current active timer to log as a lap .
function addCurrent (state )  {
  let timer  = state.timer
  if (!timer.active) return state
  const id  = uuid.v4()
  const now  = state.time && state.time.now
  const duration  = timer.duration || Settings.DEFAULTS['duration:work']
  const startedAt  = timer.lastLap || timer.startedAt || now
  const endedAt  = timer.endsAt || now
  if (endedAt > now) {
    debug('Lapping before we\'re due. Not supposed to happen!')
    debug('... endsAt', endedAt)
    debug('... now', now)
    return state
  }
  timer = {
    ...timer,
    'lastLap': endedAt,
    'lastLogId': id
  }
  let log  = {
    id,
    startedAt,
    'endedAt': endedAt,
    'duration': duration,
    'timerType': timer.type || 'work',
    'labelId': timer.labelId || Settings.DEFAULT_LABEL_ID,
    'isComplete': true
  }
  let logs  = { ...(state.log || {}), [id]: log }
  return { ...state, timer, log: logs }
}
function addCurrent ( state ) { let timer = state . timer if ( ! timer . active ) return state const id = uuid . v4 ( ) const now = state . time && state . time . now const duration = timer . duration || Settings . DEFAULTS [ 'duration:work' ] const startedAt = timer . lastLap || timer . startedAt || now const endedAt = timer . endsAt || now if ( endedAt > now ) { debug ( 'Lapping before we\'re due. Not supposed to happen!' ) debug ( '... endsAt' , endedAt ) debug ( '... now' , now ) return state } timer = { ... timer , 'lastLap' : endedAt , 'lastLogId' : id } let log = { id , startedAt , 'endedAt' : endedAt , 'duration' : duration , 'timerType' : timer . type || 'work' , 'labelId' : timer . labelId || Settings . DEFAULT_LABEL_ID , 'isComplete' : true } let logs = { ... ( state . log || { } ) , [ id ] : log } return { ... state , timer , log : logs } }
Adds current active timer to log as a lap.
Adds current active timer to log as a lap .
/*: State */ /*: State */ /*: Timer */ /*: string */ /*: Date */ /*: number */ /*: Date */ /*: Date */ // If we're not scheduled ta addCurrent(), don't bother /*: Log */ /*: Logs */