summaryrefslogtreecommitdiff
path: root/app/client/modules/samplernn/samplernn.reducer.js
blob: 4758f61e469dfcf4d290e76ae41ffcc60c78a6ad (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
import types from '../../types'

import datasetReducer from '../../dataset/dataset.reducer'

const samplernnInitialState = {
  loading: true,
  progress: { i: 0, n: 0 },
  error: null,
  folders: [],
  folder_id: 0,
  data: null,
  lossReport: null,
  results: null,
}

const samplernnReducer = (state = samplernnInitialState, action) => {
  if (action.data && action.data.module === 'samplernn') {
    return datasetReducer(state, action)
  }

  switch(action.type) {
    case types.samplernn.load_loss:
      return {
        ...state,
        lossReport: action.lossReport,
      }
    case types.samplernn.load_graph:
      return {
        ...state,
        lossReport: action.lossReport,
        results: action.results,
      }
    default:
      return state
  }
}

export default samplernnReducer