Revert "Save perPage selection in localstorage"
This reverts commit 9490374faa.
This commit is contained in:
@@ -1,11 +1,10 @@
|
|||||||
import { applyMiddleware, combineReducers, compose, createStore } from 'redux'
|
import { applyMiddleware, combineReducers, compose, createStore } from 'redux'
|
||||||
import { connectRouter, routerMiddleware } from 'connected-react-router'
|
import { routerMiddleware, connectRouter } from 'connected-react-router'
|
||||||
import createSagaMiddleware from 'redux-saga'
|
import createSagaMiddleware from 'redux-saga'
|
||||||
import { all, fork } from 'redux-saga/effects'
|
import { all, fork } from 'redux-saga/effects'
|
||||||
import { adminReducer, adminSaga, USER_LOGOUT } from 'react-admin'
|
import { adminReducer, adminSaga, USER_LOGOUT } from 'react-admin'
|
||||||
import throttle from 'lodash.throttle'
|
import throttle from 'lodash.throttle'
|
||||||
import { loadState, saveState } from './persistState'
|
import { loadState, saveState } from './persistState'
|
||||||
import { pruneResources } from './pruneResources'
|
|
||||||
|
|
||||||
export default ({
|
export default ({
|
||||||
authProvider,
|
authProvider,
|
||||||
@@ -51,9 +50,6 @@ export default ({
|
|||||||
throttle(() => {
|
throttle(() => {
|
||||||
const state = store.getState()
|
const state = store.getState()
|
||||||
saveState({
|
saveState({
|
||||||
admin: {
|
|
||||||
resources: pruneResources(state),
|
|
||||||
},
|
|
||||||
theme: state.theme,
|
theme: state.theme,
|
||||||
queue: state.queue,
|
queue: state.queue,
|
||||||
albumView: state.albumView,
|
albumView: state.albumView,
|
||||||
|
|||||||
@@ -1,39 +0,0 @@
|
|||||||
function getParts(object, fragments) {
|
|
||||||
if (!object) {
|
|
||||||
return object
|
|
||||||
}
|
|
||||||
const [part, ...rest] = fragments.split('.')
|
|
||||||
|
|
||||||
return Object.assign(
|
|
||||||
{},
|
|
||||||
...Object.entries(object)
|
|
||||||
.filter(([key]) => key.toLowerCase().includes(part))
|
|
||||||
.map(([k, v]) => {
|
|
||||||
if (!rest.length) return { [k]: v }
|
|
||||||
const parts = v && typeof v === 'object' && getParts(v, rest.join('.'))
|
|
||||||
if (parts) return { [k]: parts }
|
|
||||||
return undefined
|
|
||||||
})
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
const pruneResource = (resource) => ({
|
|
||||||
props: {},
|
|
||||||
list: {
|
|
||||||
param: {
|
|
||||||
perPage: getParts(resource.list.param, 'perPage'),
|
|
||||||
filter: {},
|
|
||||||
},
|
|
||||||
selectedIds: [],
|
|
||||||
},
|
|
||||||
})
|
|
||||||
|
|
||||||
export const pruneResources = (state) => {
|
|
||||||
return Object.keys(state.admin.resources).reduce(
|
|
||||||
(acc, cur) => ({
|
|
||||||
...acc,
|
|
||||||
[cur]: pruneResource(state.admin.resources[cur]),
|
|
||||||
}),
|
|
||||||
{}
|
|
||||||
)
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user