]> cat aescling's git repositories - mastodon.git/commitdiff
[Glitch] Avoid storing audio and video file data in memory
authorThibG <thib@sitedethib.com>
Fri, 27 Sep 2019 13:22:11 +0000 (15:22 +0200)
committerThibaut Girka <thib@sitedethib.com>
Mon, 30 Sep 2019 13:58:29 +0000 (15:58 +0200)
Port 860a77d45ee9d17117364868f0932b4fcbe07d3d to glitch-soc

Signed-off-by: Thibaut Girka <thib@sitedethib.com>
app/javascript/flavours/glitch/reducers/compose.js

index 3699ec1ad060cb5108a2a01be90c18d1cd8487a7..17ce5de3ccec9bc593c9d1a5f71cbaa4fe36192a 100644 (file)
@@ -194,7 +194,10 @@ function appendMedia(state, media, file) {
   const prevSize = state.get('media_attachments').size;
 
   return state.withMutations(map => {
-    map.update('media_attachments', list => list.push(media.set('file', file)));
+    if (media.get('type') === 'image') {
+      media = media.set('file', file);
+    }
+    map.update('media_attachments', list => list.push(media));
     map.set('is_uploading', false);
     map.set('resetFileKey', Math.floor((Math.random() * 0x10000)));
     map.set('idempotencyKey', uuid());