Don't increase replies count when editing a post

Signed-off-by: marcin mikołajczak <git@mkljczk.pl>
This commit is contained in:
marcin mikołajczak 2022-08-06 14:39:05 +02:00
parent 2bc8cdc1bd
commit 74735eeedd
2 changed files with 4 additions and 4 deletions

View file

@ -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;
});
};

View file

@ -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: