mirror of
https://github.com/electron/electron.git
synced 2026-04-10 03:01:51 -04:00
Override the Notification API constructor to create silent notifications when the webContents is muted
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user