Browse Source

updates #1795: Only download metadata for video files

JC Brand 5 years ago
parent
commit
c3102561f4
3 changed files with 4 additions and 11 deletions
  1. 2 4
      spec/messages.js
  2. 1 2
      src/templates/video.html
  3. 1 5
      src/utils/html.js

+ 2 - 4
spec/messages.js

@@ -1973,8 +1973,7 @@
                 let media = view.el.querySelector('.chat-msg .chat-msg__media');
                 expect(media.innerHTML.replace(/(\r\n|\n|\r)/gm, "")).toEqual(
                     '<!-- src/templates/video.html -->'+
-                    '<video controls="" src="https://montague.lit/video.mp4" style="max-height: 50vh"></video>'+
-                    '<a target="_blank" rel="noopener" href="https://montague.lit/video.mp4">Download video file "video.mp4"</a>');
+                    '<video controls="" preload="metadata" src="https://montague.lit/video.mp4" style="max-height: 50vh"></video>');
 
                 // If the <url> and <body> contents is the same, don't duplicate.
                 stanza = u.toStanza(`
@@ -1991,8 +1990,7 @@
                 media = view.el.querySelector('.chat-msg:last-child .chat-msg__media');
                 expect(media.innerHTML.replace(/(\r\n|\n|\r)/gm, "")).toEqual(
                     '<!-- src/templates/video.html -->'+
-                    '<video controls="" src="https://montague.lit/video.mp4" style="max-height: 50vh"></video>'+
-                    '<a target="_blank" rel="noopener" href="https://montague.lit/video.mp4">Download video file "video.mp4"</a>');
+                    '<video controls="" preload="metadata" src="https://montague.lit/video.mp4" style="max-height: 50vh"></video>');
                 done();
             }));
 

+ 1 - 2
src/templates/video.html

@@ -1,2 +1 @@
-<video controls src="{{{o.url}}}" style="max-height: 50vh"></video>
-<a target="_blank" rel="noopener" href="{{{o.url}}}">{{{o.label_download}}}</a>
+<video controls preload="metadata" src="{{{o.url}}}" style="max-height: 50vh"></video>

+ 1 - 5
src/utils/html.js

@@ -223,11 +223,7 @@ u.renderImageURLs = function (_converse, el) {
 u.renderMovieURL = function (_converse, url) {
     const uri = new URI(url);
     if (u.isVideoURL(uri)) {
-        const { __ } = _converse;
-        return tpl_video({
-            'url': url,
-            'label_download': __('Download video file "%1$s"', decodeURI(uri.filename()))
-        })
+        return tpl_video({url});
     }
     return url;
 };