From d9f15fb6ed6fdac1e7779e101549687053338a9b Mon Sep 17 00:00:00 2001 From: ThibG Date: Fri, 29 Nov 2019 17:02:18 +0100 Subject: [PATCH] [Glitch] Fix pending upload count not being decremented on error Port 9b3ebf91662015070db0ee6cdcb5f06a66f5a1f7 to glitch-soc Signed-off-by: Thibaut Girka --- app/javascript/flavours/glitch/actions/compose.js | 5 ++--- app/javascript/flavours/glitch/reducers/compose.js | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/app/javascript/flavours/glitch/actions/compose.js b/app/javascript/flavours/glitch/actions/compose.js index 7182ed0fad..f80642bd83 100644 --- a/app/javascript/flavours/glitch/actions/compose.js +++ b/app/javascript/flavours/glitch/actions/compose.js @@ -263,7 +263,7 @@ export function uploadCompose(files) { dispatch(uploadComposeProgress(progress.reduce((a, v) => a + v, 0), total)); }, }).then(({ data }) => dispatch(uploadComposeSuccess(data, f))); - }).catch(error => dispatch(uploadComposeFail(error, true))); + }).catch(error => dispatch(uploadComposeFail(error))); }; }; }; @@ -294,11 +294,10 @@ export function changeUploadComposeSuccess(media) { }; }; -export function changeUploadComposeFail(error, decrement = false) { +export function changeUploadComposeFail(error) { return { type: COMPOSE_UPLOAD_CHANGE_FAIL, error: error, - decrement: decrement, skipLoading: true, }; }; diff --git a/app/javascript/flavours/glitch/reducers/compose.js b/app/javascript/flavours/glitch/reducers/compose.js index ac826de2b2..0f807790bd 100644 --- a/app/javascript/flavours/glitch/reducers/compose.js +++ b/app/javascript/flavours/glitch/reducers/compose.js @@ -429,7 +429,7 @@ export default function compose(state = initialState, action) { case COMPOSE_UPLOAD_SUCCESS: return appendMedia(state, fromJS(action.media), action.file); case COMPOSE_UPLOAD_FAIL: - return state.set('is_uploading', false).update('pending_media_attachments', n => action.decrement ? n - 1 : n); + return state.set('is_uploading', false).update('pending_media_attachments', n => n - 1); case COMPOSE_UPLOAD_UNDO: return removeMedia(state, action.media_id); case COMPOSE_UPLOAD_PROGRESS: