From 05bfb6fc37213ee8faaa3d25b6c637123a097140 Mon Sep 17 00:00:00 2001 From: LemmyCook Date: Fri, 5 Sep 2025 19:57:22 -0400 Subject: [PATCH] Do Not Disturb: factorized logic and toast in its proper service. --- Modules/Bar/Widgets/NotificationHistory.qml | 8 +------- Modules/IPC/IPCManager.qml | 4 ---- Modules/Notification/NotificationHistoryPanel.qml | 8 +------- Services/NotificationService.qml | 15 +++++++++++---- 4 files changed, 13 insertions(+), 22 deletions(-) diff --git a/Modules/Bar/Widgets/NotificationHistory.qml b/Modules/Bar/Widgets/NotificationHistory.qml index cb11314..274c61f 100644 --- a/Modules/Bar/Widgets/NotificationHistory.qml +++ b/Modules/Bar/Widgets/NotificationHistory.qml @@ -23,11 +23,5 @@ NIconButton { onClicked: PanelService.getPanel("notificationHistoryPanel")?.toggle(screen, this) - onRightClicked: { - Settings.data.notifications.doNotDisturb = !Settings.data.notifications.doNotDisturb - ToastService.showNotice( - Settings.data.notifications.doNotDisturb ? "Do Not Disturb enabled" : "Do Not Disturb disabled", - Settings.data.notifications.doNotDisturb ? "Notifications will be hidden but saved to history" : "Notifications will be shown normally", - "notice", false, 2000) - } + onRightClicked: Settings.data.notifications.doNotDisturb = !Settings.data.notifications.doNotDisturb } diff --git a/Modules/IPC/IPCManager.qml b/Modules/IPC/IPCManager.qml index b1ba1d7..8c541a3 100644 --- a/Modules/IPC/IPCManager.qml +++ b/Modules/IPC/IPCManager.qml @@ -40,10 +40,6 @@ Item { } function toggleDND() { Settings.data.notifications.doNotDisturb = !Settings.data.notifications.doNotDisturb - ToastService.showNotice( - Settings.data.notifications.doNotDisturb ? "Do Not Disturb enabled" : "Do Not Disturb disabled", - Settings.data.notifications.doNotDisturb ? "Notifications will be hidden but saved to history" : "Notifications will be shown normally", - "notice", false, 2000) } } diff --git a/Modules/Notification/NotificationHistoryPanel.qml b/Modules/Notification/NotificationHistoryPanel.qml index 0d4bff9..97e0a9a 100644 --- a/Modules/Notification/NotificationHistoryPanel.qml +++ b/Modules/Notification/NotificationHistoryPanel.qml @@ -48,13 +48,7 @@ NPanel { icon: Settings.data.notifications.doNotDisturb ? "notifications_off" : "notifications_active" tooltipText: Settings.data.notifications.doNotDisturb ? "Do Not Disturb (ON)" : "Do Not Disturb (OFF)" sizeRatio: 0.8 - onClicked: { - Settings.data.notifications.doNotDisturb = !Settings.data.notifications.doNotDisturb - ToastService.showNotice( - Settings.data.notifications.doNotDisturb ? "Do Not Disturb enabled" : "Do Not Disturb disabled", - Settings.data.notifications.doNotDisturb ? "Notifications will be hidden but saved to history" : "Notifications will be shown normally", - "notice", false, 2000) - } + onClicked: Settings.data.notifications.doNotDisturb = !Settings.data.notifications.doNotDisturb } NIconButton { diff --git a/Services/NotificationService.qml b/Services/NotificationService.qml index 62d88fb..1607be8 100644 --- a/Services/NotificationService.qml +++ b/Services/NotificationService.qml @@ -28,11 +28,11 @@ Singleton { // Signal when notification is received onNotification: function (notification) { + // Always add notification to history + root.addToHistory(notification) // Check if do-not-disturb is enabled if (Settings.data.notifications && Settings.data.notifications.doNotDisturb) { - // Still add to history but don't show notification - root.addToHistory(notification) return } @@ -46,8 +46,6 @@ Singleton { // Add to our model root.addNotification(notification) - // Also add to history - root.addToHistory(notification) } } @@ -109,6 +107,15 @@ Singleton { } } + Connections { + target: Settings.data.notifications + function onDoNotDisturbChanged() { + const label = Settings.data.notifications.doNotDisturb ? "'Do Not Disturb' enabled" : "'Do Not Disturb' disabled" + const description = Settings.data.notifications.doNotDisturb ? "You'll find these notifications in your history." : "Showing all notifications." + ToastService.showNotice(label, description, "notice", false, 2000) + } + } + // Function to add notification to model function addNotification(notification) { notificationModel.insert(0, {