Skip to content

Commit

Permalink
Fix disappearing favorites by removing favorites update on studies fetch
Browse files Browse the repository at this point in the history
Signed-off-by: Paul Bui-Quang <[email protected]>
  • Loading branch information
pl-buiquang committed Jun 20, 2022
1 parent e56a4b4 commit ef8cad9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 13 deletions.
12 changes: 0 additions & 12 deletions webapp/src/redux/ducks/studies.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
8 changes: 7 additions & 1 deletion webapp/src/redux/ducks/studyDataSynthesis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit ef8cad9

Please sign in to comment.