shouldRefectchData delete

This commit is contained in:
Virginie Ky 2020-01-13 10:17:10 +01:00
parent beda677349
commit f70d2da3f8
2 changed files with 5 additions and 11 deletions

View File

@ -37,7 +37,6 @@ function EditView() {
initialWebhook, initialWebhook,
isTriggering, isTriggering,
triggerResponse, triggerResponse,
shouldRefetchData,
} = reducerState.toJS(); } = reducerState.toJS();
const { name } = modifiedWebhook; const { name } = modifiedWebhook;
@ -50,10 +49,10 @@ function EditView() {
const { signal } = abortController; const { signal } = abortController;
useEffect(() => { useEffect(() => {
if (!isCreating || (!isCreating && shouldRefetchData)) { if (!isCreating) {
fetchData(); fetchData();
} }
}, [fetchData, isCreating, shouldRefetchData]); }, [fetchData, isCreating]);
const fetchData = useCallback(async () => { const fetchData = useCallback(async () => {
try { try {
@ -298,9 +297,8 @@ function EditView() {
body, body,
}); });
dispatch({ fetchData();
type: 'SUBMIT_SUCCEEDED',
});
strapi.notification.error('notification.form.success.fields'); strapi.notification.error('notification.form.success.fields');
} catch (err) { } catch (err) {
strapi.notification.error('notification.error'); strapi.notification.error('notification.error');

View File

@ -12,7 +12,6 @@ const initialState = fromJS({
formErrors: {}, formErrors: {},
initialWebhook: initialWebhook, initialWebhook: initialWebhook,
modifiedWebhook: initialWebhook, modifiedWebhook: initialWebhook,
shouldRefetchData: false,
triggerResponse: {}, triggerResponse: {},
isTriggering: false, isTriggering: false,
}); });
@ -36,8 +35,7 @@ const reducer = (state, action) => {
return state return state
.update('initialWebhook', () => fromJS(data)) .update('initialWebhook', () => fromJS(data))
.update('modifiedWebhook', () => fromJS(data)) .update('modifiedWebhook', () => fromJS(data));
.update('shouldRefetchData', () => false);
} }
case 'TRIGGER_SUCCEEDED': case 'TRIGGER_SUCCEEDED':
return state return state
@ -76,8 +74,6 @@ const reducer = (state, action) => {
); );
case 'SET_ERRORS': case 'SET_ERRORS':
return state.update('formErrors', () => fromJS(action.errors)); return state.update('formErrors', () => fromJS(action.errors));
case 'SUBMIT_SUCCEEDED':
return state.update('shouldRefetchData', () => true);
default: default:
return state; return state;
} }