Toggle the sound notifications

This commit is contained in:
Adrian Tombu
2019-01-12 12:54:06 +01:00
parent 170fd28c55
commit 97cf38e501
4 changed files with 36 additions and 0 deletions

View File

@@ -1,4 +1,5 @@
module.exports = {
init,
play
}
@@ -8,6 +9,9 @@ const path = require('path')
const VOLUME = 0.25
// App state to access the soundNotifications preference
let state
/* Cache of Audio elements, for instant playback */
const cache = {}
@@ -46,7 +50,15 @@ const sounds = {
}
}
function init (appState) {
state = appState
}
function play (name) {
if (!state.saved.prefs.soundNotifications) {
return
}
let audio = cache[name]
if (!audio) {
const sound = sounds[name]

View File

@@ -121,6 +121,7 @@ function setupStateSaved (cb) {
openExternalPlayer: false,
externalPlayerPath: null,
startup: false,
soundNotifications: true,
autoAddTorrents: false,
torrentsFolderPath: '',
highestPlaybackPriority: true