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/),
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
### Fix 🍕

View file

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

View file

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

View file

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