mirror of
https://github.com/suitenumerique/meet.git
synced 2026-08-10 10:47:20 +00:00
83914f8307
Introduced a global state to handle user preferences related to notifications. The first use case is sound notifications, allowing users to disable them based on feedback. Additionally, the sound volume is now stored globally, making it easy to configure in the future if needed. I've lowered the volume of the notifications to make them more discreet. Preferences are persisted in local storage, ensuring they are retained between meetings.
25 lines
884 B
TypeScript
25 lines
884 B
TypeScript
import useSound from 'use-sound'
|
|
import { useSnapshot } from 'valtio'
|
|
import { notificationsStore } from '@/stores/notifications'
|
|
import { NotificationType } from '@/features/notifications/NotificationType'
|
|
|
|
// fixme - handle dynamic audio output changes
|
|
export const useNotificationSound = () => {
|
|
const notificationsSnap = useSnapshot(notificationsStore)
|
|
const [play] = useSound('./sounds/notifications.mp3', {
|
|
sprite: {
|
|
participantJoined: [0, 1150],
|
|
handRaised: [1400, 180],
|
|
messageReceived: [1580, 300],
|
|
waiting: [2039, 710],
|
|
success: [2740, 1304],
|
|
},
|
|
volume: notificationsSnap.soundNotificationVolume,
|
|
})
|
|
const triggerNotificationSound = (type: NotificationType) => {
|
|
const isSoundEnabled = notificationsSnap.soundNotifications.get(type)
|
|
if (isSoundEnabled) play({ id: type })
|
|
}
|
|
return { triggerNotificationSound }
|
|
}
|