1
1
mirror of https://github.com/neosubhamoy/neodlp.git synced 2026-06-21 17:23:43 +05:30

feat: added quit-on-close option #18 #33

This commit is contained in:
2026-05-26 11:20:05 +05:30
Verified
parent a213a1e8ad
commit eb4cb16bbd
6 changed files with 79 additions and 4 deletions
@@ -130,6 +130,7 @@ function AppGeneralSettings() {
const maxRetries = useSettingsPageStatesStore(state => state.settings.max_retries);
const preferVideoOverPlaylist = useSettingsPageStatesStore(state => state.settings.prefer_video_over_playlist);
const strictDownloadabilityCheck = useSettingsPageStatesStore(state => state.settings.strict_downloadablity_check);
const quitOnClose = useSettingsPageStatesStore(state => state.settings.quit_on_close);
const useAria2 = useSettingsPageStatesStore(state => state.settings.use_aria2);
const useCustomCommands = useSettingsPageStatesStore(state => state.settings.use_custom_commands);
@@ -179,6 +180,15 @@ function AppGeneralSettings() {
/>
<Label htmlFor="max-retries" className="text-xs text-muted-foreground">(Current: {maxRetries}) (Default: 5, Maximum: 100)</Label>
</div>
<div className="quit-on-close">
<h3 className="font-semibold">Quit on Close</h3>
<p className="text-xs text-muted-foreground mb-3">Wheather to quit the app when the main window is closed, if disabled the app will keep running in the background and you can open the main window again from the system tray</p>
<Switch
id="quit-on-close"
checked={quitOnClose}
onCheckedChange={(checked) => saveSettingsKey('quit_on_close', checked)}
/>
</div>
<div className="aria2">
<h3 className="font-semibold">Aria2</h3>
<p className="text-xs text-muted-foreground mb-3">Use aria2c as external downloader (recommended only if you are experiancing too slow download speeds with native downloader, you need to install aria2 via homebrew if you are on macos to use this feature)</p>
+35 -1
View File
@@ -4,10 +4,35 @@ import { MaximizeIcon } from "@/components/icons/maximize";
import { MinimizeIcon } from "@/components/icons/minimize";
import { CloseIcon } from "@/components/icons/close";
import { UnmaximizeIcon } from "@/components/icons/unmaximize";
import { useDownloadActionStatesStore, useDownloadStatesStore, useSettingsPageStatesStore } from "@/services/store";
import { useAppContext } from "@/providers/appContextProvider";
export default function TitleBar() {
const [maximized, setMaximized] = useState<boolean>(false);
const appWindow = getCurrentWebviewWindow();
const quitOnClose = useSettingsPageStatesStore(state => state.settings.quit_on_close);
const downloadStates = useDownloadStatesStore(state => state.downloadStates);
const ongoingDownloads = downloadStates.filter(state =>
['starting', 'downloading', 'queued'].includes(state.download_status)
);
const setIsPausingDownload = useDownloadActionStatesStore(state => state.setIsPausingDownload);
const { pauseDownload } = useAppContext();
const stopOngoingDownloads = async () => {
if (ongoingDownloads.length > 0) {
for (const state of ongoingDownloads) {
setIsPausingDownload(state.download_id, true);
try {
await pauseDownload(state);
} catch (e) {
console.error(e);
} finally {
setIsPausingDownload(state.download_id, false);
}
}
}
}
return (
<div className="titlebar flex items-center justify-between border-b bg-background">
@@ -48,7 +73,16 @@ export default function TitleBar() {
className="px-4 py-3 hover:bg-destructive"
id="titlebar-close"
title="Close"
onClick={() => appWindow.hide()}
onClick={async () => {
if (quitOnClose) {
if (ongoingDownloads.length > 0) {
await stopOngoingDownloads();
}
await appWindow.destroy();
} else {
await appWindow.hide()
}
}}
>
<CloseIcon />
</button>