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