saving
This commit is contained in:
parent
f7a743c600
commit
a9f69752ed
|
|
@ -252,7 +252,6 @@
|
||||||
const data = JSON.parse(e.data);
|
const data = JSON.parse(e.data);
|
||||||
// Handle channel list updates
|
// Handle channel list updates
|
||||||
if (data.type === "channel_list") {
|
if (data.type === "channel_list") {
|
||||||
console.log("[WS] Received channel_list:", data.channels.length, "channels");
|
|
||||||
M.channels = data.channels;
|
M.channels = data.channels;
|
||||||
M.renderChannelList();
|
M.renderChannelList();
|
||||||
return;
|
return;
|
||||||
|
|
|
||||||
|
|
@ -110,7 +110,6 @@
|
||||||
actions.classList.remove('hidden');
|
actions.classList.remove('hidden');
|
||||||
|
|
||||||
const isMine = myPlaylists.some(p => p.id === selectedPlaylistId);
|
const isMine = myPlaylists.some(p => p.id === selectedPlaylistId);
|
||||||
console.log("[Playlists] Creating container - isMine:", isMine, "selectedPlaylistId:", selectedPlaylistId);
|
|
||||||
|
|
||||||
// Create or update container (even for empty playlists, to enable drag-drop)
|
// Create or update container (even for empty playlists, to enable drag-drop)
|
||||||
playlistContainer = M.trackContainer.createContainer({
|
playlistContainer = M.trackContainer.createContainer({
|
||||||
|
|
@ -126,9 +125,7 @@
|
||||||
playlistId: selectedPlaylistId
|
playlistId: selectedPlaylistId
|
||||||
});
|
});
|
||||||
|
|
||||||
console.log("[Playlists] About to call render(), playlistContainer:", playlistContainer);
|
|
||||||
playlistContainer.render();
|
playlistContainer.render();
|
||||||
console.log("[Playlists] After render()");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function reloadCurrentPlaylist() {
|
function reloadCurrentPlaylist() {
|
||||||
|
|
|
||||||
|
|
@ -4,15 +4,6 @@
|
||||||
(function() {
|
(function() {
|
||||||
const M = window.MusicRoom;
|
const M = window.MusicRoom;
|
||||||
|
|
||||||
// Global debug: see if ANY drop event fires
|
|
||||||
document.addEventListener('drop', (e) => {
|
|
||||||
console.log("[GLOBAL drop] target:", e.target.tagName, e.target.className, "id:", e.target.id);
|
|
||||||
}, true);
|
|
||||||
|
|
||||||
document.addEventListener('dragend', (e) => {
|
|
||||||
console.log("[GLOBAL dragend] target:", e.target.tagName, e.target.className);
|
|
||||||
}, true);
|
|
||||||
|
|
||||||
// Track if a drag is in progress (to prevent re-renders from canceling it)
|
// Track if a drag is in progress (to prevent re-renders from canceling it)
|
||||||
let isDragging = false;
|
let isDragging = false;
|
||||||
|
|
||||||
|
|
@ -64,8 +55,6 @@
|
||||||
onRender
|
onRender
|
||||||
} = config;
|
} = config;
|
||||||
|
|
||||||
console.log("[createContainer] type:", type, "canRemove:", canRemove, "playlistId:", playlistId);
|
|
||||||
|
|
||||||
let currentTracks = [];
|
let currentTracks = [];
|
||||||
|
|
||||||
// Get canEdit dynamically (permissions may change)
|
// Get canEdit dynamically (permissions may change)
|
||||||
|
|
@ -77,12 +66,10 @@
|
||||||
function render() {
|
function render() {
|
||||||
// Defer render if a drag is in progress (would cancel the drag)
|
// Defer render if a drag is in progress (would cancel the drag)
|
||||||
if (isDragging) {
|
if (isDragging) {
|
||||||
console.log("[render] DEFERRED - drag in progress, type:", type);
|
|
||||||
pendingRender = true;
|
pendingRender = true;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
pendingRender = false;
|
pendingRender = false;
|
||||||
console.log("[render] type:", type, "canRemove:", canRemove, "playlistId:", playlistId);
|
|
||||||
const canEdit = getCanEdit();
|
const canEdit = getCanEdit();
|
||||||
element.innerHTML = "";
|
element.innerHTML = "";
|
||||||
|
|
||||||
|
|
@ -94,7 +81,6 @@
|
||||||
wireQueueContainerDrop(element);
|
wireQueueContainerDrop(element);
|
||||||
}
|
}
|
||||||
if (canRemove && type === 'playlist' && playlistId) {
|
if (canRemove && type === 'playlist' && playlistId) {
|
||||||
console.log("[Playlist] Wiring container drop on element:", element.id || element.className);
|
|
||||||
wirePlaylistContainerDrop(element);
|
wirePlaylistContainerDrop(element);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -160,7 +146,6 @@
|
||||||
};
|
};
|
||||||
|
|
||||||
container.ondrop = (e) => {
|
container.ondrop = (e) => {
|
||||||
console.log("[Container ondrop] dragSource:", dragSource, "trackIds:", draggedTrackIds, "dropTargetIndex:", dropTargetIndex);
|
|
||||||
container.classList.remove("drop-target");
|
container.classList.remove("drop-target");
|
||||||
// Clear any drop indicators on tracks
|
// Clear any drop indicators on tracks
|
||||||
container.querySelectorAll(".drop-above, .drop-below").forEach(el => {
|
container.querySelectorAll(".drop-above, .drop-below").forEach(el => {
|
||||||
|
|
@ -215,9 +200,7 @@
|
||||||
|
|
||||||
// Get current tracks and insert at position
|
// Get current tracks and insert at position
|
||||||
const current = currentTracks.map(t => (t.track || t).id);
|
const current = currentTracks.map(t => (t.track || t).id);
|
||||||
console.log("[addTracksToPlaylistAt] current:", current, "inserting:", trackIds, "at:", position);
|
|
||||||
const newList = [...current.slice(0, position), ...trackIds, ...current.slice(position)];
|
const newList = [...current.slice(0, position), ...trackIds, ...current.slice(position)];
|
||||||
console.log("[addTracksToPlaylistAt] newList:", newList);
|
|
||||||
|
|
||||||
const res = await fetch(`/api/playlists/${playlistId}/tracks`, {
|
const res = await fetch(`/api/playlists/${playlistId}/tracks`, {
|
||||||
method: "PATCH",
|
method: "PATCH",
|
||||||
|
|
@ -317,17 +300,9 @@
|
||||||
div.ondrop = (e) => handleDrop(e, div, originalIndex);
|
div.ondrop = (e) => handleDrop(e, div, originalIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Debug: log playlist track wiring conditions
|
|
||||||
if (type === 'playlist') {
|
|
||||||
console.log("[Playlist wireTrackEvents] type:", type, "playlistId:", playlistId, "canRemove:", canRemove);
|
|
||||||
}
|
|
||||||
|
|
||||||
// For playlist tracks, allow reordering and insertion (separate from canEdit)
|
// For playlist tracks, allow reordering and insertion (separate from canEdit)
|
||||||
if (type === 'playlist' && playlistId && canRemove) {
|
if (type === 'playlist' && playlistId && canRemove) {
|
||||||
console.log("[Playlist] Wiring drag handlers for track:", trackId);
|
|
||||||
|
|
||||||
div.ondragover = (e) => {
|
div.ondragover = (e) => {
|
||||||
console.log("[Playlist track ondragover] dragSource:", dragSource);
|
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
e.dataTransfer.dropEffect = dragSource === 'playlist' ? "move" : "copy";
|
e.dataTransfer.dropEffect = dragSource === 'playlist' ? "move" : "copy";
|
||||||
|
|
||||||
|
|
@ -357,8 +332,6 @@
|
||||||
div.classList.remove("drop-above", "drop-below");
|
div.classList.remove("drop-above", "drop-below");
|
||||||
element.classList.remove("drop-target");
|
element.classList.remove("drop-target");
|
||||||
|
|
||||||
console.log("[Track ondrop] dragSource:", dragSource, "trackIds:", draggedTrackIds, "dropTargetIndex:", dropTargetIndex);
|
|
||||||
|
|
||||||
if (draggedTrackIds.length > 0 && dropTargetIndex !== null) {
|
if (draggedTrackIds.length > 0 && dropTargetIndex !== null) {
|
||||||
if (dragSource === 'playlist') {
|
if (dragSource === 'playlist') {
|
||||||
// Reorder within playlist
|
// Reorder within playlist
|
||||||
|
|
@ -422,8 +395,16 @@
|
||||||
if (type === 'queue') {
|
if (type === 'queue') {
|
||||||
draggedIndices = selection.queue.has(index) ? [...selection.queue] : [index];
|
draggedIndices = selection.queue.has(index) ? [...selection.queue] : [index];
|
||||||
draggedTrackIds = draggedIndices.map(i => M.queue[i]?.id).filter(Boolean);
|
draggedTrackIds = draggedIndices.map(i => M.queue[i]?.id).filter(Boolean);
|
||||||
|
} else if (type === 'playlist') {
|
||||||
|
// Playlist uses indices for selection (supports duplicates)
|
||||||
|
draggedIndices = selection.playlist.has(index) ? [...selection.playlist] : [index];
|
||||||
|
draggedTrackIds = draggedIndices.map(i => {
|
||||||
|
const t = currentTracks[i];
|
||||||
|
return t ? (t.track || t).id : null;
|
||||||
|
}).filter(Boolean);
|
||||||
} else {
|
} else {
|
||||||
draggedTrackIds = selection[type].has(trackId) ? [...selection[type]] : [trackId];
|
// Library uses trackIds
|
||||||
|
draggedTrackIds = selection.library.has(trackId) ? [...selection.library] : [trackId];
|
||||||
draggedIndices = [];
|
draggedIndices = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -448,7 +429,6 @@
|
||||||
|
|
||||||
// Execute deferred render if any
|
// Execute deferred render if any
|
||||||
if (pendingRender) {
|
if (pendingRender) {
|
||||||
console.log("[handleDragEnd] Executing deferred render for:", type);
|
|
||||||
setTimeout(() => render(), 50);
|
setTimeout(() => render(), 50);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -478,7 +458,6 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleDrop(e, div, index) {
|
function handleDrop(e, div, index) {
|
||||||
console.log("[handleDrop] type:", type, "dragSource:", dragSource, "dropTargetIndex:", dropTargetIndex, "draggedIndices:", draggedIndices);
|
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
div.classList.remove("drop-above", "drop-below");
|
div.classList.remove("drop-above", "drop-below");
|
||||||
|
|
||||||
|
|
@ -616,7 +595,6 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
function showContextMenu(e, track, index, canEdit) {
|
function showContextMenu(e, track, index, canEdit) {
|
||||||
console.log("[showContextMenu] type:", type, "canEdit:", canEdit, "canRemove:", canRemove, "playlistId:", playlistId);
|
|
||||||
const trackId = track.id || track.filename;
|
const trackId = track.id || track.filename;
|
||||||
const title = track.title?.trim() || (track.filename || trackId || "Unknown").replace(/\.[^.]+$/, "");
|
const title = track.title?.trim() || (track.filename || trackId || "Unknown").replace(/\.[^.]+$/, "");
|
||||||
|
|
||||||
|
|
@ -779,7 +757,6 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
async function removeFromQueue(indices) {
|
async function removeFromQueue(indices) {
|
||||||
console.log("[removeFromQueue] indices:", indices, "channelId:", M.currentChannelId);
|
|
||||||
if (!M.currentChannelId) return;
|
if (!M.currentChannelId) return;
|
||||||
|
|
||||||
const res = await fetch("/api/channels/" + M.currentChannelId + "/queue", {
|
const res = await fetch("/api/channels/" + M.currentChannelId + "/queue", {
|
||||||
|
|
@ -796,7 +773,6 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
async function removeFromPlaylist(indices) {
|
async function removeFromPlaylist(indices) {
|
||||||
console.log("[removeFromPlaylist] indices:", indices, "playlistId:", playlistId);
|
|
||||||
if (!playlistId) return;
|
if (!playlistId) return;
|
||||||
|
|
||||||
const res = await fetch(`/api/playlists/${playlistId}/tracks`, {
|
const res = await fetch(`/api/playlists/${playlistId}/tracks`, {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue