updates #1795: Only download metadata for video files

This commit is contained in:
JC Brand 2019-12-18 14:18:37 +01:00
parent c6c65749bb
commit c3102561f4
3 changed files with 4 additions and 11 deletions

View File

@ -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();
}));

View File

@ -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>

View File

@ -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;
};