Skip to content

Commit 8b5f153

Browse files
committed
fire fetchData with load action on autoRefresh saga: fixes reloading with incorrect props
1 parent 2e9ca26 commit 8b5f153

File tree

1 file changed

+14
-9
lines changed

1 file changed

+14
-9
lines changed

src/sagas.js

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -38,22 +38,27 @@ export function* fetchData(action) {
3838
}
3939

4040
export function* autoRefresh(action) {
41-
while (true) {
42-
if (action.payload.loadImmediately) {
43-
yield call(fetchData, action);
44-
}
41+
if (action.payload.loadImmediately) {
42+
yield call(fetchData, action);
43+
}
4544

45+
while (true) {
4646
const loaderState = yield select(getLoaderState);
4747
const interval = action.payload.newAutoRefreshInterval
4848
? action.payload.newAutoRefreshInterval
4949
: loaderState[action.meta.loader].config.autoRefreshInterval;
5050

51-
yield race([
52-
call(delay, interval),
53-
take(act => act.type === LOAD && act.meta.loader === action.meta.loader),
54-
]);
51+
const {
52+
delayed,
53+
loadAction,
54+
} = yield race({
55+
delayed: call(delay, interval),
56+
loadAction: take(act => act.type === LOAD && act.meta.loader === action.meta.loader),
57+
});
5558

56-
if (!action.payload.loadImmediately) {
59+
if (loadAction) {
60+
yield call(fetchData, loadAction);
61+
} else if (delayed) {
5762
yield call(fetchData, action);
5863
}
5964
}

0 commit comments

Comments
 (0)