From a74ed136cefd323ad3a70b92a3dde4d4e972143f Mon Sep 17 00:00:00 2001 From: MarekWo Date: Mon, 5 Jan 2026 15:05:48 +0100 Subject: [PATCH] fix: Implement proper toggle logic for notification enable/disable MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Previous implementation always disabled notifications when permission was granted, regardless of current state. This made it impossible to re-enable notifications after disabling them. Now properly checks localStorage state and toggles: - If currently enabled → disable (show "Notifications disabled") - If currently disabled → enable (show "Notifications enabled") This fixes the issue where clicking the toggle when disabled would show "Notifications disabled" instead of enabling them. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 --- app/static/js/app.js | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/app/static/js/app.js b/app/static/js/app.js index c24f58e..710b7b7 100644 --- a/app/static/js/app.js +++ b/app/static/js/app.js @@ -726,10 +726,20 @@ async function handleNotificationToggle() { const permission = getNotificationPermission(); if (permission === 'granted') { - // Already granted - toggle off - localStorage.setItem('mc_notifications_enabled', 'false'); - updateNotificationToggleUI(); - showNotification('Notifications disabled', 'info'); + // Permission granted - toggle between enabled/disabled + const isCurrentlyEnabled = localStorage.getItem('mc_notifications_enabled') === 'true'; + + if (isCurrentlyEnabled) { + // Turn OFF + localStorage.setItem('mc_notifications_enabled', 'false'); + updateNotificationToggleUI(); + showNotification('Notifications disabled', 'info'); + } else { + // Turn ON + localStorage.setItem('mc_notifications_enabled', 'true'); + updateNotificationToggleUI(); + showNotification('Notifications enabled', 'success'); + } } else if (permission === 'denied') { // Blocked - show help message showNotification('Notifications are blocked. Change browser settings: Settings → Site Settings → Notifications', 'warning');