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,4 +1,4 @@
|
||||
import { Component, OnInit, OnDestroy, signal, computed, effect, inject, ElementRef, AfterViewInit } from '@angular/core';
|
||||
import { Component, OnInit, OnDestroy, signal, computed, effect, inject, ElementRef, AfterViewInit, untracked } from '@angular/core';
|
||||
import { DomSanitizer, SafeResourceUrl } from '@angular/platform-browser';
|
||||
import { ActivatedRoute, Router } from '@angular/router';
|
||||
import { AlertController, ToastController, GestureController } from '@ionic/angular';
|
||||
@@ -177,19 +177,40 @@ export class PlayerPage implements OnInit, AfterViewInit, OnDestroy {
|
||||
if (!found) {
|
||||
found = myCantiList.find(c => c.id === id);
|
||||
}
|
||||
if (!found) {
|
||||
found = this.playlistService.remoteCustomSongs().find(c => c.id === id || String(c.id_canti) === id);
|
||||
}
|
||||
if (!found) {
|
||||
found = comunitaCantiPers.find(c => c.id === id);
|
||||
}
|
||||
|
||||
if (found) {
|
||||
const current = this.canto();
|
||||
// Avoid duplicate triggers for the same song
|
||||
if (!current || current.id !== found.id) {
|
||||
const current = untracked(() => this.canto());
|
||||
// Avoid duplicate triggers for the same song, but update if song content changed
|
||||
const contentChanged = !current ||
|
||||
current.id !== found.id ||
|
||||
current.titolo !== found.titolo ||
|
||||
current.autore !== found.autore ||
|
||||
current.link_youtube !== found.link_youtube ||
|
||||
current.testo !== found.testo ||
|
||||
current.accordi !== found.accordi ||
|
||||
JSON.stringify(current.id_momenti) !== JSON.stringify(found.id_momenti);
|
||||
|
||||
if (contentChanged) {
|
||||
this.logPreviousSongTime();
|
||||
this.canto.set(found);
|
||||
this.currentLineIndex.set(0);
|
||||
this.lastScrollBlock.set('start');
|
||||
this.songStartTime = Date.now();
|
||||
this.cantiService.getStorage()?.set('last_song_id', id);
|
||||
this.channel.postMessage({ type: 'SYNC_CANTO', id: found.id });
|
||||
this.channel.postMessage({ type: 'SYNC_INDEX', index: 0 });
|
||||
setTimeout(() => {
|
||||
const scrollEl = this.el.nativeElement.querySelector('.lyrics-container');
|
||||
if (scrollEl) {
|
||||
scrollEl.scrollTop = 0;
|
||||
}
|
||||
}, 100);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -203,15 +224,27 @@ export class PlayerPage implements OnInit, AfterViewInit, OnDestroy {
|
||||
const activePlaylistId = this.playlistService.activePlaylistId();
|
||||
let playlistSongSetting: any = null;
|
||||
if (activePlaylistId) {
|
||||
const pl = this.playlistService.playlists().find(p => p.id === activePlaylistId);
|
||||
if (pl && pl.songSettings && pl.songSettings[c.id]) {
|
||||
playlistSongSetting = pl.songSettings[c.id];
|
||||
if (activePlaylistId.startsWith('remote_')) {
|
||||
const pl = this.playlistService.remotePlaylist();
|
||||
if (pl && pl.songSettings && pl.songSettings[c.id]) {
|
||||
playlistSongSetting = pl.songSettings[c.id];
|
||||
}
|
||||
} else {
|
||||
const pl = this.playlistService.playlists().find(p => p.id === activePlaylistId);
|
||||
if (pl && pl.songSettings && pl.songSettings[c.id]) {
|
||||
playlistSongSetting = pl.songSettings[c.id];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (playlistSongSetting) {
|
||||
this.transposeAmount.set(playlistSongSetting.tonalita !== undefined ? playlistSongSetting.tonalita : 0);
|
||||
this.autoscrollSpeed.set(playlistSongSetting.speed !== undefined ? playlistSongSetting.speed : 2);
|
||||
if (playlistSongSetting.zoom !== undefined) {
|
||||
this.fontSize.set(playlistSongSetting.zoom);
|
||||
} else {
|
||||
this.fontSize.set(1.0);
|
||||
}
|
||||
} else if (this.comunitaService.comunitaCode() && this.comunitaService.isFilterActive()) {
|
||||
const settings = this.comunitaService.comunitaCantiSettings();
|
||||
const songSetting = settings.find(s => s.id_canti === c.id_canti || s.id_canti === Number(c.id));
|
||||
@@ -322,6 +355,7 @@ export class PlayerPage implements OnInit, AfterViewInit, OnDestroy {
|
||||
|
||||
onTouchEnd() {
|
||||
this.initialPinchDistance = null;
|
||||
this.updatePlaylistSettings();
|
||||
}
|
||||
|
||||
private getDistance(t1: Touch, t2: Touch): number {
|
||||
@@ -334,9 +368,7 @@ export class PlayerPage implements OnInit, AfterViewInit, OnDestroy {
|
||||
this.transposeAmount.set(0);
|
||||
}
|
||||
|
||||
transposeUp() {
|
||||
this.transposeAmount.update(v => v + 1);
|
||||
|
||||
private updatePlaylistSettings() {
|
||||
const c = this.canto();
|
||||
if (c) {
|
||||
const dbSpeed = this.autoscrollSpeed() * 100;
|
||||
@@ -344,30 +376,35 @@ export class PlayerPage implements OnInit, AfterViewInit, OnDestroy {
|
||||
|
||||
const activePlaylistId = this.playlistService.activePlaylistId();
|
||||
if (activePlaylistId) {
|
||||
this.playlistService.updatePlaylistSongSettings(activePlaylistId, c.id, this.transposeAmount(), this.autoscrollSpeed());
|
||||
if (activePlaylistId.startsWith('remote_')) {
|
||||
return;
|
||||
}
|
||||
this.playlistService.updatePlaylistSongSettings(
|
||||
activePlaylistId,
|
||||
c.id,
|
||||
this.transposeAmount(),
|
||||
this.autoscrollSpeed(),
|
||||
this.fontSize()
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
transposeUp() {
|
||||
this.transposeAmount.update(v => v + 1);
|
||||
this.updatePlaylistSettings();
|
||||
}
|
||||
|
||||
transposeDown() {
|
||||
this.transposeAmount.update(v => v - 1);
|
||||
|
||||
const c = this.canto();
|
||||
if (c) {
|
||||
const dbSpeed = this.autoscrollSpeed() * 100;
|
||||
this.statsService.updateSongSettings(c.id_canti, this.transposeAmount(), dbSpeed);
|
||||
|
||||
const activePlaylistId = this.playlistService.activePlaylistId();
|
||||
if (activePlaylistId) {
|
||||
this.playlistService.updatePlaylistSongSettings(activePlaylistId, c.id, this.transposeAmount(), this.autoscrollSpeed());
|
||||
}
|
||||
}
|
||||
this.updatePlaylistSettings();
|
||||
}
|
||||
|
||||
zoomIn() {
|
||||
if (this.fontSize() < this.MAX_FONT) {
|
||||
this.fontSize.update(v => Math.min(v + this.FONT_STEP, this.MAX_FONT));
|
||||
this.channel.postMessage({ type: 'SYNC_FONT', fontSize: this.fontSize() });
|
||||
this.updatePlaylistSettings();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -375,6 +412,7 @@ export class PlayerPage implements OnInit, AfterViewInit, OnDestroy {
|
||||
if (this.fontSize() > this.MIN_FONT) {
|
||||
this.fontSize.update(v => Math.max(v - this.FONT_STEP, this.MIN_FONT));
|
||||
this.channel.postMessage({ type: 'SYNC_FONT', fontSize: this.fontSize() });
|
||||
this.updatePlaylistSettings();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -857,30 +895,12 @@ export class PlayerPage implements OnInit, AfterViewInit, OnDestroy {
|
||||
|
||||
increaseAutoscrollSpeed() {
|
||||
this.autoscrollSpeed.update(s => Math.min(10, s + 1));
|
||||
const c = this.canto();
|
||||
if (c) {
|
||||
const dbSpeed = this.autoscrollSpeed() * 100;
|
||||
this.statsService.updateSongSettings(c.id_canti, this.transposeAmount(), dbSpeed);
|
||||
|
||||
const activePlaylistId = this.playlistService.activePlaylistId();
|
||||
if (activePlaylistId) {
|
||||
this.playlistService.updatePlaylistSongSettings(activePlaylistId, c.id, this.transposeAmount(), this.autoscrollSpeed());
|
||||
}
|
||||
}
|
||||
this.updatePlaylistSettings();
|
||||
}
|
||||
|
||||
decreaseAutoscrollSpeed() {
|
||||
this.autoscrollSpeed.update(s => Math.max(1, s - 1));
|
||||
const c = this.canto();
|
||||
if (c) {
|
||||
const dbSpeed = this.autoscrollSpeed() * 100;
|
||||
this.statsService.updateSongSettings(c.id_canti, this.transposeAmount(), dbSpeed);
|
||||
|
||||
const activePlaylistId = this.playlistService.activePlaylistId();
|
||||
if (activePlaylistId) {
|
||||
this.playlistService.updatePlaylistSongSettings(activePlaylistId, c.id, this.transposeAmount(), this.autoscrollSpeed());
|
||||
}
|
||||
}
|
||||
this.updatePlaylistSettings();
|
||||
}
|
||||
|
||||
private logPreviousSongTime() {
|
||||
|
||||
Reference in New Issue
Block a user