mirror of
https://github.com/MasterAcnolo/Freedom-Loader.git
synced 2026-07-29 18:25:47 +02:00
Feat: Implement notification feature for download completion
This commit is contained in:
@@ -18,7 +18,8 @@ const FEATURE_WHITELIST = new Set([
|
|||||||
"autoDownloadPlaylist",
|
"autoDownloadPlaylist",
|
||||||
"customCodec",
|
"customCodec",
|
||||||
"theme",
|
"theme",
|
||||||
"createPlaylistFolders"
|
"createPlaylistFolders",
|
||||||
|
"notifySystem"
|
||||||
]);
|
]);
|
||||||
|
|
||||||
const configFolderPath = featuresPath;
|
const configFolderPath = featuresPath;
|
||||||
|
|||||||
@@ -97,13 +97,13 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- <div class="setting-item">
|
<div class="setting-item">
|
||||||
<input type="checkbox" data-key="notifySystem" id="notifySystem">
|
<input type="checkbox" data-key="notifySystem" id="notifySystem">
|
||||||
<div class="setting-info">
|
<div class="setting-info">
|
||||||
<span class="setting-title">Notification at the end</span>
|
<span class="setting-title">Notification at the end</span>
|
||||||
<small>Notify when a download finishes.</small>
|
<small>Notify when a download finishes.</small>
|
||||||
</div>
|
</div>
|
||||||
</div> -->
|
</div>
|
||||||
|
|
||||||
<div class="setting-item">
|
<div class="setting-item">
|
||||||
<input type="checkbox" data-key="autoCheckInfo" id="autoCheckInfo">
|
<input type="checkbox" data-key="autoCheckInfo" id="autoCheckInfo">
|
||||||
|
|||||||
@@ -44,8 +44,11 @@ form.addEventListener("submit", async (e) => {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Download successful
|
// Download successful - check if notifications are enabled
|
||||||
window.showSuccess("Download completed!");
|
const features = await window.electronAPI.getFeatures();
|
||||||
|
if (features.notifySystem) {
|
||||||
|
window.showSuccess("Download completed!");
|
||||||
|
}
|
||||||
|
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
if (!isDownloading && !userStoppedDownload) {
|
if (!isDownloading && !userStoppedDownload) {
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ const { fetchDownload, cancelDownload } = require("../services/download.services
|
|||||||
const { logger } = require("../logger");
|
const { logger } = require("../logger");
|
||||||
const { isValidUrl, isSafePath } = require("../helpers/validation.helpers");
|
const { isValidUrl, isSafePath } = require("../helpers/validation.helpers");
|
||||||
const { notifyDownloadFinished } = require("../helpers/notify.helpers");
|
const { notifyDownloadFinished } = require("../helpers/notify.helpers");
|
||||||
|
const { configFeatures } = require("../../config");
|
||||||
|
|
||||||
const listeners = [];
|
const listeners = [];
|
||||||
const speedListeners = [];
|
const speedListeners = [];
|
||||||
@@ -26,7 +27,7 @@ async function downloadController(req, res) {
|
|||||||
|
|
||||||
// Get output folder when the download is finished
|
// Get output folder when the download is finished
|
||||||
const outputFolder = await fetchDownload(options, listeners, speedListeners, stageListeners, playlistInfoListeners);
|
const outputFolder = await fetchDownload(options, listeners, speedListeners, stageListeners, playlistInfoListeners);
|
||||||
notifyDownloadFinished(outputFolder);
|
notifyDownloadFinished(outputFolder, configFeatures.notifySystem);
|
||||||
res.send("Download Done !");
|
res.send("Download Done !");
|
||||||
|
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
|||||||
@@ -1,7 +1,9 @@
|
|||||||
const { Notification, shell } = require("electron");
|
const { Notification, shell } = require("electron");
|
||||||
const { iconPaths } = require("./path.helpers");
|
const { iconPaths } = require("./path.helpers");
|
||||||
|
|
||||||
function notifyDownloadFinished(folder) {
|
function notifyDownloadFinished(folder, notifyEnabled = true) {
|
||||||
|
if (!notifyEnabled) return;
|
||||||
|
|
||||||
const notif = new Notification({
|
const notif = new Notification({
|
||||||
title: "Freedom Loader",
|
title: "Freedom Loader",
|
||||||
body: "Your download is complete, click here to open it.",
|
body: "Your download is complete, click here to open it.",
|
||||||
|
|||||||
Reference in New Issue
Block a user