mirror of
https://github.com/adoyle0/leptos-use.git
synced 2025-02-02 10:54:15 -05:00
Feat: Add renotify
field to UseWebNotificationOptions
and ShowOptions
Uncommented the existing `renotify` code.
This commit is contained in:
parent
a5c67b4f7f
commit
0b6903fccc
2 changed files with 18 additions and 17 deletions
|
@ -14,7 +14,7 @@ fn Demo() -> impl IntoView {
|
|||
.title("Hello World from leptos-use")
|
||||
.direction(NotificationDirection::Auto)
|
||||
.language("en")
|
||||
// .renotify(true)
|
||||
.renotify(true)
|
||||
.tag("test"),
|
||||
);
|
||||
|
||||
|
|
|
@ -28,6 +28,7 @@ use std::rc::Rc;
|
|||
/// UseWebNotificationOptions::default()
|
||||
/// .direction(NotificationDirection::Auto)
|
||||
/// .language("en")
|
||||
/// .renotity(true)
|
||||
/// .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.
|
||||
///
|
||||
/// The following implementations are missing:
|
||||
/// - `renotify`
|
||||
/// - `vibrate`
|
||||
/// - `vibrate`
|
||||
/// - `silent`
|
||||
/// - `image`
|
||||
#[derive(DefaultBuilder, Clone)]
|
||||
|
@ -268,10 +268,11 @@ pub struct UseWebNotificationOptions {
|
|||
/// user clicks or dismisses it, rather than closing automatically.
|
||||
require_interaction: bool,
|
||||
|
||||
// /// 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.
|
||||
// #[builder(into)]
|
||||
// renotify: bool,
|
||||
/// 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.
|
||||
#[builder(into)]
|
||||
renotify: bool,
|
||||
|
||||
/// Called when the user clicks on displayed `Notification`.
|
||||
on_click: Rc<dyn Fn(web_sys::Event)>,
|
||||
|
||||
|
@ -296,7 +297,7 @@ impl Default for UseWebNotificationOptions {
|
|||
tag: None,
|
||||
icon: None,
|
||||
require_interaction: false,
|
||||
// renotify: false,
|
||||
renotify: false,
|
||||
on_click: Rc::new(|_| {}),
|
||||
on_close: Rc::new(|_| {}),
|
||||
on_error: Rc::new(|_| {}),
|
||||
|
@ -311,8 +312,8 @@ impl From<&UseWebNotificationOptions> for web_sys::NotificationOptions {
|
|||
|
||||
web_sys_options
|
||||
.dir(options.direction.into())
|
||||
.require_interaction(options.require_interaction);
|
||||
// .renotify(options.renotify);
|
||||
.require_interaction(options.require_interaction)
|
||||
.renotify(options.renotify);
|
||||
|
||||
if let Some(body) = &options.body {
|
||||
web_sys_options.body(body);
|
||||
|
@ -380,10 +381,10 @@ pub struct ShowOptions {
|
|||
/// user clicks or dismisses it, rather than closing automatically.
|
||||
#[builder(into)]
|
||||
require_interaction: Option<bool>,
|
||||
// /// 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.
|
||||
// #[builder(into)]
|
||||
// renotify: Option<bool>,
|
||||
/// 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.
|
||||
#[builder(into)]
|
||||
renotify: Option<bool>,
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "ssr"))]
|
||||
|
@ -413,9 +414,9 @@ impl ShowOptions {
|
|||
options.tag(tag);
|
||||
}
|
||||
|
||||
// if let Some(renotify) = &self.renotify {
|
||||
// options.renotify(renotify);
|
||||
// }
|
||||
if let Some(renotify) = self.renotify {
|
||||
options.renotify(renotify);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue