Files
logseq/src/main/frontend
scheinriese c540a92ffa fix: avatar fallback colors update instantly on theme toggle
The avatar fallback hex (background + text) is computed in JS by
`avatar-fallback-style` → `colors/read-bg-var` → `getComputedStyle`,
so its output is a snapshot of the current theme's CSS variables at
render time. The result is written into the element's inline style.
On `tt` (theme toggle) the snapshot stayed frozen until something
unrelated triggered a re-render, leaving avatars carrying the wrong
theme's tone — too bright in dark mode, too dark in light mode.

Two coordinated changes:

1. state/set-theme-mode! now stamps `data-theme` + body classes
   synchronously *before* mutating `:ui/theme`. The previous flow
   left the DOM update inside theme.cljs's `use-effect!`, which
   fires AFTER React's render commit — so subscribers re-rendering
   on the state change still read the old theme's CSS vars. The
   theme.cljs effect remains as an idempotent safety net plus the
   side effects (plugin hook, custom-theme application).

2. `avatar-image-cp` and `get-node-icon-cp` subscribe to `:ui/theme`.
   The subscribed value is discarded — the subscription's job is to
   tick Rum's dependency graph so the component re-renders on toggle
   and recomputes `avatar-fallback-style` against the (now fresh)
   CSS variables. Combined with the synchronous DOM update above,
   the read-bg-var snapshot is correct on the first render after
   toggle, no second tick required.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-12 17:31:42 +02:00
..
2026-03-05 16:53:46 +08:00
2026-03-13 21:00:57 +08:00
2026-03-13 17:44:54 +08:00
2026-03-12 17:51:23 +08:00