"Enhance loading experience and optimize theme application

Added a fallback background and a preload lock for smoother loading transitions. Improved theme application by applying it prior to React rendering and removed theme flash. Adjusted Service Worker registration for better performance and reliability."
This commit is contained in:
2026-02-06 18:44:44 +01:00
parent 070057afb3
commit 7c4754e506
2 changed files with 55 additions and 12 deletions

View File

@@ -4,6 +4,7 @@ import App from "./App.jsx";
import { applyTheme, DEFAULT_THEME_KEY } from "./styles/themes";
import { registerSW } from "virtual:pwa-register";
// ✅ Theme VOR React setzen (kein Theme-Flash)
try {
const key = localStorage.getItem("hpTheme:guest") || DEFAULT_THEME_KEY;
applyTheme(key);
@@ -11,12 +12,17 @@ try {
applyTheme(DEFAULT_THEME_KEY);
}
// ✅ Preload Unlock (nach Theme!)
document.body.classList.remove("preload");
document.body.classList.add("ready");
ReactDOM.createRoot(document.getElementById("root")).render(<App />);
registerSW({ immediate: true });
// ✅ Service Worker NUR EINMAL registrieren
const updateSW = registerSW({
immediate: true,
onNeedRefresh() {
updateSW(true); // sofort neue Version aktivieren
window.location.reload();
},
});
immediate: true,
onNeedRefresh() {
updateSW(true);
window.location.reload();
},
});