Files
kandev/apps/web/lib/desktop/native-notification-client.ts
T
2026-07-15 23:19:00 +01:00

24 lines
695 B
TypeScript

import { createTauriInvokeTransport } from "./tauri-event-transport";
export type NativeNotificationRequest = {
eventId: string;
title: string;
body: string;
taskId: string;
sessionId?: string | null;
};
type NativeNotificationResult = "shown" | "duplicate" | "permission-denied";
const transport = createTauriInvokeTransport();
export const nativeNotifications = {
isAvailable: transport.isAvailable,
show(request: NativeNotificationRequest): Promise<NativeNotificationResult> {
if (!transport.isAvailable()) return Promise.resolve("duplicate");
return transport.invoke("show_native_notification", {
request,
}) as Promise<NativeNotificationResult>;
},
};