mirror of
https://git.notfire.cc/notfire/akkoma-fe.git
synced 2026-01-11 05:23:16 -08:00
add the ability to have custom notification sounds for specific users
This commit is contained in:
parent
ae35c58425
commit
7c4cc56ff4
2 changed files with 19 additions and 3 deletions
|
|
@ -767,7 +767,7 @@
|
|||
"show_yous": "Show (You)s",
|
||||
"sound_on_notification": "Play a sound when you get a notification",
|
||||
"sound_on_notification_custom": "Custom sounds",
|
||||
"sound_on_notification_custom_exp": "Put URLs to custom sounds in this box, one line for each. If you want one sound to have a different volume, put a semicolon after the link and the volume as a number between 0 and 1.",
|
||||
"sound_on_notification_custom_exp": "Put URLs to custom sounds in this box, one line for each. If you want one sound to have a different volume, put a semicolon after the link and the volume as a number between 0 and 1. If you want a sound to affect a certain user, use a second semicolon and then their ID.",
|
||||
"sound_on_notification_volume": "Volume of the default notification sound",
|
||||
"stop_gifs": "Pause animated images until you hover on them",
|
||||
"streaming": "Automatically show new posts when scrolled to the top",
|
||||
|
|
|
|||
|
|
@ -136,9 +136,25 @@ export const prepareNotificationObject = (notification, i18n, store) => {
|
|||
|
||||
if (store.getters.mergedConfig.soundOnNotif) {
|
||||
if (store.getters.mergedConfig.soundOnNotifCustom !== '') {
|
||||
var fallback = true
|
||||
var soundVol
|
||||
var soundList = store.getters.mergedConfig.soundOnNotifCustom.split("\n")
|
||||
var randomSound = soundList[Math.floor(Math.random() * soundList.length)]
|
||||
var soundVol = (randomSound.split(";").length > 1 ? randomSound.split(";")[1] : store.getters.mergedConfig.soundOnNotifVolume)
|
||||
var randomSound
|
||||
soundList.forEach(sound => {
|
||||
// if there's more args, assume specific user tied to sound
|
||||
if (sound.split(";").length > 2) {
|
||||
var user = [sound.split(";")[2]]
|
||||
if (user == notification.from_profile.id) {
|
||||
randomSound = sound.split(";")[0]
|
||||
soundVol = (sound.split(";")[1].length > 0 ? sound.split(";")[1] : store.getters.mergedConfig.soundOnNotifVolume)
|
||||
fallback = false
|
||||
}
|
||||
}
|
||||
});
|
||||
if (fallback) {
|
||||
randomSound = soundList[Math.floor(Math.random() * soundList.length)]
|
||||
soundVol = (randomSound.split(";").length > 1 ? randomSound.split(";")[1] : store.getters.mergedConfig.soundOnNotifVolume)
|
||||
}
|
||||
|
||||
var sound = new Audio(randomSound.split(";")[0])
|
||||
sound.volume = soundVol
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue