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:
@@ -63,7 +63,13 @@ export class DisplayPage implements OnInit, OnDestroy {
|
||||
const allCanti = this.cantiService.canti();
|
||||
const comunitaCantiPers = this.comunitaService.comunitaCantiPersonali();
|
||||
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) {
|
||||
found = comunitaCantiPers.find(c => c.id === id);
|
||||
}
|
||||
|
||||
@@ -163,7 +163,13 @@ export class PlayerPage implements OnInit, AfterViewInit, OnDestroy {
|
||||
const comunitaCantiPers = this.comunitaService.comunitaCantiPersonali();
|
||||
|
||||
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) {
|
||||
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 { CantiService } from '../../services/canti.service';
|
||||
import { ComunitaService } from '../../services/comunita.service';
|
||||
import { MyCantiService } from '../../services/my-canti.service';
|
||||
import { CdkDragDrop, moveItemInArray } from '@angular/cdk/drag-drop';
|
||||
import { AlertController, ToastController, ModalController } from '@ionic/angular';
|
||||
import { Router } from '@angular/router';
|
||||
@@ -16,13 +17,34 @@ export class PlaylistPage {
|
||||
public playlistService = inject(PlaylistService);
|
||||
public cantiService = inject(CantiService);
|
||||
public comunitaService = inject(ComunitaService);
|
||||
public myCantiService = inject(MyCantiService);
|
||||
private alertCtrl = inject(AlertController);
|
||||
private toastCtrl = inject(ToastController);
|
||||
private router = inject(Router);
|
||||
|
||||
public selectedSongs = computed(() => {
|
||||
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[] = [];
|
||||
|
||||
Reference in New Issue
Block a user