feat(calendar): add event notifications with alert evaluation

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.
This commit is contained in:
Matthieu MALVACHE
2026-02-16 23:49:35 +01:00
committed by Matthieu MALVACHE
parent 73612313c0
commit fea21d5bcd
24 changed files with 949 additions and 47 deletions
+4 -1
View File
@@ -1,6 +1,7 @@
import { notFound } from "next/navigation";
import { IntlProvider } from "@/components/providers/intl-provider";
import { ThemeProvider } from "@/components/providers/theme-provider";
import { CalendarAlertProvider } from "@/components/providers/calendar-alert-provider";
import { locales } from "@/i18n/routing";
export default async function LocaleLayout({
@@ -24,7 +25,9 @@ export default async function LocaleLayout({
return (
<IntlProvider locale={locale} messages={messages}>
<ThemeProvider>
{children}
<CalendarAlertProvider>
{children}
</CalendarAlertProvider>
</ThemeProvider>
</IntlProvider>
);
+1 -22
View File
@@ -18,6 +18,7 @@ import { useUIStore } from "@/stores/ui-store";
import { useDeviceDetection } from "@/hooks/use-media-query";
import { useKeyboardShortcuts } from "@/hooks/use-keyboard-shortcuts";
import { debug } from "@/lib/debug";
import { playNotificationSound } from "@/lib/notification-sound";
import { cn } from "@/lib/utils";
import {
ErrorBoundary,
@@ -87,28 +88,6 @@ export default function Home() {
advancedSearch,
} = useEmailStore();
// Play notification sound for new emails
const playNotificationSound = () => {
try {
// Use Web Audio API for a simple notification beep
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; // Hz
oscillator.type = 'sine';
gainNode.gain.value = 0.1; // Low volume
oscillator.start();
oscillator.stop(audioContext.currentTime + 0.15); // Short beep
} catch (e) {
debug.log('Could not play notification sound:', e);
}
};
// Keyboard shortcuts handlers
const keyboardHandlers = useMemo(() => ({
onNextEmail: () => {