mirror of
https://github.com/abhinavxd/libredesk.git
synced 2026-09-22 18:43:33 +00:00
43ebed1c3a
Targets broadcasts via per-tab list and open subs (validated at subscribe time) instead of broadcasting message uuid to all agents. Adds frontend list typing, throttled sound, and many perf improvements to reduce cpu memory & database queries. Other fixes: Enforce message-to-conversation binding in handleGetMessage
22 lines
482 B
JavaScript
22 lines
482 B
JavaScript
import notificationSound from '../assets/notification.mp3'
|
|
|
|
const PLAY_THROTTLE_MS = 1500
|
|
let audio = null
|
|
let lastPlayedAt = 0
|
|
|
|
export function initAudioContext() {
|
|
if (audio) return
|
|
audio = new Audio(notificationSound)
|
|
audio.volume = 0.5
|
|
audio.load()
|
|
}
|
|
|
|
export function playNotificationSound() {
|
|
if (!audio) return
|
|
const now = Date.now()
|
|
if (now - lastPlayedAt < PLAY_THROTTLE_MS) return
|
|
lastPlayedAt = now
|
|
audio.currentTime = 0
|
|
audio.play().catch(() => {})
|
|
}
|