Files
ustk-todolist/client/src/middleware/keepSynced.js
Stepan Usatiuk afd1f98254 update, lint, prettify everything
put backend sources into src
setup circleci
don't use react-loadable because it seems unnecessary
2021-03-13 19:58:06 +03:00

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());
}
}
}
};