mirror of
https://github.com/pierre42100/ComunicWeb
synced 2024-11-26 05:49:22 +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
|
* Song element : null by default
|
||||||
|
*
|
||||||
|
* @type {HTMLAudioElement}
|
||||||
*/
|
*/
|
||||||
songElem: null,
|
songElem: null,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check whether notifications song is enabled or not
|
||||||
|
*/
|
||||||
|
enableSong: false,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Play notification song once
|
* Play notification song once
|
||||||
*/
|
*/
|
||||||
play: function(){
|
play: function(){
|
||||||
|
|
||||||
|
if (!NotificationsSong.enableSong)
|
||||||
|
return;
|
||||||
|
|
||||||
//Create song element if required
|
//Create song element if required
|
||||||
if(this.songElem == null){
|
if(NotificationsSong.songElem == null){
|
||||||
this.songElem = new SongPlayer([
|
NotificationsSong.songElem = new SongPlayer([
|
||||||
ComunicWeb.__config.assetsURL + "audio/notif_song.mp3",
|
ComunicWeb.__config.assetsURL + "audio/notif_song.mp3",
|
||||||
ComunicWeb.__config.assetsURL + "audio/notif_song.ogg"
|
ComunicWeb.__config.assetsURL + "audio/notif_song.ogg"
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Play song
|
//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);
|
await SettingsInterface.setNotifications(newSettings);
|
||||||
|
|
||||||
|
// Apply new settings immediatly
|
||||||
|
NotificationsSong.enableSong = newSettings.allow_notifications_sound;
|
||||||
|
|
||||||
notify(tr("Successfully updated settings!"), "success")
|
notify(tr("Successfully updated settings!"), "success")
|
||||||
|
|
||||||
} catch(e) {
|
} catch(e) {
|
||||||
|
Loading…
Reference in New Issue
Block a user