Skip to content
This repository has been archived by the owner on Feb 26, 2021. It is now read-only.

Commit

Permalink
Merge pull request #872 from maitrella/handling-downloaded-items-intents
Browse files Browse the repository at this point in the history
Add intents for handling downloaded items
  • Loading branch information
ianb committed Jan 17, 2020
2 parents e294a9f + 6afa143 commit d1a180f
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions extension/intents/saving/saving.js
Expand Up @@ -32,6 +32,29 @@ this.intents.saving = (function() {
},
});

this.intentRunner.registerIntent({
name: "saving.showLastDownload",
description: "Shows the last downloaded file in its containing folder",
examples: ["Show download"],
match: `
(show | view | find | open) (download | file)
`,
async run(context) {
const downloadItems = await browser.downloads.search({
limit: 1,
orderBy: ["-startTime"],
});
if (downloadItems.length > 0) {
const lastestDownloadId = downloadItems[0].id;
await browser.downloads.show(lastestDownloadId);
} else {
const e = new Error("No downloaded items found:");
e.displayMessage = "No downloaded items found";
throw e;
}
},
});

async function downloadData(body, contentType, filename) {
if (contentType !== "image/png" && contentType !== "image/jpeg") {
contentType = "image/png";
Expand Down

0 comments on commit d1a180f

Please sign in to comment.