feat: add sound
This commit is contained in:
@@ -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
BIN
web/static/call.wav
Normal file
Binary file not shown.
Reference in New Issue
Block a user