summaryrefslogtreecommitdiff
path: root/animism-align/frontend/app/store.js
blob: 3f30abdea56ca2323e004b5c57f36c4ccd27554e (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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
import { applyMiddleware, compose, combineReducers, createStore } from 'redux'
import { connectRouter, routerMiddleware } from 'connected-react-router'
import { createBrowserHistory } from 'history'
// import createDebounce from 'redux-debounced'
import thunk from 'redux-thunk'

// cms
import uploadReducer from 'app/views/upload/upload.reducer'
import annotationReducer from 'app/views/annotation/annotation.reducer'
import siteReducer from 'app/views/site/site.reducer'
import mediaReducer from 'app/views/media/media.reducer'
import episodeReducer from 'app/views/episode/episode.reducer'
import venueReducer from 'app/views/venue/venue.reducer'
import authReducer from 'app/views/auth/auth.reducer'
import userReducer from 'app/views/user/user.reducer'

// editor
import alignReducer from 'app/views/align/align.reducer'
import paragraphReducer from 'app/views/paragraph/paragraph.reducer'

// viewer
import audioReducer from 'app/views/audio/audio.reducer'
import viewerReducer from 'app/views/viewer/viewer.reducer'

const createRootReducer = history => (
  combineReducers({
    router: connectRouter(history),
    site: siteReducer,

    upload: uploadReducer,
    annotation: annotationReducer,
    media: mediaReducer,
    episode: episodeReducer,
    venue: venueReducer,
    user: userReducer,
    auth: authReducer,

    align: alignReducer,
    paragraph: paragraphReducer,

    audio: audioReducer,
    viewer: viewerReducer,
  })
)

const configureStore = (initialState = {}, history) => {
  const composeEnhancers = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose

  const store = createStore(
    createRootReducer(history),
    initialState,
    composeEnhancers(
      applyMiddleware(
        thunk,
        // createDebounce(),
        routerMiddleware(history)
      ),
    ),
  )

  return store
}

const history = createBrowserHistory()
const store = configureStore({}, history)
const { dispatch } = store

export { store, history, dispatch }