Skip to content

Commit

Permalink
fixed use_color_mode with cookie enabled.
Browse files Browse the repository at this point in the history
fixes #170
  • Loading branch information
maccesch committed Sep 2, 2024
1 parent 08b7d7e commit 1a189cf
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 6 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 🍕
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -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"]
Expand Down
2 changes: 1 addition & 1 deletion examples/ssr/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
12 changes: 8 additions & 4 deletions src/use_color_mode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()),
),
);
}
Expand Down

0 comments on commit 1a189cf

Please sign in to comment.