mirror of
https://github.com/usatiuk/ustk-todolist.git
synced 2025-10-28 15:47:48 +01:00
put backend sources into src setup circleci don't use react-loadable because it seems unnecessary
21 lines
737 B
JavaScript
21 lines
737 B
JavaScript
import { REQUEST_LISTS, INVALIDATE_LISTS } from "../actions/defs";
|
|
import { fetchLists } from "../actions/lists";
|
|
|
|
export default (store) => (next) => (action) => {
|
|
next(action);
|
|
if (action.type !== REQUEST_LISTS && typeof action !== "function") {
|
|
const state = store.getState();
|
|
if (state.user.user) {
|
|
const dirtyLists = state.lists.dirty || false;
|
|
const dirtyTodos = state.todos.dirty || false;
|
|
const fetchingLists = state.lists.fetching || false;
|
|
if (
|
|
((dirtyLists || dirtyTodos) && !fetchingLists) ||
|
|
action.type === INVALIDATE_LISTS
|
|
) {
|
|
store.dispatch(fetchLists());
|
|
}
|
|
}
|
|
}
|
|
};
|