Ottimizzazione UI player, rotazione head tilt invertita, prefisso playlist in Home e implementazione Identity QR modal e interceptor API
This commit is contained in:
@@ -5,8 +5,9 @@ import { IonicModule, ToastController, IonTextarea, PopoverController, NavContro
|
||||
import { createWorker } from 'tesseract.js';
|
||||
import { CantiService } from '../../services/canti.service';
|
||||
import { MyCantiService } from '../../services/my-canti.service';
|
||||
import { PlaylistService } from '../../services/playlist.service';
|
||||
import { ThemeService } from '../../services/theme.service';
|
||||
import { ActivatedRoute, RouterModule } from '@angular/router';
|
||||
import { ActivatedRoute, RouterModule, Router } from '@angular/router';
|
||||
|
||||
@Component({
|
||||
selector: 'app-propose-canto',
|
||||
@@ -21,9 +22,11 @@ export class ProposeCantoPage implements OnInit {
|
||||
|
||||
public cantiService = inject(CantiService);
|
||||
private myCantiService = inject(MyCantiService);
|
||||
private playlistService = inject(PlaylistService);
|
||||
private navCtrl = inject(NavController);
|
||||
public themeService = inject(ThemeService);
|
||||
private route = inject(ActivatedRoute);
|
||||
private router = inject(Router);
|
||||
|
||||
title: string = '';
|
||||
author: string = '';
|
||||
@@ -112,10 +115,11 @@ export class ProposeCantoPage implements OnInit {
|
||||
const editId = params['editId'];
|
||||
if (editId) {
|
||||
this.editId = editId;
|
||||
// Find the song in standard canti or personal canti list
|
||||
// Find the song in standard canti, personal canti, or remote custom canti list
|
||||
const song = [
|
||||
...this.cantiService.canti(),
|
||||
...this.myCantiService.myCanti()
|
||||
...this.myCantiService.myCanti(),
|
||||
...this.playlistService.remoteCustomSongs()
|
||||
].find(c => c.id === editId);
|
||||
|
||||
if (song) {
|
||||
@@ -128,8 +132,8 @@ export class ProposeCantoPage implements OnInit {
|
||||
const litIds = this.cantiService.indiceLiturgico().map(m => m.id);
|
||||
const temIds = this.cantiService.indiceTematico().map(m => m.id);
|
||||
|
||||
this.selectedLiturgico = song.id_momenti?.filter(id => litIds.includes(id)) || [];
|
||||
this.selectedTematico = song.id_momenti?.filter(id => temIds.includes(id)) || [];
|
||||
this.selectedLiturgico = song.id_momenti?.filter((id: number) => litIds.includes(id)) || [];
|
||||
this.selectedTematico = song.id_momenti?.filter((id: number) => temIds.includes(id)) || [];
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -749,16 +753,62 @@ export class ProposeCantoPage implements OnInit {
|
||||
// Combine lit and tematico for id_momenti
|
||||
const id_momenti = [...this.selectedLiturgico, ...this.selectedTematico];
|
||||
|
||||
await this.myCantiService.saveCanto({
|
||||
id: this.editId || undefined,
|
||||
titolo: this.title,
|
||||
autore: this.author,
|
||||
link_youtube: this.youtubeLink,
|
||||
testo: this.content,
|
||||
accordi: this.content, // Save to both fields for compatibility
|
||||
id_momenti: id_momenti
|
||||
});
|
||||
const activePlaylistId = this.playlistService.activePlaylistId();
|
||||
const isRemotePlaylist = activePlaylistId && activePlaylistId.startsWith('remote_');
|
||||
|
||||
this.navCtrl.back();
|
||||
if (isRemotePlaylist) {
|
||||
// 1. Clone the song (generate a brand new my_... ID)
|
||||
const savedCanto = await this.myCantiService.saveCanto({
|
||||
titolo: this.title,
|
||||
autore: this.author,
|
||||
link_youtube: this.youtubeLink,
|
||||
testo: this.content,
|
||||
accordi: this.content,
|
||||
id_momenti: id_momenti
|
||||
});
|
||||
|
||||
// 2. Clone/convert remote playlist to local personal playlist
|
||||
const remotePl = this.playlistService.remotePlaylist();
|
||||
if (remotePl) {
|
||||
const originalIds = remotePl.ids || [];
|
||||
const updatedIds = originalIds.map((id: string) => id === this.editId ? savedCanto.id : id);
|
||||
|
||||
const songSettings = { ...(remotePl.songSettings || {}) };
|
||||
if (this.editId && songSettings[this.editId]) {
|
||||
songSettings[savedCanto.id] = { ...songSettings[this.editId] };
|
||||
delete songSettings[this.editId];
|
||||
}
|
||||
|
||||
const localName = remotePl.name.replace('[Remote] ', '');
|
||||
|
||||
// Force save as a new local playlist
|
||||
this.playlistService.activePlaylistId.set(null);
|
||||
await this.playlistService.savePlaylist(localName, updatedIds, songSettings);
|
||||
}
|
||||
|
||||
// Navigate to the player with the new cloned song ID immediately
|
||||
this.router.navigate(['/player'], { queryParams: { id: savedCanto.id }, replaceUrl: true });
|
||||
} else {
|
||||
// Standard path
|
||||
const savedCanto = await this.myCantiService.saveCanto({
|
||||
id: this.editId || undefined,
|
||||
titolo: this.title,
|
||||
autore: this.author,
|
||||
link_youtube: this.youtubeLink,
|
||||
testo: this.content,
|
||||
accordi: this.content, // Save to both fields for compatibility
|
||||
id_momenti: id_momenti
|
||||
});
|
||||
|
||||
if (this.editId && !this.editId.startsWith('my_') && savedCanto && savedCanto.id) {
|
||||
await this.playlistService.replaceSongIdInPlaylists(this.editId, savedCanto.id);
|
||||
}
|
||||
|
||||
if (this.editId && savedCanto && savedCanto.id && this.editId !== savedCanto.id) {
|
||||
this.router.navigate(['/player'], { queryParams: { id: savedCanto.id }, replaceUrl: true });
|
||||
} else {
|
||||
this.navCtrl.back();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user