fix: correzione filtro comunità al riavvio e priorità deduplicazione invertita

- 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).
This commit is contained in:
David Frassi
2026-05-20 16:09:30 +02:00
parent 98fc5e9c97
commit 8c9f9df11c
2 changed files with 11 additions and 3 deletions
+6 -3
View File
@@ -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<number | string, any>();
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);
}
}