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

@ -94,6 +94,9 @@ module.exports = {
// nosleep
nosleep: 'Prevent sleep',
// notifications
notifications: 'Benachrichtigungen',
// remote save
remotesave_open: 'Öffnen (auf dem Server)',
remotesave_save: 'Speichern (auf dem Server)',
@ -135,4 +138,4 @@ module.exports = {
error: 'Error'
}
}

View file

@ -94,6 +94,9 @@ module.exports = {
// nosleep
nosleep: 'Prevent sleep',
// notifications
notifications: 'Notifications',
// remote save
remotesave_open: 'Open (on the server)',
remotesave_save: 'Save (on the server)',

View file

@ -94,6 +94,9 @@ module.exports = {
// nosleep
nosleep: 'Empêcher la veille',
// notifications
notifications: 'Notifications',
// remote save
remotesave_open: 'Ouvrir (sur le serveur)',
remotesave_save: 'Enregistrer (sur le serveur)',

View file

@ -94,6 +94,9 @@ module.exports = {
// nosleep
nosleep: 'Nie pozwalaj na uśpienie ekranu',
// notifications
notifications: 'Powiadomienia',
// remote save
remotesave_open: 'Otwórz (na serwerze)',
remotesave_save: 'Sapisz (na serwerze)',

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'})