FIX: vite warnings
This commit is contained in:
parent
731c7a7a0b
commit
22365976c9
3 changed files with 14 additions and 52 deletions
41
js/app.js
41
js/app.js
|
|
@ -16,17 +16,18 @@ import { registerSW } from 'virtual:pwa-register';
|
|||
import { initializeDiscordRPC } from './discord-rpc.js';
|
||||
import * as Neutralino from '@neutralinojs/lib';
|
||||
import './smooth-scrolling.js';
|
||||
import { showNotification, downloadPlaylistAsZip } from './downloads.js';
|
||||
import './metadata.js'; // Ensure Side Effects
|
||||
|
||||
// Assign Neutralino to window for global access
|
||||
if (typeof window !== 'undefined') {
|
||||
window.Neutralino = Neutralino;
|
||||
}
|
||||
|
||||
import { initTracker } from './tracker.js';
|
||||
|
||||
// Lazy-loaded modules
|
||||
let settingsModule = null;
|
||||
let downloadsModule = null;
|
||||
let trackerModule = null;
|
||||
let metadataModule = null;
|
||||
|
||||
async function loadSettingsModule() {
|
||||
if (!settingsModule) {
|
||||
|
|
@ -35,26 +36,7 @@ async function loadSettingsModule() {
|
|||
return settingsModule;
|
||||
}
|
||||
|
||||
async function loadDownloadsModule() {
|
||||
if (!downloadsModule) {
|
||||
downloadsModule = await import('./downloads.js');
|
||||
}
|
||||
return downloadsModule;
|
||||
}
|
||||
|
||||
async function loadTrackerModule() {
|
||||
if (!trackerModule) {
|
||||
trackerModule = await import('./tracker.js');
|
||||
}
|
||||
return trackerModule;
|
||||
}
|
||||
|
||||
async function loadMetadataModule() {
|
||||
if (!metadataModule) {
|
||||
metadataModule = await import('./metadata.js');
|
||||
}
|
||||
return metadataModule;
|
||||
}
|
||||
|
||||
function initializeCasting(audioPlayer, castBtn) {
|
||||
if (!castBtn) return;
|
||||
|
|
@ -381,8 +363,7 @@ document.addEventListener('DOMContentLoaded', async () => {
|
|||
initializeUIInteractions(player, api, ui);
|
||||
initializeKeyboardShortcuts(player, audioPlayer);
|
||||
|
||||
// Load tracker module
|
||||
const { initTracker } = await loadTrackerModule();
|
||||
// Initialize tracker
|
||||
initTracker(player);
|
||||
|
||||
// Initialize desktop environment (Neutralino)
|
||||
|
|
@ -390,7 +371,7 @@ document.addEventListener('DOMContentLoaded', async () => {
|
|||
console.log('Initializing Neutralino desktop environment (Lite Mode)...');
|
||||
try {
|
||||
Neutralino.init();
|
||||
|
||||
|
||||
// Register events immediately
|
||||
Neutralino.events.on('windowClose', () => {
|
||||
Neutralino.app.exit();
|
||||
|
|
@ -584,7 +565,7 @@ document.addEventListener('DOMContentLoaded', async () => {
|
|||
}
|
||||
} catch (error) {
|
||||
console.error('Failed to play album:', error);
|
||||
const { showNotification } = await loadDownloadsModule();
|
||||
|
||||
showNotification('Failed to play album');
|
||||
}
|
||||
}
|
||||
|
|
@ -608,12 +589,12 @@ document.addEventListener('DOMContentLoaded', async () => {
|
|||
if (shuffleBtn) shuffleBtn.classList.remove('active');
|
||||
player.shuffleActive = false;
|
||||
player.playTrackFromQueue();
|
||||
const { showNotification } = await loadDownloadsModule();
|
||||
|
||||
showNotification('Shuffling album');
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Failed to shuffle album:', error);
|
||||
const { showNotification } = await loadDownloadsModule();
|
||||
|
||||
showNotification('Failed to shuffle album');
|
||||
}
|
||||
}
|
||||
|
|
@ -637,7 +618,7 @@ document.addEventListener('DOMContentLoaded', async () => {
|
|||
|
||||
try {
|
||||
const { mix, tracks } = await api.getMix(mixId);
|
||||
const { downloadPlaylistAsZip } = await loadDownloadsModule();
|
||||
|
||||
await downloadPlaylistAsZip(mix, tracks, api, downloadQualitySettings.getQuality(), lyricsManager);
|
||||
} catch (error) {
|
||||
console.error('Mix download failed:', error);
|
||||
|
|
@ -681,7 +662,7 @@ document.addEventListener('DOMContentLoaded', async () => {
|
|||
tracks = data.tracks;
|
||||
}
|
||||
|
||||
const { downloadPlaylistAsZip } = await loadDownloadsModule();
|
||||
|
||||
await downloadPlaylistAsZip(playlist, tracks, api, downloadQualitySettings.getQuality(), lyricsManager);
|
||||
} catch (error) {
|
||||
console.error('Playlist download failed:', error);
|
||||
|
|
|
|||
|
|
@ -1250,7 +1250,6 @@ async function updateContextMenuLikeState(contextMenu, contextTrack) {
|
|||
|
||||
const likeItem = contextMenu.querySelector('li[data-action="toggle-like"]');
|
||||
if (likeItem) {
|
||||
const { db } = await import('./db.js');
|
||||
const isLiked = await db.isFavorite('track', contextTrack.id);
|
||||
likeItem.textContent = isLiked ? 'Unlike' : 'Like';
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,6 +12,9 @@ import {
|
|||
} from './utils.js';
|
||||
import { sidePanelManager } from './side-panel.js';
|
||||
import { downloadQualitySettings } from './storage.js';
|
||||
import { db } from './db.js';
|
||||
import { syncManager } from './accounts/pocketbase.js';
|
||||
import { showNotification, downloadTracks } from './downloads.js';
|
||||
|
||||
export function initializeUIInteractions(player, api, ui) {
|
||||
const sidebar = document.querySelector('.sidebar');
|
||||
|
|
@ -53,9 +56,6 @@ export function initializeUIInteractions(player, api, ui) {
|
|||
const folderId = folderCard.dataset.folderId;
|
||||
|
||||
if (playlistId && folderId) {
|
||||
const { db } = await import('./db.js');
|
||||
const { syncManager } = await import('./accounts/pocketbase.js');
|
||||
const { showNotification } = await import('./downloads.js');
|
||||
const updatedFolder = await db.addPlaylistToFolder(folderId, playlistId);
|
||||
syncManager.syncUserFolder(updatedFolder, 'update');
|
||||
const subtitle = folderCard.querySelector('.card-subtitle');
|
||||
|
|
@ -126,7 +126,6 @@ export function initializeUIInteractions(player, api, ui) {
|
|||
const downloadBtn = container.querySelector('#download-queue-btn');
|
||||
if (downloadBtn) {
|
||||
downloadBtn.addEventListener('click', async () => {
|
||||
const { downloadTracks } = await import('./downloads.js');
|
||||
downloadTracks(currentQueue, api, downloadQualitySettings.getQuality());
|
||||
});
|
||||
}
|
||||
|
|
@ -134,10 +133,6 @@ export function initializeUIInteractions(player, api, ui) {
|
|||
const likeBtn = container.querySelector('#like-queue-btn');
|
||||
if (likeBtn) {
|
||||
likeBtn.addEventListener('click', async () => {
|
||||
const { db } = await import('./db.js'); // Already imported
|
||||
const { syncManager } = await import('./accounts/pocketbase.js');
|
||||
const { showNotification } = await import('./downloads.js');
|
||||
|
||||
let addedCount = 0;
|
||||
for (const track of currentQueue) {
|
||||
const wasAdded = await db.toggleFavorite('track', track);
|
||||
|
|
@ -160,10 +155,6 @@ export function initializeUIInteractions(player, api, ui) {
|
|||
const addToPlaylistBtn = container.querySelector('#add-queue-to-playlist-btn');
|
||||
if (addToPlaylistBtn) {
|
||||
addToPlaylistBtn.addEventListener('click', async () => {
|
||||
const { db } = await import('./db.js'); // Already imported
|
||||
const { syncManager } = await import('./accounts/pocketbase.js');
|
||||
const { showNotification } = await import('./downloads.js');
|
||||
|
||||
const playlists = await db.getPlaylists();
|
||||
if (playlists.length === 0) {
|
||||
showNotification('No playlists yet. Create one first.');
|
||||
|
|
@ -291,7 +282,6 @@ export function initializeUIInteractions(player, api, ui) {
|
|||
// Update like button state
|
||||
const likeBtn = item.querySelector('.queue-like-btn');
|
||||
if (likeBtn && track) {
|
||||
const { db } = await import('./db.js');
|
||||
const isLiked = await db.isFavorite('track', track.id);
|
||||
likeBtn.classList.toggle('active', isLiked);
|
||||
likeBtn.innerHTML = isLiked
|
||||
|
|
@ -313,10 +303,6 @@ export function initializeUIInteractions(player, api, ui) {
|
|||
e.stopPropagation();
|
||||
const track = player.getCurrentQueue()[index];
|
||||
if (track) {
|
||||
const { db } = await import('./db.js'); // Already imported
|
||||
const { syncManager } = await import('./accounts/pocketbase.js');
|
||||
const { showNotification } = await import('./downloads.js');
|
||||
|
||||
const added = await db.toggleFavorite('track', track);
|
||||
syncManager.syncLibraryItem('track', track, added);
|
||||
|
||||
|
|
@ -343,7 +329,6 @@ export function initializeUIInteractions(player, api, ui) {
|
|||
if (contextMenu) {
|
||||
const track = player.getCurrentQueue()[index];
|
||||
if (track) {
|
||||
const { db } = await import('./db.js');
|
||||
const isLiked = await db.isFavorite('track', track.id);
|
||||
const likeItem = contextMenu.querySelector('li[data-action="toggle-like"]');
|
||||
if (likeItem) {
|
||||
|
|
@ -440,9 +425,6 @@ export function initializeUIInteractions(player, api, ui) {
|
|||
const playlistId = e.dataTransfer.getData('text/playlist-id');
|
||||
const folderId = window.location.pathname.split('/')[2];
|
||||
if (playlistId && folderId) {
|
||||
const { db } = await import('./db.js');
|
||||
const { syncManager } = await import('./accounts/pocketbase.js');
|
||||
const { showNotification } = await import('./downloads.js');
|
||||
try {
|
||||
const updatedFolder = await db.addPlaylistToFolder(folderId, playlistId);
|
||||
syncManager.syncUserFolder(updatedFolder, 'update');
|
||||
|
|
|
|||
Loading…
Reference in a new issue