Changeset 0a7ba90 in Klonkt


Ignore:
Timestamp:
06/27/2026 12:42:07 PM (2 months ago)
Author:
Robin Genis <roboburr@…>
Branches:
main
Children:
a78e051
Parents:
204bd74
Message:

fix(theme): a site renders in its own palette, not the logged-in viewer's

  • middleware/site.js — loadTheme prioritised the session user's palette over the site's, so a full page load (owner logged in) used the viewer's stale user.palette while htmx-nav used the site palette → the palette appeared to change on hard refresh. There is no per-user palette UI (user.palette is vestigial migration data); the site palette now always wins, matching the htmx pcmsNav path. Theme (dark/light) stays a per-user preference.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/middleware/site.js

    r204bd74 r0a7ba90  
    110110  const site = res.locals.site;
    111111 
    112   // Priority: user setting > site setting > default
    113   const palette = (user && PALETTES.includes(user.palette) ? user.palette : null)
    114                 || (site && PALETTES.includes(site.palette) ? site.palette : null)
     112  // A site always renders in ITS OWN palette, regardless of who is viewing. There is
     113  // no per-user palette UI (user.palette is vestigial/stale data from old migrations),
     114  // and the htmx pcmsNav path (render.js) already uses the site palette only — so reading
     115  // user.palette here made a full page load (owner logged in) flip to the viewer's stale
     116  // palette while htmx-nav kept the site's, i.e. "palette changes on hard refresh".
     117  const palette = (site && PALETTES.includes(site.palette) ? site.palette : null)
    115118                || 'klonkt';
    116  
     119
    117120  res.locals.palette = palette;
    118121  res.locals.theme = (user && ['dark','light'].includes(user.theme)) ? user.theme : 'dark';
Note: See TracChangeset for help on using the changeset viewer.