diff --git a/app/soapbox/actions/__tests__/statuses-test.js b/app/soapbox/actions/__tests__/statuses-test.js index 972330f395..463b87437a 100644 Binary files a/app/soapbox/actions/__tests__/statuses-test.js and b/app/soapbox/actions/__tests__/statuses-test.js differ diff --git a/app/soapbox/actions/statuses.js b/app/soapbox/actions/statuses.js index 7363f979dc..bc580455a1 100644 Binary files a/app/soapbox/actions/statuses.js and b/app/soapbox/actions/statuses.js differ diff --git a/app/soapbox/reducers/__tests__/statuses-test.js b/app/soapbox/reducers/__tests__/statuses-test.js index 91c9603085..fb245062ab 100644 Binary files a/app/soapbox/reducers/__tests__/statuses-test.js and b/app/soapbox/reducers/__tests__/statuses-test.js differ diff --git a/app/soapbox/reducers/statuses.ts b/app/soapbox/reducers/statuses.ts index e35468b4f1..aac7dc975c 100644 --- a/app/soapbox/reducers/statuses.ts +++ b/app/soapbox/reducers/statuses.ts @@ -28,6 +28,8 @@ import { STATUS_UNMUTE_SUCCESS, STATUS_REVEAL, STATUS_HIDE, + STATUS_DELETE_REQUEST, + STATUS_DELETE_FAIL, } from '../actions/statuses'; import { TIMELINE_DELETE } from '../actions/timelines'; @@ -152,7 +154,7 @@ const deleteStatus = (state: State, id: string, references: Array) => { return state.delete(id); }; -const importPendingStatus = (state: State, { in_reply_to_id }: APIEntity) => { +const incrementReplyCount = (state: State, { in_reply_to_id }: APIEntity) => { if (in_reply_to_id) { return state.updateIn([in_reply_to_id, 'replies_count'], 0, count => { return typeof count === 'number' ? count + 1 : 0; @@ -162,7 +164,7 @@ const importPendingStatus = (state: State, { in_reply_to_id }: APIEntity) => { } }; -const deletePendingStatus = (state: State, { in_reply_to_id }: APIEntity) => { +const decrementReplyCount = (state: State, { in_reply_to_id }: APIEntity) => { if (in_reply_to_id) { return state.updateIn([in_reply_to_id, 'replies_count'], 0, count => { return typeof count === 'number' ? Math.max(0, count - 1) : 0; @@ -200,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 importPendingStatus(state, action.params); + return incrementReplyCount(state, action.params); case STATUS_CREATE_FAIL: - return deletePendingStatus(state, action.params); + return decrementReplyCount(state, action.params); case FAVOURITE_REQUEST: return simulateFavourite(state, action.status.id, true); case UNFAVOURITE_REQUEST: @@ -249,6 +251,10 @@ export default function statuses(state = initialState, action: AnyAction): State } }); }); + case STATUS_DELETE_REQUEST: + return decrementReplyCount(state, action.params); + case STATUS_DELETE_FAIL: + return incrementReplyCount(state, action.params); case TIMELINE_DELETE: return deleteStatus(state, action.id, action.references); default: