Add ability to reorder uploaded media before posting in web UI (#28456)

This commit is contained in:
Eugen Rochko 2024-03-25 11:29:55 +01:00 committed by GitHub
parent 6c381f20b1
commit 8e7e86ee35
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
10 changed files with 159 additions and 171 deletions

View file

@ -45,6 +45,7 @@ import {
INIT_MEDIA_EDIT_MODAL,
COMPOSE_CHANGE_MEDIA_DESCRIPTION,
COMPOSE_CHANGE_MEDIA_FOCUS,
COMPOSE_CHANGE_MEDIA_ORDER,
COMPOSE_SET_STATUS,
COMPOSE_FOCUS,
} from '../actions/compose';
@ -536,6 +537,14 @@ export default function compose(state = initialState, action) {
return state.set('language', action.language);
case COMPOSE_FOCUS:
return state.set('focusDate', new Date()).update('text', text => text.length > 0 ? text : action.defaultText);
case COMPOSE_CHANGE_MEDIA_ORDER:
return state.update('media_attachments', list => {
const indexA = list.findIndex(x => x.get('id') === action.a);
const moveItem = list.get(indexA);
const indexB = list.findIndex(x => x.get('id') === action.b);
return list.splice(indexA, 1).splice(indexB, 0, moveItem);
});
default:
return state;
}