Do Not Disturb: factorized logic and toast in its proper service.
This commit is contained in:
parent
8ec1ad7255
commit
05bfb6fc37
4 changed files with 13 additions and 22 deletions
|
|
@ -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, {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue