|
|
@ -61,6 +61,7 @@ const initialState = ImmutableMap({ |
|
|
|
is_uploading: false, |
|
|
|
progress: 0, |
|
|
|
media_attachments: ImmutableList(), |
|
|
|
pending_media_attachments: 0, |
|
|
|
poll: null, |
|
|
|
suggestion_token: null, |
|
|
|
suggestions: ImmutableList(), |
|
|
@ -114,6 +115,7 @@ function appendMedia(state, media, file) { |
|
|
|
map.set('is_uploading', false); |
|
|
|
map.set('resetFileKey', Math.floor((Math.random() * 0x10000))); |
|
|
|
map.set('idempotencyKey', uuid()); |
|
|
|
map.update('pending_media_attachments', n => n - 1); |
|
|
|
|
|
|
|
if (prevSize === 0 && (state.get('default_sensitive') || state.get('spoiler'))) { |
|
|
|
map.set('sensitive', true); |
|
|
@ -322,11 +324,11 @@ export default function compose(state = initialState, action) { |
|
|
|
case COMPOSE_UPLOAD_CHANGE_FAIL: |
|
|
|
return state.set('is_changing_upload', false); |
|
|
|
case COMPOSE_UPLOAD_REQUEST: |
|
|
|
return state.set('is_uploading', true); |
|
|
|
return state.set('is_uploading', true).update('pending_media_attachments', n => n + 1); |
|
|
|
case COMPOSE_UPLOAD_SUCCESS: |
|
|
|
return appendMedia(state, fromJS(action.media), action.file); |
|
|
|
case COMPOSE_UPLOAD_FAIL: |
|
|
|
return state.set('is_uploading', false); |
|
|
|
return state.set('is_uploading', false).update('pending_media_attachments', n => action.decrement ? n - 1 : n); |
|
|
|
case COMPOSE_UPLOAD_UNDO: |
|
|
|
return removeMedia(state, action.media_id); |
|
|
|
case COMPOSE_UPLOAD_PROGRESS: |
|
|
|