Fix: Added Download Toggles to Global-Store (#63)

This commit is contained in:
Youwes09
2026-05-02 17:40:07 -05:00
parent b4d680ddd1
commit bd95bf4eb1
2 changed files with 13 additions and 8 deletions
@@ -5,7 +5,7 @@ import {
DEQUEUE_DOWNLOAD, DEQUEUE_CHAPTERS_DOWNLOAD,
ENQUEUE_DOWNLOAD, REORDER_DOWNLOAD,
} from "@api/mutations";
import { addToast, setActiveDownloads } from "@store/state.svelte";
import { addToast, setActiveDownloads, store, updateSettings } from "@store/state.svelte";
import { boot } from "@store/boot.svelte";
import type { DownloadStatus, DownloadQueueItem } from "@types/index";
import {
@@ -26,8 +26,8 @@ class DownloadStore {
pagesPerSec: number | null = $state(null);
eta: number | null = $state(null);
toastsEnabled = $state(true);
autoRetryEnabled = $state(false);
get toastsEnabled() { return store.settings.downloadToastsEnabled ?? true; }
get autoRetryEnabled() { return store.settings.downloadAutoRetry ?? false; }
private lastSample: SpeedSample | null = null;
private prevQueue: DownloadQueueItem[] = [];
@@ -39,18 +39,19 @@ class DownloadStore {
get hasErrored() { return this.erroredIds.size > 0; }
toggleToasts() {
this.toastsEnabled = !this.toastsEnabled;
addToast({ kind: "info", title: this.toastsEnabled ? "Notifications enabled" : "Notifications muted", body: this.toastsEnabled ? "You'll be notified when chapters finish downloading" : "Download notifications are silenced", duration: 2500 });
const next = !this.toastsEnabled;
updateSettings({ downloadToastsEnabled: next });
addToast({ kind: "info", title: next ? "Notifications enabled" : "Notifications muted", body: next ? "You'll be notified when chapters finish downloading" : "Download notifications are silenced", duration: 2500 });
}
toggleAutoRetry() {
if (this.autoRetryEnabled) {
this.autoRetryHnd?.stop();
this.autoRetryHnd = null;
this.autoRetryEnabled = false;
this.autoRetryHnd = null;
updateSettings({ downloadAutoRetry: false });
addToast({ kind: "info", title: "Auto-retry disabled", body: "Failed downloads will no longer retry automatically", duration: 2500 });
} else {
this.autoRetryEnabled = true;
updateSettings({ downloadAutoRetry: true });
this.autoRetryHnd = startAutoRetry(
() => this.queue,
() => this.isRunning,
+4
View File
@@ -124,6 +124,8 @@ export interface Settings {
trackerRespectScanlatorFilter: boolean;
pinchZoom?: boolean;
autoLinkOnOpen: boolean;
downloadToastsEnabled: boolean;
downloadAutoRetry: boolean;
}
export const DEFAULT_SETTINGS: Settings = {
@@ -163,4 +165,6 @@ export const DEFAULT_SETTINGS: Settings = {
trackerRespectScanlatorFilter: true,
pinchZoom: false,
autoLinkOnOpen: false,
downloadToastsEnabled: true,
downloadAutoRetry: false,
};