Remove suffix, don't alert on download cancel
This commit is contained in:
8
popup.js
8
popup.js
@@ -9,6 +9,11 @@ function setStatus(message) {
|
||||
statusEl.textContent = message;
|
||||
}
|
||||
|
||||
function isUserCancelledError(result) {
|
||||
const error = result && typeof result.error === "string" ? result.error.toLowerCase() : "";
|
||||
return error.includes("canceled by the user") || error.includes("cancelled by the user");
|
||||
}
|
||||
|
||||
function entryLabel(entry) {
|
||||
return entry && entry.fullUrl ? "full candidate" : "preview fallback";
|
||||
}
|
||||
@@ -115,6 +120,9 @@ function buildRow(entry) {
|
||||
download.addEventListener("click", async () => {
|
||||
const result = await browser.runtime.sendMessage({ type: "DOWNLOAD_ENTRY", entry });
|
||||
if (!result || !result.ok) {
|
||||
if (isUserCancelledError(result)) {
|
||||
return;
|
||||
}
|
||||
window.alert((result && result.error) || "Download failed.");
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user