modificato deploy verso contabo
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { Component, OnInit, OnDestroy, signal, computed, effect, inject, ElementRef, AfterViewInit, untracked, HostListener } from '@angular/core';
|
||||
import { DomSanitizer, SafeResourceUrl } from '@angular/platform-browser';
|
||||
import { DomSanitizer, SafeResourceUrl, Meta } from '@angular/platform-browser';
|
||||
import { ActivatedRoute, Router } from '@angular/router';
|
||||
import { AlertController, ToastController, GestureController } from '@ionic/angular';
|
||||
import { CantiService, Canto } from '../../services/canti.service';
|
||||
@@ -150,6 +150,7 @@ export class PlayerPage implements OnInit, AfterViewInit, OnDestroy {
|
||||
private el = inject(ElementRef);
|
||||
private sanitizer = inject(DomSanitizer);
|
||||
public faceDetector = inject(FaceDetectorService);
|
||||
private meta = inject(Meta);
|
||||
|
||||
public enableCameraNavigation = signal<boolean>(false);
|
||||
|
||||
@@ -212,6 +213,9 @@ export class PlayerPage implements OnInit, AfterViewInit, OnDestroy {
|
||||
if (!found) {
|
||||
found = this.playlistService.remoteCustomSongs().find(c => c.id === id || String(c.id_canti) === id);
|
||||
}
|
||||
if (!found) {
|
||||
found = this.playlistService.remoteShareCanti().find(c => c.id === id || String(c.id_canti) === id);
|
||||
}
|
||||
if (!found) {
|
||||
found = comunitaCantiPers.find(c => c.id === id);
|
||||
}
|
||||
@@ -237,6 +241,15 @@ export class PlayerPage implements OnInit, AfterViewInit, OnDestroy {
|
||||
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 });
|
||||
|
||||
// Update Open Graph Image tag dynamically
|
||||
const thumb = this.cantiService.getYoutubeThumb(found.link_youtube);
|
||||
if (thumb) {
|
||||
this.meta.updateTag({ property: 'og:image', content: thumb });
|
||||
} else {
|
||||
this.meta.updateTag({ property: 'og:image', content: window.location.origin + '/assets/icon/favicon.png' });
|
||||
}
|
||||
|
||||
setTimeout(() => {
|
||||
const scrollEl = this.el.nativeElement.querySelector('.lyrics-container');
|
||||
if (scrollEl) {
|
||||
@@ -1037,6 +1050,84 @@ export class PlayerPage implements OnInit, AfterViewInit, OnDestroy {
|
||||
}
|
||||
}
|
||||
|
||||
async shareCanto() {
|
||||
const c = this.canto();
|
||||
if (!c) return;
|
||||
|
||||
const isStandard = !c.id.startsWith('my_') && !c.id.startsWith('remote_share_') && !c.nonValidato;
|
||||
|
||||
try {
|
||||
let shareLink = '';
|
||||
if (isStandard) {
|
||||
shareLink = `https://www.canticristiani.it/?id=${c.id}`;
|
||||
} else {
|
||||
await this.playlistService.syncLocalDataToServer();
|
||||
const uid = this.settingsService.userUuid();
|
||||
shareLink = `https://www.canticristiani.it/?song-uid=${uid}&song-id=${c.id_canti}`;
|
||||
}
|
||||
|
||||
let fileToShare: File | null = null;
|
||||
const thumbUrl = this.cantiService.getYoutubeThumb(c.link_youtube);
|
||||
|
||||
// Try to fetch YouTube thumbnail first if available
|
||||
if (thumbUrl) {
|
||||
try {
|
||||
const response = await Promise.race([
|
||||
fetch(thumbUrl),
|
||||
new Promise<Response>((_, reject) => setTimeout(() => reject(new Error('Timeout')), 3000))
|
||||
]);
|
||||
if (response.ok) {
|
||||
const blob = await response.blob();
|
||||
fileToShare = new File([blob], 'song_thumbnail.jpg', { type: 'image/jpeg' });
|
||||
}
|
||||
} catch (e) {
|
||||
console.warn('[Share] Failed to fetch YouTube thumbnail due to CORS or timeout:', e);
|
||||
}
|
||||
}
|
||||
|
||||
// If no YouTube thumb or fetch failed, fallback to local canticristiani logo (favicon)
|
||||
if (!fileToShare) {
|
||||
try {
|
||||
const response = await fetch('assets/icon/favicon.png');
|
||||
if (response.ok) {
|
||||
const blob = await response.blob();
|
||||
fileToShare = new File([blob], 'canticristiani_logo.png', { type: 'image/png' });
|
||||
}
|
||||
} catch (e) {
|
||||
console.warn('[Share] Failed to fetch local logo:', e);
|
||||
}
|
||||
}
|
||||
|
||||
const shareDataObj: any = {
|
||||
title: `Condividi Canto: ${c.titolo}`,
|
||||
text: isStandard
|
||||
? `Ecco il canto "${c.titolo}" dall'app Canti Cristiani. Clicca sul link per aprirlo:\n\n`
|
||||
: `Ecco il canto "${c.titolo}" per l'app Canti Cristiani. Clicca sul link per aggiungerlo:\n\n`,
|
||||
url: shareLink
|
||||
};
|
||||
|
||||
if (fileToShare && navigator.canShare && navigator.canShare({ files: [fileToShare] })) {
|
||||
shareDataObj.files = [fileToShare];
|
||||
}
|
||||
|
||||
if (navigator.share) {
|
||||
await navigator.share(shareDataObj);
|
||||
} else {
|
||||
if (navigator.clipboard) {
|
||||
await navigator.clipboard.writeText(shareLink);
|
||||
const toast = await this.toastCtrl.create({
|
||||
message: 'Link di condivisione copiato negli appunti!',
|
||||
duration: 2500,
|
||||
color: 'success'
|
||||
});
|
||||
await toast.present();
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
console.error('Failed to share song', err);
|
||||
}
|
||||
}
|
||||
|
||||
private initPlayer(id: string) {
|
||||
if (!this.youtubePlayerService.isPlayerSupported()) {
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user