Remove text requirement when media attached from statuses (fixes #381)

Ports cfa9b6e13a to glitchsoc
This commit is contained in:
Thibaut Girka
2018-03-12 18:39:07 +01:00
parent a0724cd742
commit 841ef606a9
4 changed files with 19 additions and 7 deletions

View File

@@ -158,7 +158,6 @@ function appendMedia(state, media) {
map.update('media_attachments', list => list.push(media));
map.set('is_uploading', false);
map.set('resetFileKey', Math.floor((Math.random() * 0x10000)));
map.update('text', oldText => `${oldText.trim()} ${media.get('text_url')}`);
map.set('focusDate', new Date());
map.set('idempotencyKey', uuid());
@@ -169,12 +168,10 @@ function appendMedia(state, media) {
};
function removeMedia(state, mediaId) {
const media = state.get('media_attachments').find(item => item.get('id') === mediaId);
const prevSize = state.get('media_attachments').size;
return state.withMutations(map => {
map.update('media_attachments', list => list.filterNot(item => item.get('id') === mediaId));
map.update('text', text => text.replace(media.get('text_url'), '').trim());
map.set('idempotencyKey', uuid());
if (prevSize === 1) {