Skip to content

Commit

Permalink
fix: toggle all read flag
Browse files Browse the repository at this point in the history
  • Loading branch information
giuliaghisini committed Nov 11, 2024
1 parent 93c9e4d commit f1d5832
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 20 deletions.
2 changes: 1 addition & 1 deletion src/actions/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ export function updateFeedback(parent_uid, item) {
export const UPDATE_FEEDBACK_LIST = 'UPDATE_FEEDBACK_LIST';
export function updateFeedbackList(feedbacks) {
return {
type: UPDATE_FEEDBACK,
type: UPDATE_FEEDBACK_LIST,
request: {
op: 'patch',
path: '/@feedback-list/',
Expand Down
10 changes: 9 additions & 1 deletion src/components/manage/VFPanel/FeedbackComments.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,10 @@ const FeedbackComments = ({ item, moment: Moment }) => {
return state.getFeedback?.subrequests?.[item?.uid];
});

const updateFeedbackListResult = useSelector((state) => {
return state.updateFeedbackList;
});

useEffect(() => {
if (feedbackCommentsResults?.loaded) {
setComments(feedbackCommentsResults.items);
Expand Down Expand Up @@ -196,8 +200,12 @@ const FeedbackComments = ({ item, moment: Moment }) => {
return acc;
}, {});
dispatch(updateFeedbackList(feedbacks));
loadCommentsData();
};
useEffect(() => {
if (!updateFeedbackListResult.loading && updateFeedbackListResult.loaded) {
loadCommentsData();
}
}, [updateFeedbackListResult.loaded]);

useEffect(() => {
loadCommentsData();
Expand Down
32 changes: 14 additions & 18 deletions src/reducers/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -461,7 +461,7 @@ export const updateFeedbackList = (state = initialState, action = {}) => {
...state.subrequests,
[action.subrequest]: {
...(state.subrequests[action.subrequest] || {
data: null,
result: null,
}),
loaded: false,
loading: true,
Expand All @@ -471,11 +471,9 @@ export const updateFeedbackList = (state = initialState, action = {}) => {
}
: {
...state,
result: {
loading: true,
loaded: false,
error: null,
},
loading: true,
loaded: false,
error: null,
};
case `${UPDATE_FEEDBACK_LIST}_SUCCESS`:
return action.subrequest
Expand All @@ -486,17 +484,17 @@ export const updateFeedbackList = (state = initialState, action = {}) => {
[action.subrequest]: {
loading: false,
loaded: true,
result: action.result,
error: null,
},
},
}
: {
...state,
result: {
loading: false,
loaded: true,
error: null,
},
loading: false,
loaded: true,
result: action.result,
error: null,
};
case `${UPDATE_FEEDBACK_LIST}_FAIL`:
return action.subrequest
Expand All @@ -505,21 +503,19 @@ export const updateFeedbackList = (state = initialState, action = {}) => {
subrequests: {
...state.subrequests,
[action.subrequest]: {
data: null,
loading: false,
loaded: false,
error: action.error,
result: null,
},
},
}
: {
...state,
data: null,
result: {
loading: false,
loaded: false,
error: action.error,
},
loading: false,
loaded: false,
error: action.error,
result: null,
};
default:
return state;
Expand Down

0 comments on commit f1d5832

Please sign in to comment.