From ef8cad95f987dfe4b15e97a9c890dd2653b8b8b8 Mon Sep 17 00:00:00 2001 From: Paul Bui-Quang Date: Mon, 20 Jun 2022 13:49:38 +0200 Subject: [PATCH] Fix disappearing favorites by removing favorites update on studies fetch Signed-off-by: Paul Bui-Quang --- webapp/src/redux/ducks/studies.ts | 12 ------------ webapp/src/redux/ducks/studyDataSynthesis.ts | 8 +++++++- 2 files changed, 7 insertions(+), 13 deletions(-) diff --git a/webapp/src/redux/ducks/studies.ts b/webapp/src/redux/ducks/studies.ts index 776f76e312..24e2a71318 100644 --- a/webapp/src/redux/ducks/studies.ts +++ b/webapp/src/redux/ducks/studies.ts @@ -211,18 +211,6 @@ export const fetchStudies = createAsyncThunk< >(n("FETCH_STUDIES"), async (_, { dispatch, getState, rejectWithValue }) => { try { const studies = await api.getStudies(); - const state = getState(); - const currentFavorites = getFavoriteStudyIds(state); - const newFavorites = R.innerJoin( - (fav, study) => fav === study.id, - currentFavorites, - studies - ); - - if (currentFavorites.length !== newFavorites.length) { - dispatch(setFavoriteStudies(newFavorites)); - } - dispatch(fetchStudyVersions()); return studies; diff --git a/webapp/src/redux/ducks/studyDataSynthesis.ts b/webapp/src/redux/ducks/studyDataSynthesis.ts index 52144c5147..7b49739189 100644 --- a/webapp/src/redux/ducks/studyDataSynthesis.ts +++ b/webapp/src/redux/ducks/studyDataSynthesis.ts @@ -61,13 +61,19 @@ export const createStudyData = createAsyncThunk< // Set current area const areas = Object.keys(studyData.areas); - if (areas.length > 0) dispatch(setCurrentArea(areas[0])); + if (areas.length > 0) { + dispatch(setCurrentArea(areas[0])); + } else { + dispatch(setCurrentArea("")); + } // Set current link const links = selectLinks(studyData); const linkList = links ? Object.values(links) : []; if (linkList.length > 0) { dispatch(setCurrentLink(linkList[0].name)); + } else { + dispatch(setCurrentLink("")); } return studyData;