mirror of
				https://github.com/pierre42100/ComunicWeb
				synced 2025-11-03 11:44:19 +00:00 
			
		
		
		
	Take account of new settings
This commit is contained in:
		@@ -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);
 | 
			
		||||
	}
 | 
			
		||||
})
 | 
			
		||||
		Reference in New Issue
	
	Block a user