Ottimizzazione UI player, rotazione head tilt invertita, prefisso playlist in Home e implementazione Identity QR modal e interceptor API
This commit is contained in:
@@ -1,8 +1,9 @@
|
||||
import { Injectable, signal, inject } from '@angular/core';
|
||||
import { Injectable, signal, inject, Injector } from '@angular/core';
|
||||
import { Storage } from '@ionic/storage-angular';
|
||||
import { Canto, CantiService } from './canti.service';
|
||||
import { ToastController } from '@ionic/angular';
|
||||
import { environment } from '../../environments/environment';
|
||||
import { PlaylistService } from './playlist.service';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
@@ -11,6 +12,8 @@ export class MyCantiService {
|
||||
private storage = inject(Storage);
|
||||
private cantiService = inject(CantiService);
|
||||
private toastController = inject(ToastController);
|
||||
private injector = inject(Injector);
|
||||
private playlistService!: PlaylistService;
|
||||
|
||||
private _storage: Storage | null = null;
|
||||
public myCanti = signal<Canto[]>([]);
|
||||
@@ -56,9 +59,11 @@ export class MyCantiService {
|
||||
});
|
||||
// Fallback if not found in list (should not happen normally)
|
||||
if (!updated.some(c => c.id === canto.id)) {
|
||||
const numericId = canto.id ? Number(canto.id.replace('my_', '')) : NaN;
|
||||
const idCanti = isNaN(numericId) ? Date.now() : numericId;
|
||||
targetCanto = {
|
||||
id: canto.id,
|
||||
id_canti: canto.id_canti || Date.now(),
|
||||
id_canti: canto.id_canti || idCanti,
|
||||
titolo: canto.titolo || 'Senza Titolo',
|
||||
testo: canto.testo || '',
|
||||
accordi: canto.accordi,
|
||||
@@ -86,6 +91,12 @@ export class MyCantiService {
|
||||
this.myCanti.set(updated);
|
||||
await this._storage?.set('my-canti', updated);
|
||||
|
||||
// Sincronizza automaticamente in background
|
||||
if (!this.playlistService) {
|
||||
this.playlistService = this.injector.get(PlaylistService);
|
||||
}
|
||||
this.playlistService.syncLocalDataToServer();
|
||||
|
||||
const toast = await this.toastController.create({
|
||||
message: 'Canto salvato nei "Miei Canti"!',
|
||||
duration: 2000,
|
||||
@@ -100,6 +111,12 @@ export class MyCantiService {
|
||||
const updated = this.myCanti().filter(c => c.id !== id);
|
||||
this.myCanti.set(updated);
|
||||
await this._storage?.set('my-canti', updated);
|
||||
|
||||
// Sincronizza automaticamente in background
|
||||
if (!this.playlistService) {
|
||||
this.playlistService = this.injector.get(PlaylistService);
|
||||
}
|
||||
this.playlistService.syncLocalDataToServer();
|
||||
}
|
||||
|
||||
async sendAllMyCanti() {
|
||||
|
||||
Reference in New Issue
Block a user