From 1da9951edc47911ff3b8b4bb7ea56aefbe0bbf24 Mon Sep 17 00:00:00 2001 From: keiko233 Date: Thu, 29 Feb 2024 10:03:41 +0800 Subject: [PATCH] feat: add useMessage hook --- src/hooks/use-notification.ts | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/hooks/use-notification.ts b/src/hooks/use-notification.ts index 14cf180a78..a25c5c5f39 100644 --- a/src/hooks/use-notification.ts +++ b/src/hooks/use-notification.ts @@ -6,6 +6,8 @@ import { requestPermission, sendNotification, } from "@tauri-apps/api/notification"; +import { MessageDialogOptions, message } from "@tauri-apps/api/dialog"; + let permissionGranted: boolean | null = null; let portable: boolean | null = null; @@ -57,3 +59,10 @@ export const useNotification = async ({ if (body) options.body = body; sendNotification(options); }; + +export const useMessage = async ( + value: string, + options?: string | MessageDialogOptions | undefined, +) => { + await message(value, options); +};