Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Commit 7bb04c74 authored by Kai Uwe Broulik's avatar Kai Uwe Broulik 🍇

Send all active downloads on load

Ensures when the extension is reloaded any downloads currently running are still shown in notifications

Differential Revision: https://phabricator.kde.org/D16887
parent 8ddb1d02
......@@ -405,7 +405,7 @@ var whitelistedDownloadProperties = [
"id", "url", "finalUrl", "filename", "startTime", "estimatedEndTime", "totalBytes", "bytesReceived", "state", "error", /*"canResume"*/, "paused"
];
chrome.downloads.onCreated.addListener(function (download) {
function createDownload(download) {
// don't bother telling us about completed downloads...
// otherwise on browser startup we'll spawn a gazillion download progress notification
if (download.state === "complete" || download.state === "interrupted") {
......@@ -418,7 +418,18 @@ chrome.downloads.onCreated.addListener(function (download) {
startSendingDownloadUpdates();
port.postMessage({subsystem: "downloads", event: "created", download: filteredDownload});
});
}
function sendDownloads() {
// When extension is (re)loaded, create each download initially
chrome.downloads.search({
state: 'in_progress',
}, function (results) {
results.forEach(createDownload);
});
}
chrome.downloads.onCreated.addListener(createDownload);
chrome.downloads.onChanged.addListener(function (delta) {
if (activeDownloads.indexOf(delta.id) === -1) {
......@@ -666,6 +677,7 @@ function connectHost() {
sendEnvironment();
sendSettings();
sendDownloads();
}
addRuntimeCallback("settings", "changed", function () {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment