feat: add sound

This commit is contained in:
2025-12-20 14:29:16 +01:00
parent 4ae4ad8b74
commit b1dc4835b3
2 changed files with 6 additions and 0 deletions

View File

@@ -12,6 +12,7 @@
};
}
let withSound = false;
let persisted: PersistedState<CallEntry[]> = new PersistedState("calls", []);
let calls = $state<CallEntry[]>($state.snapshot(persisted.current));
let newCalls = $state<CallEntry[]>([]);
@@ -20,6 +21,7 @@
let connected = $state(false);
onMount(() => {
withSound = location.search.includes("sound=true");
eventTarget.addEventListener("display", (e) => {
const detail = (e as CustomEvent).detail;
const _newCalls = detail.tickets.filter(
@@ -29,6 +31,10 @@
persisted.current = calls;
connected = true;
if (!firstLoad) {
if (_newCalls.length > 0 && withSound) {
const audio = new Audio("/call.wav");
audio.play();
}
newCalls.push(..._newCalls);
setTimeout(() => {
newCalls = newCalls.filter((c) => _newCalls.includes(c));

BIN
web/static/call.wav Normal file

Binary file not shown.