don't load forwards if the array already exists in state

master
Tudor Stanciu 2020-05-14 14:37:39 +03:00
parent c5e2a03a93
commit 3a7613e9ff
1 changed files with 4 additions and 1 deletions

View File

@ -15,8 +15,11 @@ export function loadServerSessions() {
} }
export function loadSessionForwards(sessionId) { export function loadSessionForwards(sessionId) {
return async function (dispatch) { return async function (dispatch, getState) {
try { try {
const forwards = getState().forwards[sessionId];
if (forwards && (forwards.loading || forwards.loaded)) return;
dispatch({ type: types.LOAD_SESSION_FORWARDS_STARTED, id: sessionId }); dispatch({ type: types.LOAD_SESSION_FORWARDS_STARTED, id: sessionId });
const data = await dispatch( const data = await dispatch(
sendHttpRequest(api.getSessionForwards(sessionId)) sendHttpRequest(api.getSessionForwards(sessionId))