ui: allow disabling notifications globally

This commit is contained in:
jean-emmanuel 2024-07-26 12:30:58 +02:00
parent 30ee07c52b
commit abf943da5f
9 changed files with 34 additions and 1 deletions

View file

@ -211,6 +211,13 @@ var menuEntries = [
if (fullscreen.isEnabled) fullscreen.toggle()
},
shortcut: 'f11'
},
{
label: locales('notifications'),
class: ()=>{return 'toggle ' + (notifications.visible ? 'on' : 'off')},
action: ()=>{
notifications.setVisibility(!notifications.visible)
}
}
]

View file

@ -63,6 +63,9 @@ class Notifications extends UiWidget {
this.toasts = []
this.loop = null
this.visible = undefined
this.setVisibility(ENV.notifications != 0)
this.container.addEventListener('fast-click', (e)=>{
for (var toast of this.toasts) {
@ -124,6 +127,13 @@ class Notifications extends UiWidget {
}
setVisibility(v) {
this.visible = v
this.container.style.display = v ? '' : 'none'
}
}
module.exports = new Notifications({selector: '#notifications'})