From 5e857d5fc83307fa22fad6490c189b379c3964ce Mon Sep 17 00:00:00 2001 From: binh-dam-ibigroup <56846598+binh-dam-ibigroup@users.noreply.github.com> Date: Fri, 1 Apr 2022 16:36:40 -0400 Subject: [PATCH] fix(actions/versions): Fix clearing compared feed version. --- lib/manager/actions/versions.js | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/lib/manager/actions/versions.js b/lib/manager/actions/versions.js index 200593cc2..950c3cd16 100644 --- a/lib/manager/actions/versions.js +++ b/lib/manager/actions/versions.js @@ -580,14 +580,17 @@ export function ensureVersionIndexIsFetched ( feed: Feed, oneBasedIndex: number ) { - return function (dispatch: dispatchFn, getState: getStateFn) { - const requestedVersion = feed.feedVersions && feed.feedVersions[oneBasedIndex - 1] + return async function (dispatch: dispatchFn, getState: getStateFn) { console.log('Requesting version ', oneBasedIndex) + if (!oneBasedIndex || oneBasedIndex < 1) return null + + const requestedVersion = feed.feedVersions && feed.feedVersions[oneBasedIndex - 1] if (!requestedVersion) { if (feed.feedVersionSummaries) { // If the requested version has not been fetched yet, async fetch it. const versionId = feed.feedVersionSummaries[oneBasedIndex - 1].id - return dispatch(fetchFeedVersion(versionId)) + const { payload } = await dispatch(fetchFeedVersion(versionId)) + return payload } } return requestedVersion @@ -602,7 +605,7 @@ export function setVersionIndex ( ) { return async function (dispatch: dispatchFn, getState: getStateFn) { if (feed.feedVersionSummaries) { - const { payload: newActiveVersion } = await dispatch(ensureVersionIndexIsFetched(feed, oneBasedIndex)) + const newActiveVersion = await dispatch(ensureVersionIndexIsFetched(feed, oneBasedIndex)) dispatch(setActiveVersion(newActiveVersion)) if (push) { browserHistory.push(`${isPublic ? '/public' : ''}/feed/${feed.id}/version/${oneBasedIndex}`) @@ -623,7 +626,7 @@ export function setComparedVersion ( oneBasedIndex: number ) { return async function (dispatch: dispatchFn, getState: getStateFn) { - const { payload: newComparedVersion } = await dispatch(ensureVersionIndexIsFetched(feed, oneBasedIndex)) + const newComparedVersion = await dispatch(ensureVersionIndexIsFetched(feed, oneBasedIndex)) // Dispatch action to set value in reducer. dispatch(settingComparedVersion(newComparedVersion)) if (newComparedVersion) {