Override the Notification API constructor to create silent notifications when the webContents is muted
This commit is contained in:
parent
36a0a491c9
commit
54f06b0ba9
1 changed files with 11 additions and 0 deletions
|
@ -248,3 +248,14 @@ Object.defineProperty(document, 'visibilityState', {
|
||||||
return cachedVisibilityState
|
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
|
||||||
|
|
Loading…
Add table
Reference in a new issue