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

@ -20,6 +20,8 @@
- client
- file browser now remembers the last displayed directory
- allow dismissing notifications by clicking on them
- allow toggling notifications globally from main menu
- add `notifications` client option
## 1.26.2

View file

@ -17,6 +17,7 @@ Client options can be set either with the server's `--client-options` option, or
| clientSync | 1 / 0 | 1 | set to 0 to prevent the client from syncing with other clients |
| altTraversing | 1 / 0 | 0 | set to 1 to enable an alternative traversing behavior for toggle buttons (traversing gestures on toggle buttons will change their values in only one way depending on the first touched button's state) |
| virtualKeyboard | 1 / 0 | 0 | (desktop only) set to 1 to enable the virtual keyboard by default |
| notifications | 1 / 0 | 1 | set to 0 to hide notifications by default |
Example:

View file

@ -30,6 +30,7 @@
- Clear console: remove logged messages from the console
- Virtual keyboard: (desktop only) toggle virtual keyboard (displayed only when a text input is in focus, except for code editors in the inspector)
- Fullscreen: toggle fullscreen
- Notifications: toggle visibility of notifications
- Prevent sleep (mobile only): attempt to prevent device from going to sleep when idle
## 2. Sidepanels

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