HifiPlanet-Website/hifi/api/database/migration_page_loader.sql
Maaxxs 139d6c2c59 Add a toggleable page loading screen that waits for images
New app_settings.page_loader_enabled (default on) plus a checkbox in
Website-Einstellungen -> "Seiten-Ladeanzeige".

PageImageLoader.jsx wraps the routed page content (PublicLayout.jsx's
<Outlet />): the content stays mounted (so its images actually start
loading and any data-fetching effects still run) but is visually hidden
behind a spinner until every <img> currently in it has fired load/error.
Works generically across all public pages with no per-page changes,
since many pages (gallery/brand/model photos) only render their <img>
tags after an async API call resolves - a plain "scan once on mount"
check would find zero images and dismiss the loader immediately, so it
uses a MutationObserver to keep tracking newly-inserted images as data
arrives, and only dismisses once nothing has changed or finished loading
for a short settle window. A hard 8-second cap prevents the loader from
sticking forever if an image never resolves.

Overlay only covers the main content area (navbar/footer stay visible
and usable throughout), and the whole thing only mounts when the setting
is enabled - disabled, PublicLayout renders the page exactly as before.

Verified the backend setting end-to-end (migration, default value,
save/round-trip through SiteSettingsController). The loading behavior
itself is client-side timing logic I can't exercise in a real browser
here, so it's worth clicking through a few pages (especially
image-heavy ones like the gallery) before this goes live.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-09-11 11:47:53 +02:00

10 lines
498 B
SQL

USE hifi_shop;
-- An-/abschaltbarer Lade-Bildschirm: solange die Bilder einer Seite noch nicht fertig geladen
-- sind, wird statt des Inhalts ein Lade-Symbol gezeigt, damit nichts "einpoppt". Additiv,
-- nichts wird geloescht.
-- Hinweis: Auf der Live-Seite reicht stattdessen ein Klick auf "Datenbankstruktur aktualisieren"
-- unter Admin-Panel -> Einstellungen -> Datenbank.
ALTER TABLE app_settings
ADD COLUMN IF NOT EXISTS page_loader_enabled TINYINT(1) NOT NULL DEFAULT 1 AFTER site_font;