From 7448fa93df6c2ba9f4fffecb605cd675ddcabbf5 Mon Sep 17 00:00:00 2001 From: yflory Date: Thu, 26 Nov 2020 16:27:12 +0100 Subject: [PATCH] Fix download from contextmenu when mediatag is not ready --- www/common/inner/common-mediatag.js | 3 +++ www/pad/inner.js | 2 ++ 2 files changed, 5 insertions(+) diff --git a/www/common/inner/common-mediatag.js b/www/common/inner/common-mediatag.js index e60f734d0..741529de0 100644 --- a/www/common/inner/common-mediatag.js +++ b/www/common/inner/common-mediatag.js @@ -364,6 +364,7 @@ define([ Messages.pad_mediatagShare = "Share file"; // XXX Messages.pad_mediatagOpen = "Open file"; // XXX + Messages.mediatag_notReady = "Not ready"; // XXX var mediatagContextMenu; MT.importMediaTagMenu = function (common) { @@ -424,6 +425,8 @@ define([ } else if ($this.hasClass("cp-app-code-context-download")) { var media = Util.find($mt, [0, '_mediaObject']); + if (!media) { return void console.error('no media'); } + if (!media.complete) { return void UI.warn(Messages.mediatag_notReady); } if (!(media && media._blob)) { return void console.error($mt); } window.saveAs(media._blob.content, media.name); } diff --git a/www/pad/inner.js b/www/pad/inner.js index 2e5b2ad91..8a99b6101 100644 --- a/www/pad/inner.js +++ b/www/pad/inner.js @@ -1171,6 +1171,8 @@ define([ }; editor.plugins.mediatag.download = function($mt) { var media = Util.find($mt, [0, '_mediaObject']); + if (!media) { return void console.error('no media'); } + if (!media.complete) { return void UI.warn(Messages.mediatag_notReady); } if (!(media && media._blob)) { return void console.error($mt); } window.saveAs(media._blob.content, media.name); };