Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions desktop/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
</style>
<script>
(() => {
var cached, bg, parsed;
var cached, bg, parsed, vars, key;
try {
cached = window.localStorage.getItem("buzz-theme-cache");
if (!cached) {
Expand All @@ -38,7 +38,21 @@
return;
}
parsed = JSON.parse(cached);
bg = parsed.vars["--background"];
// Seed the full cached vars map on <html> before paint, mirroring
// ThemeProvider.applyCachedVars(). The loading gate's grainient reads
// --chart-*, --primary, --foreground, etc. — not just --background —
// so seeding only --background would let a cached non-Latte theme
// (houston/buzz/custom) paint the splash from the static Catppuccin
// :root vars until React mounts.
vars = parsed.vars;
if (vars) {
for (key in vars) {
if (Object.hasOwn(vars, key)) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Avoid Object.hasOwn in the untranspiled boot script

In WebViews that only provide the ES2020 baseline, this throws because Object.hasOwn is ES2022, and this classic inline script is not transpiled by the desktop build. When a user has cached theme vars on one of those WebViews, the throw is caught before any cached vars, background color, or light/dark class are applied, so the cold-boot FOUC this patch is meant to fix comes back. Use an ES2020-safe check such as Object.prototype.hasOwnProperty.call(vars, key) or iterate Object.entries(vars) instead.

Useful? React with 👍 / 👎.

document.documentElement.style.setProperty(key, vars[key]);
}
}
}
bg = vars && vars["--background"];
if (bg) document.documentElement.style.backgroundColor = `hsl(${bg})`;
// Match the cached light/dark class so themed vars resolve correctly
// before ThemeProvider mounts.
Expand Down
Loading