mirror of
https://github.com/zoriya/noctalia-shell.git
synced 2026-08-15 18:43:59 +00:00
Do Not Disturb: factorized logic and toast in its proper service.
This commit is contained in:
@@ -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, {
|
||||
|
||||
Reference in New Issue
Block a user