fixed use_color_mode with cookie enabled.

fixes #170
This commit is contained in:
Maccesch 2024-09-02 18:21:21 +01:00
parent 08b7d7e932
commit 1a189cf7a4
4 changed files with 16 additions and 6 deletions

View file

@ -3,6 +3,12 @@
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), 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). and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [0.13.3] - 2024-09-02
### Fix 🍕
- Fixed `use_color_mode` with cookies enabled
## [0.13.2] - 2024-09-02 ## [0.13.2] - 2024-09-02
### Fix 🍕 ### Fix 🍕

View file

@ -1,6 +1,6 @@
[package] [package]
name = "leptos-use" name = "leptos-use"
version = "0.13.2" version = "0.13.3"
edition = "2021" edition = "2021"
authors = ["Marc-Stefan Cassola"] authors = ["Marc-Stefan Cassola"]
categories = ["gui", "web-programming"] categories = ["gui", "web-programming"]

View file

@ -8,7 +8,7 @@ crate-type = ["cdylib", "rlib"]
[dependencies] [dependencies]
axum = { version = "0.7", optional = true } axum = { version = "0.7", optional = true }
codee.workspace = true codee = "0.2"
console_error_panic_hook = "0.1" console_error_panic_hook = "0.1"
console_log = "1" console_log = "1"
cfg-if = "1" cfg-if = "1"

View file

@ -215,11 +215,15 @@ where
let _ = sync_signal_with_options( let _ = sync_signal_with_options(
(cookie, set_cookie), (cookie, set_cookie),
(store, set_store), (store, set_store),
SyncSignalOptions::with_transforms( SyncSignalOptions::with_assigns(
move |cookie: &Option<ColorMode>| { move |store: &mut ColorMode, cookie: &Option<ColorMode>| {
cookie.clone().unwrap_or_else(|| store.get_untracked()) if let Some(cookie) = cookie {
*store = cookie.clone();
}
},
move |cookie: &mut Option<ColorMode>, store: &ColorMode| {
*cookie = Some(store.clone())
}, },
move |store: &ColorMode| Some(store.clone()),
), ),
); );
} }