From a8449109c742e5e102dff229b3f9b7efd9d9612e Mon Sep 17 00:00:00 2001 From: Fen Dweller Date: Thu, 28 Oct 2021 10:47:13 -0400 Subject: [PATCH] Warn when a screenshot fails to be taken This usually happens when the window gets unfocused before the screenshot is done. The promise is now handled properly. Unhandled promise errors will now cause a popup. The popup can only appear once now. --- macrovision.html | 11 ++++++++++- macrovision.js | 9 +++++++-- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/macrovision.html b/macrovision.html index 8778ccea..9f7402f8 100644 --- a/macrovision.html +++ b/macrovision.html @@ -39,7 +39,16 @@ diff --git a/macrovision.js b/macrovision.js index d60cd12c..e28e6abf 100644 --- a/macrovision.js +++ b/macrovision.js @@ -5,6 +5,8 @@ let prevSelectedEntity = null; let entityIndex = 0; +let firsterror = true; + let clicked = null; let movingInBounds = false; let dragging = false; @@ -3179,7 +3181,6 @@ document.addEventListener("DOMContentLoaded", () => { document.querySelector("#copy-screenshot").addEventListener("click", e => { copyScreenshot(); - toast("Copied to clipboard!"); }); document.querySelector("#save-screenshot").addEventListener("click", e => { @@ -5095,7 +5096,11 @@ function copyScreenshot() { new ClipboardItem({ "image/png": blob }) - ]); + ]).then(e => + toast("Copied to clipboard!")) + .catch(e => { + toast("Couldn't write to the clipboard. Make sure the screenshot completes before switching tabs.") + }) }); drawScales(false); }