forked from WorldBrain/Memex
-
Notifications
You must be signed in to change notification settings - Fork 0
/
store.js
87 lines (76 loc) · 2.68 KB
/
store.js
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
import { createStore, combineReducers, compose, applyMiddleware } from 'redux'
import { createEpicMiddleware, combineEpics } from 'redux-observable'
import thunk from 'redux-thunk'
import initSentry from '../util/raven'
import * as imports from './imports'
import * as blacklist from './blacklist'
import * as pdfs from './PDF'
import * as settings from './settings'
import * as overviewPage from '../overview'
import { reducer as onboarding } from '../overview/onboarding'
import { reducer as deleteConfModal } from '../overview/delete-confirm-modal'
import { reducer as results } from '../overview/results'
import { reducer as searchBar } from '../overview/search-bar'
import { reducer as tooltips } from '../overview/tooltips'
import { reducer as customLists } from 'src/custom-lists'
import { reducer as modals } from '../overview/modals/reducer'
// Search filters in the sidebar
import { reducer as searchFilters } from 'src/search-filters'
import { reducer as sidebarLeft } from 'src/overview/sidebar-left'
import { reducer as sidebar } from 'src/sidebar-overlay/sidebar'
import * as notifications from '../notifications'
import { authReducer } from '../authentication/redux'
const rootReducer = combineReducers({
auth: authReducer,
blacklist: blacklist.reducer,
imports: imports.reducer,
pdfs: pdfs.reducer,
settings: settings.reducer,
onboarding,
customLists,
searchFilters,
sidebarLeft,
sidebar,
notifications: notifications.reducer,
deleteConfModal,
modals,
searchBar,
tooltips,
results,
})
const rootEpic = combineEpics(...Object.values(overviewPage.epics))
/**
* Used to transform the redux state before sending to raven, filtering out
* anything we don't need to know.
*/
const stateTransformer = ({ overview, ...state }) => ({
...state,
overview: {
...overview,
searchResult: {
...overview.searchResult,
// Filter out personal stuff from results; not really useful for our knowledge
docs: overview.searchResult.docs.map(
({ url, title, favIcon, screenshot, ...doc }) => doc,
),
},
},
})
export default function configureStore({ ReduxDevTools = undefined } = {}) {
const middlewares = [createEpicMiddleware(rootEpic), thunk]
initSentry({ reduxMiddlewares: middlewares, stateTransformer })
const enhancers = [
overviewPage.enhancer,
imports.enhancer,
applyMiddleware(...middlewares),
]
if (ReduxDevTools) {
enhancers.push(ReduxDevTools.instrument())
}
const enhancer = compose(...enhancers)
return createStore(
rootReducer,
undefined, // Initial State
enhancer,
)
}