From 8c2beb814da171ecaf295ae7437d711720a8f75f Mon Sep 17 00:00:00 2001 From: Maccesch Date: Tue, 24 Oct 2023 00:44:23 -0500 Subject: [PATCH] release 0.8.0 --- .idea/leptos-use.iml | 2 ++ CHANGELOG.md | 6 ++-- Cargo.toml | 2 +- README.md | 12 ++++---- docs/book/src/introduction.md | 2 +- examples/use_web_notification/src/main.rs | 13 +++----- src/lib.rs | 4 +-- src/use_infinite_scroll.rs | 37 +++++++++++------------ src/use_web_notification.rs | 12 ++++---- 9 files changed, 44 insertions(+), 46 deletions(-) diff --git a/.idea/leptos-use.iml b/.idea/leptos-use.iml index bb3717d..830c9eb 100644 --- a/.idea/leptos-use.iml +++ b/.idea/leptos-use.iml @@ -58,6 +58,8 @@ + + diff --git a/CHANGELOG.md b/CHANGELOG.md index 1585ee9..be42cc6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,13 +3,13 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). -## [Unreleased] - +## [0.8.0] - 2023-10-24 ### New Functions 🚀 -- `use_web_notification` - @centershocks44 +- `use_web_notification` (thanks to @centershocks44) - `use_infinite_scroll` -- `use_service_worker` - @lpotthast +- `use_service_worker` (thanks to @lpotthast) ### Breaking Changes 🛠 diff --git a/Cargo.toml b/Cargo.toml index 0805adb..9b19c02 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "leptos-use" -version = "0.7.2" +version = "0.8.0" edition = "2021" authors = ["Marc-Stefan Cassola"] categories = ["gui", "web-programming"] diff --git a/README.md b/README.md index f398a8d..e2771df 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,7 @@ Crates.io SSR Docs & Demos - 59 Functions + 62 Functions


@@ -87,8 +87,8 @@ This will create the function file in the src directory, scaffold an example dir ## Leptos compatibility -| Crate version | Compatible Leptos version | -|---------------|---------------------------| -| <= 0.3 | 0.3 | -| 0.4, 0.5, 0.6 | 0.4 | -| 0.7 | 0.5 | +| Crate version | Compatible Leptos version | +|----------------|---------------------------| +| <= 0.3 | 0.3 | +| 0.4, 0.5, 0.6 | 0.4 | +| 0.7, 0.8 | 0.5 | diff --git a/docs/book/src/introduction.md b/docs/book/src/introduction.md index 5381e52..d9a1704 100644 --- a/docs/book/src/introduction.md +++ b/docs/book/src/introduction.md @@ -12,6 +12,6 @@ Crates.io SSR Docs & Demos - 59 Functions + 62 Functions

\ No newline at end of file diff --git a/examples/use_web_notification/src/main.rs b/examples/use_web_notification/src/main.rs index b9045bc..bc717bb 100644 --- a/examples/use_web_notification/src/main.rs +++ b/examples/use_web_notification/src/main.rs @@ -24,23 +24,20 @@ fn Demo() -> impl IntoView { view! {
-

- Supported: -

+

Supported:

The Notification Web API is not supported in your browser. + fallback=|| { + view! {
The Notification Web API is not supported in your browser.
} } > + + }>Show Notification
} } diff --git a/src/lib.rs b/src/lib.rs index 8f48103..a9700c1 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -25,7 +25,6 @@ mod is_none; mod is_ok; mod is_some; mod on_click_outside; -mod use_web_notification; mod signal_debounced; mod signal_throttled; mod use_active_element; @@ -62,6 +61,7 @@ mod use_supported; mod use_throttle_fn; mod use_timestamp; mod use_to_string; +mod use_web_notification; mod use_websocket; mod use_window; mod use_window_focus; @@ -77,7 +77,6 @@ pub use is_none::*; pub use is_ok::*; pub use is_some::*; pub use on_click_outside::*; -pub use use_web_notification::*; pub use signal_debounced::*; pub use signal_throttled::*; pub use use_active_element::*; @@ -114,6 +113,7 @@ pub use use_supported::*; pub use use_throttle_fn::*; pub use use_timestamp::*; pub use use_to_string::*; +pub use use_web_notification::*; pub use use_websocket::*; pub use use_window::*; pub use use_window_focus::*; diff --git a/src/use_infinite_scroll.rs b/src/use_infinite_scroll.rs index 8153c4f..d02d97d 100644 --- a/src/use_infinite_scroll.rs +++ b/src/use_infinite_scroll.rs @@ -150,26 +150,25 @@ where scroll_width <= client_width }; - if state.arrived_state.get_untracked().get_direction(direction) || is_narrower { - if !is_loading.get_untracked() { - set_loading.set(true); + if (state.arrived_state.get_untracked().get_direction(direction) || is_narrower) + && !is_loading.get_untracked() + { + set_loading.set(true); - let state = state.clone(); - let measure = measure.clone(); - spawn_local(async move { - join!( - on_load_more.with_value(|f| f(state)), - sleep(Duration::from_millis(interval as u64)) - ); + let measure = measure.clone(); + spawn_local(async move { + join!( + on_load_more.with_value(|f| f(state)), + sleep(Duration::from_millis(interval as u64)) + ); - set_loading.set(false); - sleep(Duration::ZERO).await; - measure(); - if let Some(check_and_load) = check_and_load.get_value() { - check_and_load(); - } - }); - } + set_loading.set(false); + sleep(Duration::ZERO).await; + measure(); + if let Some(check_and_load) = check_and_load.get_value() { + check_and_load(); + } + }); } } } @@ -178,7 +177,7 @@ where let _ = watch( move || is_element_visible.get(), move |visible, prev_visible, _| { - if *visible && !prev_visible.map(|v| *v).unwrap_or_default() { + if *visible && !prev_visible.copied().unwrap_or_default() { measure(); } }, diff --git a/src/use_web_notification.rs b/src/use_web_notification.rs index 92a7024..98c66ef 100644 --- a/src/use_web_notification.rs +++ b/src/use_web_notification.rs @@ -140,7 +140,7 @@ pub fn use_web_notification_with_options( set_permission.set(request_web_notification_permission().await); }); - on_cleanup(close.clone()); + on_cleanup(close); // Use close() to remove a notification that is no longer relevant to to // the user (e.g.the user already read the notification on the webpage). @@ -157,7 +157,7 @@ pub fn use_web_notification_with_options( } UseWebNotificationReturn { - is_supported: is_supported.into(), + is_supported, notification: notification.into(), show, close, @@ -274,19 +274,19 @@ impl From<&UseWebNotificationOptions> for web_sys::NotificationOptions { // .renotify(options.renotify); if let Some(body) = &options.body { - web_sys_options.body(&body); + web_sys_options.body(body); } if let Some(icon) = &options.icon { - web_sys_options.icon(&icon); + web_sys_options.icon(icon); } if let Some(language) = &options.language { - web_sys_options.lang(&language); + web_sys_options.lang(language); } if let Some(tag) = &options.tag { - web_sys_options.tag(&tag); + web_sys_options.tag(tag); } web_sys_options