Override the Notification API constructor to create silent notifications when the webContents is muted

This commit is contained in:
Samuel Attard 2016-07-01 23:12:06 +12:00
parent 36a0a491c9
commit 54f06b0ba9

View file

@ -248,3 +248,14 @@ Object.defineProperty(document, 'visibilityState', {
return cachedVisibilityState
}
})
// Make notifications silent if the the current webContents is muted
const NativeNotification = window.Notification
class Notification extends NativeNotification {
constructor (title, opts) {
super(title, Object.assign({
silent: remote.getCurrentWebContents().isAudioMuted()
}, opts))
}
}
window.Notification = Notification