Add client-side calendar event notification system that evaluates JMAP CalendarEventAlert triggers and displays toast notifications when alert times are reached. Includes configurable notification sound, acknowledged alert persistence, and proactive event fetching for background alerts. Also mounts ToastContainer globally to fix silent toast failures.
23 lines
728 B
TypeScript
23 lines
728 B
TypeScript
import { debug } from '@/lib/debug';
|
|
|
|
export function playNotificationSound() {
|
|
try {
|
|
const audioContext = new (window.AudioContext || (window as unknown as { webkitAudioContext: typeof AudioContext }).webkitAudioContext)();
|
|
const oscillator = audioContext.createOscillator();
|
|
const gainNode = audioContext.createGain();
|
|
|
|
oscillator.connect(gainNode);
|
|
gainNode.connect(audioContext.destination);
|
|
|
|
oscillator.frequency.value = 800;
|
|
oscillator.type = 'sine';
|
|
gainNode.gain.value = 0.1;
|
|
|
|
oscillator.start();
|
|
oscillator.stop(audioContext.currentTime + 0.15);
|
|
oscillator.onended = () => audioContext.close();
|
|
} catch (e) {
|
|
debug.log('Could not play notification sound:', e);
|
|
}
|
|
}
|