fix: Implement proper toggle logic for notification enable/disable

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 <noreply@anthropic.com>
This commit is contained in:
MarekWo
2026-01-05 15:05:48 +01:00
parent e0fe04e339
commit a74ed136ce

View File

@@ -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');