fix weird ass bug

This commit is contained in:
2026-04-24 23:11:38 +02:00
parent 90823e76cd
commit 5d384ae407
+8 -12
View File
@@ -328,32 +328,31 @@ function applySubdir(payload) {
}); });
} }
// ─── Playlist Selection ──────────────────────────────────────────────────────
function selectPlaylistItem(i, el) { function selectPlaylistItem(i, el) {
const path = el.dataset.path;
if (el.classList.contains("selected")) { if (el.classList.contains("selected")) {
el.classList.remove("selected"); el.classList.remove("selected");
selectedPlaylistIndex = null; selectedPlaylistPath = null;
updateControls(); updateControls();
return; return;
} }
clearListSelections("playlist-ul", "dirs-box", "subdir-box"); clearListSelections("playlist-ul", "dirs-box", "subdir-box");
el.classList.add("selected"); el.classList.add("selected");
selectedPlaylistPath = path;
selectedPlaylistIndex = i; selectedPlaylistIndex = i;
updateControls(); updateControls();
} }
// ─── Queue Actions ───────────────────────────────────────────────────────────
function addSelectedFileToQueue(top) { function addSelectedFileToQueue(top) {
let fullPath = null; let fullPath = null;
if (selectedPlaylistIndex != null) { if (selectedPlaylistPath != null) {
const selected = playlist[selectedPlaylistIndex]; const selected = playlist.find(t => t.path === selectedPlaylistPath);
if (!selected) return false;
const path = (selected.official ? "" : "!") + selected.path; const path = (selected.official ? "" : "!") + selected.path;
wsSend({ action: "add_to_toplay", songs: [path], top }); wsSend({ action: "add_to_toplay", songs: [path], top });
// Only clear playlist selection — keep dir/subdir selections intact
clearListSelections("playlist-ul"); clearListSelections("playlist-ul");
selectedPlaylistPath = null;
selectedPlaylistIndex = null; selectedPlaylistIndex = null;
updateControls(); updateControls();
return true; return true;
@@ -362,8 +361,7 @@ function addSelectedFileToQueue(top) {
if (selectedSubFile && selectedDir) { if (selectedSubFile && selectedDir) {
fullPath = subBasePath.replace(/\/$/, "") + "/" + selectedSubFile; fullPath = subBasePath.replace(/\/$/, "") + "/" + selectedSubFile;
} else { } else {
const selectedFileEl = Array.from(document.getElementById("dirs-box").children) const selectedFileEl = Array.from(document.getElementById("dirs-box").children).find(el => el.classList.contains("selected") && el.dataset.type === "file");
.find(el => el.classList.contains("selected") && el.dataset.type === "file");
if (selectedFileEl) { if (selectedFileEl) {
fullPath = basePath.replace(/\/$/, "") + "/" + selectedFileEl.textContent; fullPath = basePath.replace(/\/$/, "") + "/" + selectedFileEl.textContent;
} }
@@ -378,8 +376,6 @@ function addSelectedFileToQueue(top) {
return false; return false;
} }
// ─── Controls ────────────────────────────────────────────────────────────────
function updateControls() { function updateControls() {
document.getElementById("clear-btn").disabled = queue.length === 0; document.getElementById("clear-btn").disabled = queue.length === 0;