From 8c9f9df11cb8b0456f32c71f5ee9a17932b4ebcf Mon Sep 17 00:00:00 2001 From: David Frassi Date: Wed, 20 May 2026 16:09:30 +0200 Subject: [PATCH] =?UTF-8?q?fix:=20correzione=20filtro=20comunit=C3=A0=20al?= =?UTF-8?q?=20riavvio=20e=20priorit=C3=A0=20deduplicazione=20invertita?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Il background refresh al riavvio ora non riattiva il filtro comunità se comunitaEnabled è false nelle impostazioni, evitando di restringere silenziosamente il bacino dei canti. - Invertita la logica di deduplicazione: in caso di canto duplicato (validato + non validato), ora vince la versione validata (ufficiale del catalogo). --- src/app/home/home.page.ts | 9 ++++++--- src/app/services/comunita.service.ts | 5 +++++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/app/home/home.page.ts b/src/app/home/home.page.ts index c70b783..96ad8e0 100644 --- a/src/app/home/home.page.ts +++ b/src/app/home/home.page.ts @@ -124,7 +124,9 @@ export class HomePage implements OnDestroy { return comunitaIds.includes(c.id_canti) || comunitaIds.includes(c.id); }); - // Deduplicate: if a song exists in both validated and unvalidated lists, keep only the unvalidated/custom one + // Deduplicate: if a song exists in both validated and unvalidated lists, + // the NON-VALIDATED (parish-customized) version always takes precedence, + // so parishes can always personalize their songs even if never validated. const seen = new Map(); for (const canto of list) { const key = canto.id_canti || canto.id; @@ -132,8 +134,9 @@ export class HomePage implements OnDestroy { if (!existing) { seen.set(key, canto); } else { - // Precedence to unvalidated/custom version - if (canto.nonValidato) { + // Precedence to non-validated (parish custom) version: + // overwrite only if current entry is validated and new one is non-validated + if (!existing.nonValidato && canto.nonValidato) { seen.set(key, canto); } } diff --git a/src/app/services/comunita.service.ts b/src/app/services/comunita.service.ts index 554d724..32952ee 100644 --- a/src/app/services/comunita.service.ts +++ b/src/app/services/comunita.service.ts @@ -60,7 +60,12 @@ export class ComunitaService { if (savedCode) { this.comunitaCode.set(savedCode); // Run background refresh 1 second after startup to fetch any new custom canti or updates + // but only if the community feature is enabled in settings setTimeout(() => { + if (!this.settingsService.comunitaEnabled()) { + // Community is disabled: skip refresh to avoid re-enabling the filter + return; + } this.setComunitaCode(savedCode).catch(err => { console.warn('Failed background community refresh at startup:', err); });