feat: deduplicazione lista canti comunità con precedenza al canto non validato
- In HomePage, dopo il filtro per comunità, viene applicata una deduplicazione basata sull'id_canti: se lo stesso canto esiste sia nella lista globale (validato) sia in quella parrocchiale (non validato), viene mantenuto solo quello non validato. - In HomePage.findCanto(), Player, Display e Playlist: quando il filtro comunità è attivo, la ricerca di un canto per ID dà precedenza alla lista comunitaCantiPersonali rispetto al catalogo globale. - In PlaylistPage: aggiunta gestione completa delle sorgenti (global, my-canti, canti personali comunità) con stesso ordine di priorità.
This commit is contained in:
@@ -123,6 +123,22 @@ export class HomePage implements OnDestroy {
|
|||||||
list = list.filter(c => {
|
list = list.filter(c => {
|
||||||
return comunitaIds.includes(c.id_canti) || comunitaIds.includes(c.id);
|
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
|
||||||
|
const seen = new Map<number | string, any>();
|
||||||
|
for (const canto of list) {
|
||||||
|
const key = canto.id_canti || canto.id;
|
||||||
|
const existing = seen.get(key);
|
||||||
|
if (!existing) {
|
||||||
|
seen.set(key, canto);
|
||||||
|
} else {
|
||||||
|
// Precedence to unvalidated/custom version
|
||||||
|
if (canto.nonValidato) {
|
||||||
|
seen.set(key, canto);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
list = Array.from(seen.values());
|
||||||
|
|
||||||
// Sort list by community song number (num_canto) ASC!
|
// Sort list by community song number (num_canto) ASC!
|
||||||
const cantiInfo = this.comunitaService.comunitaCantiInfo();
|
const cantiInfo = this.comunitaService.comunitaCantiInfo();
|
||||||
@@ -332,6 +348,10 @@ export class HomePage implements OnDestroy {
|
|||||||
}
|
}
|
||||||
|
|
||||||
findCanto(id: string) {
|
findCanto(id: string) {
|
||||||
|
if (this.comunitaService.comunitaCode() && this.comunitaService.isFilterActive()) {
|
||||||
|
const personal = this.comunitaService.comunitaCantiPersonali().find(c => c.id === id);
|
||||||
|
if (personal) return personal;
|
||||||
|
}
|
||||||
return [
|
return [
|
||||||
...this.cantiService.canti(),
|
...this.cantiService.canti(),
|
||||||
...this.myCantiService.myCanti(),
|
...this.myCantiService.myCanti(),
|
||||||
|
|||||||
@@ -63,7 +63,13 @@ export class DisplayPage implements OnInit, OnDestroy {
|
|||||||
const allCanti = this.cantiService.canti();
|
const allCanti = this.cantiService.canti();
|
||||||
const comunitaCantiPers = this.comunitaService.comunitaCantiPersonali();
|
const comunitaCantiPers = this.comunitaService.comunitaCantiPersonali();
|
||||||
if (id) {
|
if (id) {
|
||||||
let found = allCanti.find(c => c.id === id);
|
let found: any = null;
|
||||||
|
if (this.comunitaService.comunitaCode() && this.comunitaService.isFilterActive()) {
|
||||||
|
found = comunitaCantiPers.find(c => c.id === id);
|
||||||
|
}
|
||||||
|
if (!found) {
|
||||||
|
found = allCanti.find(c => c.id === id);
|
||||||
|
}
|
||||||
if (!found) {
|
if (!found) {
|
||||||
found = comunitaCantiPers.find(c => c.id === id);
|
found = comunitaCantiPers.find(c => c.id === id);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -163,7 +163,13 @@ export class PlayerPage implements OnInit, AfterViewInit, OnDestroy {
|
|||||||
const comunitaCantiPers = this.comunitaService.comunitaCantiPersonali();
|
const comunitaCantiPers = this.comunitaService.comunitaCantiPersonali();
|
||||||
|
|
||||||
if (id) {
|
if (id) {
|
||||||
let found = allCanti.find(c => c.id === id);
|
let found: any = null;
|
||||||
|
if (this.comunitaService.comunitaCode() && this.comunitaService.isFilterActive()) {
|
||||||
|
found = comunitaCantiPers.find(c => c.id === id);
|
||||||
|
}
|
||||||
|
if (!found) {
|
||||||
|
found = allCanti.find(c => c.id === id);
|
||||||
|
}
|
||||||
if (!found) {
|
if (!found) {
|
||||||
found = myCantiList.find(c => c.id === id);
|
found = myCantiList.find(c => c.id === id);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import { Component, inject, computed } from '@angular/core';
|
|||||||
import { PlaylistService } from '../../services/playlist.service';
|
import { PlaylistService } from '../../services/playlist.service';
|
||||||
import { CantiService } from '../../services/canti.service';
|
import { CantiService } from '../../services/canti.service';
|
||||||
import { ComunitaService } from '../../services/comunita.service';
|
import { ComunitaService } from '../../services/comunita.service';
|
||||||
|
import { MyCantiService } from '../../services/my-canti.service';
|
||||||
import { CdkDragDrop, moveItemInArray } from '@angular/cdk/drag-drop';
|
import { CdkDragDrop, moveItemInArray } from '@angular/cdk/drag-drop';
|
||||||
import { AlertController, ToastController, ModalController } from '@ionic/angular';
|
import { AlertController, ToastController, ModalController } from '@ionic/angular';
|
||||||
import { Router } from '@angular/router';
|
import { Router } from '@angular/router';
|
||||||
@@ -16,13 +17,34 @@ export class PlaylistPage {
|
|||||||
public playlistService = inject(PlaylistService);
|
public playlistService = inject(PlaylistService);
|
||||||
public cantiService = inject(CantiService);
|
public cantiService = inject(CantiService);
|
||||||
public comunitaService = inject(ComunitaService);
|
public comunitaService = inject(ComunitaService);
|
||||||
|
public myCantiService = inject(MyCantiService);
|
||||||
private alertCtrl = inject(AlertController);
|
private alertCtrl = inject(AlertController);
|
||||||
private toastCtrl = inject(ToastController);
|
private toastCtrl = inject(ToastController);
|
||||||
private router = inject(Router);
|
private router = inject(Router);
|
||||||
|
|
||||||
public selectedSongs = computed(() => {
|
public selectedSongs = computed(() => {
|
||||||
const ids = Array.from(this.playlistService.selectedIds());
|
const ids = Array.from(this.playlistService.selectedIds());
|
||||||
return ids.map(id => this.cantiService.canti().find(c => c.id === id)).filter(c => !!c);
|
const allCanti = this.cantiService.canti();
|
||||||
|
const myCantiList = this.myCantiService.myCanti();
|
||||||
|
const comunitaCantiPers = this.comunitaService.comunitaCantiPersonali();
|
||||||
|
const communityActive = this.comunitaService.comunitaCode() && this.comunitaService.isFilterActive();
|
||||||
|
|
||||||
|
return ids.map(id => {
|
||||||
|
let found: any = null;
|
||||||
|
if (communityActive) {
|
||||||
|
found = comunitaCantiPers.find(c => c.id === id);
|
||||||
|
}
|
||||||
|
if (!found) {
|
||||||
|
found = allCanti.find(c => c.id === id);
|
||||||
|
}
|
||||||
|
if (!found) {
|
||||||
|
found = myCantiList.find(c => c.id === id);
|
||||||
|
}
|
||||||
|
if (!found) {
|
||||||
|
found = comunitaCantiPers.find(c => c.id === id);
|
||||||
|
}
|
||||||
|
return found;
|
||||||
|
}).filter(c => !!c);
|
||||||
});
|
});
|
||||||
|
|
||||||
public localSongs: any[] = [];
|
public localSongs: any[] = [];
|
||||||
|
|||||||
+1
-1
@@ -1 +1 @@
|
|||||||
export const VERSION = '2026.05.20.1227';
|
export const VERSION = '2026.05.20.1245';
|
||||||
|
|||||||
Reference in New Issue
Block a user