fix: stabiliziraj navbar tranziciju i ukloni white splash

Zadrzava Navbar i ostale UI otoke kroz Astro tranzicije te sinkronizira aktivni path preko astro:page-load kako bi react-spring indikator animirao iz trenutne pozicije.

Uklanja bijeli splash pri promjeni stranice i prelasku teme postavljanjem html background boje inline, prilagodbom ThemeToggle logike i uklanjanjem body color tranzicije.

Dodano je i TTL kesiranje za dashboard/task dohvat kako bi se smanjili redundantni API pozivi pri navigaciji.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
mariomitte
2026-07-19 16:18:15 +02:00
parent fe7edf5643
commit bbdd02c9e9
7 changed files with 139 additions and 38 deletions

View File

@@ -21,6 +21,10 @@ export const $serviceRecords = atom([]);
export const $offlineQueueCount = atom(0);
export const $syncLog = atom([]);
// Timestamp posljednjeg uspješnog fetch-a — koristi se za TTL provjeru
let _lastDashboardFetchAt = 0;
const DASHBOARD_FETCH_TTL_MS = 30_000; // 30 sekundi
let dbPromise = null;
let syncListenerStarted = false;
let isSyncInProgress = false;
@@ -488,7 +492,13 @@ export async function ensureVehiclesCatalog() {
}
export async function fetchFleetDashboardData(options = {}) {
const { silent = false } = options;
const { silent = false, force = false } = options;
// Preskoči fetch ako su podaci svježi (unutar TTL), osim ako je force=true
if (!force && $workOrders.get().length > 0 && Date.now() - _lastDashboardFetchAt < DASHBOARD_FETCH_TTL_MS) {
return;
}
startOfflineSyncListeners();
if (!silent) $dashboardLoading.set(true);
$dashboardError.set(null);
@@ -511,6 +521,7 @@ export async function fetchFleetDashboardData(options = {}) {
$workOrders.set(Array.isArray(workOrders) ? workOrders : []);
$serviceRecords.set(Array.isArray(serviceRecords) ? serviceRecords : []);
$vehicles.set(normalizeCraneList(vehicles));
_lastDashboardFetchAt = Date.now();
await persistDashboardCache();
await processOfflineQueue();
} catch (error) {