fix: circular import causing navigate undefined; unified importer input
- Remove top-level ui.js import from soundcloud.js (broke views.js→soundcloud.js→ui.js→views.js cycle) - Use window.executeSpotifyDownload() instead to avoid the circular dep - Merge Spotify + SoundCloud into one unified URL input that auto-detects the service and colors the badge/button accordingly - resolveImporterLink() routes to the correct handler based on URL Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
1 parent
ee65183555
commit
0e8eb311af
4 files changed
+84
-57
No files matched your search
+7
-16
@@ -1,34 +1,25 @@
|
||||
import { S } from './state.js';
|
||||
import { esc, toast } from './utils.js';
|
||||
// Circular imports — safe (only used inside function bodies)
|
||||
import { executeSpotifyDownload } from './ui.js';
|
||||
|
||||
export function loadSoundCloudImporter() {
|
||||
const input = document.getElementById('sc-link-input');
|
||||
if (!input?.value) _showHint();
|
||||
// Hint is managed by the unified importer input in spotify.js
|
||||
}
|
||||
|
||||
export function clearSoundCloudPreview() {
|
||||
if (!document.getElementById('sc-link-input')?.value) _showHint();
|
||||
}
|
||||
|
||||
function _showHint() {
|
||||
document.getElementById('sc-importer-hint').style.display = '';
|
||||
document.getElementById('sc-preview').style.display = 'none';
|
||||
// no-op — handled by onImporterInput
|
||||
}
|
||||
|
||||
export async function resolveSoundCloudLink() {
|
||||
const url = document.getElementById('sc-link-input')?.value.trim();
|
||||
const url = document.getElementById('sc-link-input')?.value.trim()
|
||||
|| document.getElementById('importer-link-input')?.value.trim();
|
||||
if (!url) return;
|
||||
if (!url.includes('soundcloud.com')) { toast('⚠ Kein SoundCloud-Link'); return; }
|
||||
if (!S.cfg.backendUrl) { toast('⚠ Backend URL in Einstellungen konfigurieren'); return; }
|
||||
|
||||
const hint = document.getElementById('sc-importer-hint');
|
||||
const preview = document.getElementById('sc-preview');
|
||||
const inner = document.getElementById('sc-preview-inner');
|
||||
const section = document.getElementById('sc-tracks-section');
|
||||
|
||||
hint.style.display = 'none';
|
||||
preview.style.display = '';
|
||||
section.style.display = 'none';
|
||||
inner.innerHTML = '<div class="spinner"></div>';
|
||||
@@ -59,7 +50,7 @@ export async function resolveSoundCloudLink() {
|
||||
export function scDlAll() {
|
||||
const data = window._scResolved;
|
||||
if (!data) return;
|
||||
executeSpotifyDownload({
|
||||
window.executeSpotifyDownload({
|
||||
type: 'playlist',
|
||||
title: data.name,
|
||||
artist: data.artist,
|
||||
@@ -72,7 +63,7 @@ export function scDlSingle() {
|
||||
const data = window._scResolved;
|
||||
if (!data?.tracks?.[0]) return;
|
||||
const t = data.tracks[0];
|
||||
executeSpotifyDownload({
|
||||
window.executeSpotifyDownload({
|
||||
type: 'track',
|
||||
title: t.trackName,
|
||||
artist: t.artistName,
|
||||
@@ -85,7 +76,7 @@ export function scDlTrack(idx) {
|
||||
const data = window._scResolved;
|
||||
const t = data?.tracks?.[idx];
|
||||
if (!t) return;
|
||||
executeSpotifyDownload({
|
||||
window.executeSpotifyDownload({
|
||||
type: 'track',
|
||||
title: t.trackName,
|
||||
artist: t.artistName,
|
||||
|
||||
Reference in new issue
Block a user