summaryrefslogtreecommitdiff
path: root/app/client/browser/browser.reducer.js
blob: 099176f4ca70e4588cd1346f66ccc50df4513530 (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 types from '../types'

import moment from 'moment/min/moment.min'
let FileSaver = require('file-saver')

const browserInitialState = {
  loading: false,
  progress: null,
  error: null,
  data: {},
  images: [
  ],
  files: [
  ]
}

const browserReducer = (state = browserInitialState, action) => {
  switch(action.type) {
    case types.app.load_progress:
      if (!action.data || action.data.module !== 'browser') {
        return state
      }
      return {
        ...state,
        loading: true,
        progress: action.progress,
      }
    case types.app.load:
      return {
        ...state,
        loading: false,
        error: null,
        data: action.data,
      }
    default:
      return state
  }
}

export default browserReducer