mirror of
https://github.com/pierre42100/ComunicWeb
synced 2024-11-22 12:09:21 +00:00
Take account of new settings
This commit is contained in:
parent
4d05913819
commit
b5a942bf0c
@ -8,23 +8,43 @@ const NotificationsSong = {
|
||||
|
||||
/**
|
||||
* Song element : null by default
|
||||
*
|
||||
* @type {HTMLAudioElement}
|
||||
*/
|
||||
songElem: null,
|
||||
|
||||
/**
|
||||
* Check whether notifications song is enabled or not
|
||||
*/
|
||||
enableSong: false,
|
||||
|
||||
/**
|
||||
* Play notification song once
|
||||
*/
|
||||
play: function(){
|
||||
|
||||
if (!NotificationsSong.enableSong)
|
||||
return;
|
||||
|
||||
//Create song element if required
|
||||
if(this.songElem == null){
|
||||
this.songElem = new SongPlayer([
|
||||
if(NotificationsSong.songElem == null){
|
||||
NotificationsSong.songElem = new SongPlayer([
|
||||
ComunicWeb.__config.assetsURL + "audio/notif_song.mp3",
|
||||
ComunicWeb.__config.assetsURL + "audio/notif_song.ogg"
|
||||
]);
|
||||
}
|
||||
|
||||
//Play song
|
||||
this.songElem.playOnce();
|
||||
NotificationsSong.songElem.playOnce();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Get notification settings as soon as the page is loaded
|
||||
document.addEventListener("wsOpen", async () => {
|
||||
try {
|
||||
const settings = await SettingsInterface.getNotifications();
|
||||
NotificationsSong.enableSong = settings.allow_notifications_sound;
|
||||
} catch(e) {
|
||||
console.error(e);
|
||||
}
|
||||
})
|
@ -36,6 +36,9 @@ class NotificationsSettings {
|
||||
|
||||
await SettingsInterface.setNotifications(newSettings);
|
||||
|
||||
// Apply new settings immediatly
|
||||
NotificationsSong.enableSong = newSettings.allow_notifications_sound;
|
||||
|
||||
notify(tr("Successfully updated settings!"), "success")
|
||||
|
||||
} catch(e) {
|
||||
|
Loading…
Reference in New Issue
Block a user