From e5da0301de046d2f55f196aad24fb008126ce40a Mon Sep 17 00:00:00 2001 From: AI Assistant Date: Thu, 26 Mar 2026 22:07:15 +0200 Subject: [PATCH] fix(parcel-sync): freshness check only on primary layers (terenuri + cladiri) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Secondary layers (LIMITE_INTRAV, LIMITE_UAT) are synced once and rarely change. They were causing permanent "1 vechi" badge even after fresh sync of terenuri+cladiri. Now canExportLocal and the freshness badge only consider TERENURI_ACTIVE and CLADIRI_ACTIVE — the layers that actually matter for export. Co-Authored-By: Claude Opus 4.6 (1M context) --- .../components/tabs/export-tab.tsx | 31 ++++++++++++------- 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/src/modules/parcel-sync/components/tabs/export-tab.tsx b/src/modules/parcel-sync/components/tabs/export-tab.tsx index 08e390b..33b0f33 100644 --- a/src/modules/parcel-sync/components/tabs/export-tab.tsx +++ b/src/modules/parcel-sync/components/tabs/export-tab.tsx @@ -143,12 +143,18 @@ export function ExportTab({ const dbTotalFeatures = dbLayersSummary.reduce((sum, l) => sum + l.count, 0); + // Only check primary layers (terenuri + cladiri) for freshness — + // secondary layers (intravilan, limite UAT) don't affect export readiness + const PRIMARY_LAYERS = ["TERENURI_ACTIVE", "CLADIRI_ACTIVE"]; + const primaryLayers = dbLayersSummary.filter((l) => + PRIMARY_LAYERS.includes(l.id), + ); const allFresh = - dbLayersSummary.length > 0 && dbLayersSummary.every((l) => l.isFresh); + primaryLayers.length > 0 && primaryLayers.every((l) => l.isFresh); const hasData = dbTotalFeatures > 0; const canExportLocal = allFresh && hasData; - const oldestSyncDate = dbLayersSummary.reduce( + const oldestSyncDate = primaryLayers.reduce( (oldest, l) => { if (!l.lastSynced) return oldest; if (!oldest || l.lastSynced < oldest) return l.lastSynced; @@ -620,21 +626,22 @@ export function ExportTab({ layere {(() => { - const freshCount = dbLayersSummary.filter( + // Check freshness only for primary layers (terenuri + cladiri) + const freshCount = primaryLayers.filter( (l) => l.isFresh, ).length; - const staleCount = dbLayersSummary.length - freshCount; - const oldestSync = dbLayersSummary.reduce( - (oldest, l) => { - if (!l.lastSynced) return oldest; - if (!oldest || l.lastSynced < oldest) return l.lastSynced; - return oldest; + const staleCount = primaryLayers.length - freshCount; + const newestSync = primaryLayers.reduce( + (newest, l) => { + if (!l.lastSynced) return newest; + if (!newest || l.lastSynced > newest) return l.lastSynced; + return newest; }, null as Date | null, ); return ( <> - {staleCount === 0 ? ( + {staleCount === 0 && primaryLayers.length > 0 ? ( )} - {oldestSync && ( + {newestSync && ( - Ultima sincronizare: {relativeTime(oldestSync)} + Ultima sincronizare: {relativeTime(newestSync)} )}