diff --git a/src/actions/index.js b/src/actions/index.js index 4afaa25..ad790bc 100644 --- a/src/actions/index.js +++ b/src/actions/index.js @@ -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/', diff --git a/src/components/manage/VFPanel/FeedbackComments.jsx b/src/components/manage/VFPanel/FeedbackComments.jsx index 1b14ac2..a189c2f 100644 --- a/src/components/manage/VFPanel/FeedbackComments.jsx +++ b/src/components/manage/VFPanel/FeedbackComments.jsx @@ -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); @@ -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(); diff --git a/src/reducers/index.js b/src/reducers/index.js index 20142d3..8c85865 100644 --- a/src/reducers/index.js +++ b/src/reducers/index.js @@ -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, @@ -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 @@ -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 @@ -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;