From 3a7b05b85931990fec31aada07489bd4e52be33e Mon Sep 17 00:00:00 2001 From: vicrodh <103399283+vicrodh@users.noreply.github.com> Date: Wed, 14 Jan 2026 04:41:13 -0600 Subject: [PATCH] feat(settings): add notifications toggle Users can now disable toast notifications (buffering, track changes, etc.) from Settings > Appearance. Error notifications are always shown. cc --- package.json | 2 +- src-tauri/Cargo.toml | 2 +- src-tauri/tauri.conf.json | 2 +- src/lib/components/views/SettingsView.svelte | 16 ++++++++- src/lib/stores/toastStore.ts | 36 ++++++++++++++++++++ 5 files changed, 54 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index 0f08bbee3..8c85a8c07 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "qbz-nix", - "version": "1.1.3", + "version": "1.1.4", "description": "Native Qobuz client for Linux with Hi-Fi audio support", "type": "module", "scripts": { diff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.toml index 2caac025e..bf6b29bf3 100644 --- a/src-tauri/Cargo.toml +++ b/src-tauri/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "qbz-nix" -version = "1.1.3" +version = "1.1.4" description = "Native Qobuz client for Linux with Hi-Fi audio support" authors = ["blitzkriegfc"] edition = "2021" diff --git a/src-tauri/tauri.conf.json b/src-tauri/tauri.conf.json index daf83204e..1b5b3cd9b 100644 --- a/src-tauri/tauri.conf.json +++ b/src-tauri/tauri.conf.json @@ -1,7 +1,7 @@ { "$schema": "https://schema.tauri.app/config/2", "productName": "QBZ", - "version": "1.1.3", + "version": "1.1.4", "identifier": "com.blitzkriegfc.qbz", "build": { "beforeDevCommand": "npm run dev", diff --git a/src/lib/components/views/SettingsView.svelte b/src/lib/components/views/SettingsView.svelte index 993b86f59..ff947f2dc 100644 --- a/src/lib/components/views/SettingsView.svelte +++ b/src/lib/components/views/SettingsView.svelte @@ -16,6 +16,11 @@ } from '$lib/stores/downloadState'; import { clearCache as clearLyricsCache } from '$lib/stores/lyricsStore'; import { getDevicePrettyName } from '$lib/utils/audioDeviceNames'; + import { + getNotificationsEnabled, + setNotificationsEnabled, + loadNotificationsPreference + } from '$lib/stores/toastStore'; interface Props { onBack?: () => void; @@ -138,6 +143,7 @@ // Appearance settings let theme = $state('Dark'); let compactMode = $state(false); + let notificationsEnabled = $state(true); let language = $state('Auto'); // Last.fm integration state @@ -209,6 +215,10 @@ // Load API keys state loadApiKeysState(); + + // Load notifications preference + loadNotificationsPreference(); + notificationsEnabled = getNotificationsEnabled(); }); async function loadLastfmState() { @@ -840,10 +850,14 @@ onchange={handleZoomChange} /> -
+
Compact Mode (compactMode = v)} />
+
+ Notifications + { notificationsEnabled = v; setNotificationsEnabled(v); }} /> +
diff --git a/src/lib/stores/toastStore.ts b/src/lib/stores/toastStore.ts index 16843ab3c..a829a6702 100644 --- a/src/lib/stores/toastStore.ts +++ b/src/lib/stores/toastStore.ts @@ -18,6 +18,37 @@ let currentToast: Toast | null = null; // Track buffering toast specifically so we can dismiss it let bufferingToastActive = false; +// Global enable/disable for notifications +let notificationsEnabled = true; + +/** + * Load notifications preference from localStorage + */ +export function loadNotificationsPreference(): void { + const saved = localStorage.getItem('qbz-notifications-enabled'); + if (saved !== null) { + notificationsEnabled = saved === 'true'; + } +} + +/** + * Set notifications enabled/disabled + */ +export function setNotificationsEnabled(enabled: boolean): void { + notificationsEnabled = enabled; + localStorage.setItem('qbz-notifications-enabled', String(enabled)); + if (!enabled) { + hideToast(); + } +} + +/** + * Get notifications enabled state + */ +export function getNotificationsEnabled(): boolean { + return notificationsEnabled; +} + // Auto-hide timeout let hideTimeout: ReturnType | null = null; @@ -45,6 +76,11 @@ export function isBufferingActive(): boolean { * @param duration How long to show the toast in ms (default: varies by type) */ export function showToast(message: string, type: ToastType = 'info', duration?: number): void { + // Skip if notifications are disabled (except errors which are always shown) + if (!notificationsEnabled && type !== 'error') { + return; + } + // Clear existing timeout if (hideTimeout) { clearTimeout(hideTimeout);