summaryrefslogtreecommitdiff
path: root/app/client/modules/pix2pixhd/pix2pixhd.reducer.js
blob: c3d52a39f62d41771dde17cd9bd33aa39788850a (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 pix2pixhdInitialState = {
  loading: true,
  progress: { i: 0, n: 0 },
  error: null,
  folder_id: 0,
  data: null,
  results: null,
}

const pix2pixhdReducer = (state = pix2pixhdInitialState, action) => {
  if (action.data && action.data.module === 'pix2pixhd') {
    state = datasetReducer(state, action)
  }

  switch (action.type) {
    case types.pix2pixhd.load_results:
      return {
        ...state,
        results: action.results,
      }
    case types.file.destroy:
      console.log('file destroy', state.results)
      return {
        ...state,
        results: {
          ...state.results,
          files: state.results.files.filter(f => f.id !== action.data.id)
        }
      }
    default:
      return state
  }
}

export default pix2pixhdReducer