fix custom sounds on notifs for specific users. i think this wasn't working before because it didn't properly remove every element it needed to
This commit is contained in:
parent
ec36425b19
commit
9cd2bebb55
1 changed files with 7 additions and 6 deletions
|
@ -140,23 +140,24 @@ export const prepareNotificationObject = (notification, i18n, store) => {
|
||||||
var soundVol
|
var soundVol
|
||||||
var soundList = store.getters.mergedConfig.soundOnNotifCustom.split("\n")
|
var soundList = store.getters.mergedConfig.soundOnNotifCustom.split("\n")
|
||||||
var randomSound
|
var randomSound
|
||||||
var indexesToRemove = []
|
var tempList = []
|
||||||
soundList.forEach(sound => {
|
soundList.forEach(sound => {
|
||||||
// if there's more args, assume specific user tied to sound
|
// if there's more args, assume specific user tied to sound
|
||||||
if (sound.split(";").length > 2) {
|
if (sound.split(";").length > 2) {
|
||||||
indexesToRemove.push(soundList.indexOf(sound))
|
|
||||||
var user = [sound.split(";")[2]]
|
var user = [sound.split(";")[2]]
|
||||||
if (user == notification.from_profile.id) {
|
if (user == notification.from_profile.id) {
|
||||||
randomSound = sound.split(";")[0]
|
randomSound = sound.split(";")[0]
|
||||||
soundVol = (sound.split(";")[1].length > 0 ? sound.split(";")[1] : store.getters.mergedConfig.soundOnNotifVolume)
|
soundVol = (sound.split(";")[1].length > 0 ? sound.split(";")[1] : store.getters.mergedConfig.soundOnNotifVolume)
|
||||||
fallback = false
|
fallback = false
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
tempList.push(sound)
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
// ensure we remove the sounds with > 2 args
|
// ensure we only have the sounds with <= 2 args
|
||||||
indexesToRemove.forEach(index => {
|
if (tempList.length > 0) {
|
||||||
soundList.splice(index, 1)
|
soundList = tempList
|
||||||
})
|
}
|
||||||
if (fallback) {
|
if (fallback) {
|
||||||
randomSound = soundList[Math.floor(Math.random() * soundList.length)]
|
randomSound = soundList[Math.floor(Math.random() * soundList.length)]
|
||||||
soundVol = (randomSound.split(";").length > 1 ? randomSound.split(";")[1] : store.getters.mergedConfig.soundOnNotifVolume)
|
soundVol = (randomSound.split(";").length > 1 ? randomSound.split(";")[1] : store.getters.mergedConfig.soundOnNotifVolume)
|
||||||
|
|
Loading…
Add table
Reference in a new issue