summaryrefslogtreecommitdiff
path: root/animism-align/frontend/views/align/align.reducer.js
blob: c0dcfacd53db70bc9ee3f97543c1eedab0b93d05 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import * as types from '../../types'
import { session, getDefault, getDefaultInt } from '../../session'

import { crudState, crudReducer } from '../../api/crud.reducer'

const initialState = {
  timeline: {
    start_ts: 0,
    zoom: 0,
    duration: 0,
  },
  options: {
  }
}

export default function alignReducer(state = initialState, action) {
  // console.log(action.type, action)
  switch (action.type) {
    case types.peaks.loaded:
      return {
        ...state,
        timeline: {
          ...state.timeline,
          duration: action.data.length / 2,
        }
      }

    case types.align.set_display_setting:
      return {
        ...state,
        timeline: {
          ...state.timeline,
          [action.key]: action.value,
        }
      }

    default:
      return state
  }
}