Skip to content

Commit

Permalink
Fix setting default color mode in dev mode (#4616)
Browse files Browse the repository at this point in the history
* Fix setting default color mode in dev mode

Without this, the last_compiled_timestamp local storage never gets set because
it's always `null` until it gets set.

* test_client_storage: also pop `theme` key from next-themes
  • Loading branch information
masenf authored Jan 22, 2025
1 parent 1ca36fa commit 6d314d1
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,7 @@ export default function RadixThemesColorModeProvider({ children }) {
if (isDevMode) {
const lastCompiledTimeInLocalStorage =
localStorage.getItem("last_compiled_time");
if (
lastCompiledTimeInLocalStorage &&
lastCompiledTimeInLocalStorage !== lastCompiledTimeStamp
) {
if (lastCompiledTimeInLocalStorage !== lastCompiledTimeStamp) {
// on app startup, make sure the application color mode is persisted correctly.
setTheme(defaultColorMode);
localStorage.setItem("last_compiled_time", lastCompiledTimeStamp);
Expand Down
2 changes: 2 additions & 0 deletions tests/integration/test_client_storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,7 @@ def set_sub_sub(var: str, value: str):
assert not driver.get_cookies()
local_storage_items = local_storage.items()
local_storage_items.pop("last_compiled_time", None)
local_storage_items.pop("theme", None)
assert not local_storage_items

# set some cookies and local storage values
Expand Down Expand Up @@ -436,6 +437,7 @@ def set_sub_sub(var: str, value: str):

local_storage_items = local_storage.items()
local_storage_items.pop("last_compiled_time", None)
local_storage_items.pop("theme", None)
assert local_storage_items.pop(f"{sub_state_name}.l1") == "l1 value"
assert local_storage_items.pop(f"{sub_state_name}.l2") == "l2 value"
assert local_storage_items.pop("l3") == "l3 value"
Expand Down

0 comments on commit 6d314d1

Please sign in to comment.