summaryrefslogtreecommitdiff
path: root/animism-align/frontend/app/views/audio/audio.reducer.js
blob: 09ce6cec8d84e5b67590d3be90914e50421a841e (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
import * as types from 'app/types'
import { session, getDefault, getDefaultInt } from 'app/session'

const initialState = {
  playing: false,
  play_ts: 0,
  muted: false,
}

export default function alignReducer(state = initialState, action) {
  // console.log(action.type, action)
  switch (action.type) {
    case types.audio.play:
      return {
        ...state,
        playing: true,
      }
    case types.audio.pause:
      return {
        ...state,
        playing: false,
      }
    case types.audio.update_time:
      return {
        ...state,
        play_ts: action.play_ts,
      }
    case types.audio.toggle_muted:
      return {
        ...state,
        muted: !state.muted,
      }
    default:
      return state
  }
}