sforkowany z mirror/soapbox
Merge branch 'editing-replies-count' into 'develop'
Don't increase replies count when editing a post See merge request soapbox-pub/soapbox-fe!1707react-query-api
commit
a8577fe0ee
|
@ -49,7 +49,7 @@ const statusExists = (getState: () => RootState, statusId: string) => {
|
|||
|
||||
const createStatus = (params: Record<string, any>, idempotencyKey: string, statusId: string | null) => {
|
||||
return (dispatch: AppDispatch, getState: () => RootState) => {
|
||||
dispatch({ type: STATUS_CREATE_REQUEST, params, idempotencyKey });
|
||||
dispatch({ type: STATUS_CREATE_REQUEST, params, idempotencyKey, editing: !!statusId });
|
||||
|
||||
return api(getState).request({
|
||||
url: statusId === null ? '/api/v1/statuses' : `/api/v1/statuses/${statusId}`,
|
||||
|
@ -84,7 +84,7 @@ const createStatus = (params: Record<string, any>, idempotencyKey: string, statu
|
|||
|
||||
return status;
|
||||
}).catch(error => {
|
||||
dispatch({ type: STATUS_CREATE_FAIL, error, params, idempotencyKey });
|
||||
dispatch({ type: STATUS_CREATE_FAIL, error, params, idempotencyKey, editing: !!statusId });
|
||||
throw error;
|
||||
});
|
||||
};
|
||||
|
|
|
@ -202,9 +202,9 @@ export default function statuses(state = initialState, action: AnyAction): State
|
|||
case STATUSES_IMPORT:
|
||||
return importStatuses(state, action.statuses, action.expandSpoilers);
|
||||
case STATUS_CREATE_REQUEST:
|
||||
return incrementReplyCount(state, action.params);
|
||||
return action.editing ? state : incrementReplyCount(state, action.params);
|
||||
case STATUS_CREATE_FAIL:
|
||||
return decrementReplyCount(state, action.params);
|
||||
return action.editing ? state : decrementReplyCount(state, action.params);
|
||||
case FAVOURITE_REQUEST:
|
||||
return simulateFavourite(state, action.status.id, true);
|
||||
case UNFAVOURITE_REQUEST:
|
||||
|
|
Ładowanie…
Reference in New Issue