Feat: Add renotify field to UseWebNotificationOptions and ShowOptions

Uncommented the existing `renotify` code.
This commit is contained in:
Hector Candelaria 2024-07-31 21:47:38 -04:00
parent a5c67b4f7f
commit 0b6903fccc
2 changed files with 18 additions and 17 deletions

View file

@ -14,7 +14,7 @@ fn Demo() -> impl IntoView {
.title("Hello World from leptos-use") .title("Hello World from leptos-use")
.direction(NotificationDirection::Auto) .direction(NotificationDirection::Auto)
.language("en") .language("en")
// .renotify(true) .renotify(true)
.tag("test"), .tag("test"),
); );

View file

@ -28,6 +28,7 @@ use std::rc::Rc;
/// UseWebNotificationOptions::default() /// UseWebNotificationOptions::default()
/// .direction(NotificationDirection::Auto) /// .direction(NotificationDirection::Auto)
/// .language("en") /// .language("en")
/// .renotity(true)
/// .tag("test"), /// .tag("test"),
/// ); /// );
/// ///
@ -227,8 +228,7 @@ impl From<NotificationDirection> for web_sys::NotificationDirection {
/// See [MDN Docs](https://developer.mozilla.org/en-US/docs/Web/API/notification) for more info. /// See [MDN Docs](https://developer.mozilla.org/en-US/docs/Web/API/notification) for more info.
/// ///
/// The following implementations are missing: /// The following implementations are missing:
/// - `renotify` /// - `vibrate`
/// - `vibrate`
/// - `silent` /// - `silent`
/// - `image` /// - `image`
#[derive(DefaultBuilder, Clone)] #[derive(DefaultBuilder, Clone)]
@ -268,10 +268,11 @@ pub struct UseWebNotificationOptions {
/// user clicks or dismisses it, rather than closing automatically. /// user clicks or dismisses it, rather than closing automatically.
require_interaction: bool, require_interaction: bool,
// /// A boolean value specifying whether the user should be notified after a new notification replaces an old one. /// A boolean value specifying whether the user should be notified after a new notification replaces an old one.
// /// The default is `false`, which means they won't be notified. If `true`, then `tag` also must be set. /// The default is `false`, which means they won't be notified. If `true`, then `tag` also must be set.
// #[builder(into)] #[builder(into)]
// renotify: bool, renotify: bool,
/// Called when the user clicks on displayed `Notification`. /// Called when the user clicks on displayed `Notification`.
on_click: Rc<dyn Fn(web_sys::Event)>, on_click: Rc<dyn Fn(web_sys::Event)>,
@ -296,7 +297,7 @@ impl Default for UseWebNotificationOptions {
tag: None, tag: None,
icon: None, icon: None,
require_interaction: false, require_interaction: false,
// renotify: false, renotify: false,
on_click: Rc::new(|_| {}), on_click: Rc::new(|_| {}),
on_close: Rc::new(|_| {}), on_close: Rc::new(|_| {}),
on_error: Rc::new(|_| {}), on_error: Rc::new(|_| {}),
@ -311,8 +312,8 @@ impl From<&UseWebNotificationOptions> for web_sys::NotificationOptions {
web_sys_options web_sys_options
.dir(options.direction.into()) .dir(options.direction.into())
.require_interaction(options.require_interaction); .require_interaction(options.require_interaction)
// .renotify(options.renotify); .renotify(options.renotify);
if let Some(body) = &options.body { if let Some(body) = &options.body {
web_sys_options.body(body); web_sys_options.body(body);
@ -380,10 +381,10 @@ pub struct ShowOptions {
/// user clicks or dismisses it, rather than closing automatically. /// user clicks or dismisses it, rather than closing automatically.
#[builder(into)] #[builder(into)]
require_interaction: Option<bool>, require_interaction: Option<bool>,
// /// A boolean value specifying whether the user should be notified after a new notification replaces an old one. /// A boolean value specifying whether the user should be notified after a new notification replaces an old one.
// /// The default is `false`, which means they won't be notified. If `true`, then `tag` also must be set. /// The default is `false`, which means they won't be notified. If `true`, then `tag` also must be set.
// #[builder(into)] #[builder(into)]
// renotify: Option<bool>, renotify: Option<bool>,
} }
#[cfg(not(feature = "ssr"))] #[cfg(not(feature = "ssr"))]
@ -413,9 +414,9 @@ impl ShowOptions {
options.tag(tag); options.tag(tag);
} }
// if let Some(renotify) = &self.renotify { if let Some(renotify) = self.renotify {
// options.renotify(renotify); options.renotify(renotify);
// } }
} }
} }