Merge branch 'main' of github.com:SamidyFR/monochrome
This commit is contained in:
commit
c31684ecf2
2 changed files with 110 additions and 93 deletions
|
|
@ -44,6 +44,19 @@ export class SidePanelManager {
|
||||||
return this.currentView === view && this.panel.classList.contains('active');
|
return this.currentView === view && this.panel.classList.contains('active');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
refresh(view, renderControlsCallback, renderContentCallback) {
|
||||||
|
if (this.isActive(view)) {
|
||||||
|
if (renderControlsCallback) {
|
||||||
|
this.controlsElement.innerHTML = '';
|
||||||
|
renderControlsCallback(this.controlsElement);
|
||||||
|
}
|
||||||
|
if (renderContentCallback) {
|
||||||
|
this.contentElement.innerHTML = '';
|
||||||
|
renderContentCallback(this.contentElement);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
updateContent(view, renderContentCallback) {
|
updateContent(view, renderContentCallback) {
|
||||||
if (this.isActive(view)) {
|
if (this.isActive(view)) {
|
||||||
this.contentElement.innerHTML = '';
|
this.contentElement.innerHTML = '';
|
||||||
|
|
|
||||||
|
|
@ -30,8 +30,7 @@ export function initializeUIInteractions(player, api) {
|
||||||
});
|
});
|
||||||
|
|
||||||
// Queue panel
|
// Queue panel
|
||||||
const openQueuePanel = () => {
|
const renderQueueControls = (container) => {
|
||||||
const renderControls = (container) => {
|
|
||||||
const currentQueue = player.getCurrentQueue();
|
const currentQueue = player.getCurrentQueue();
|
||||||
const showClearBtn = currentQueue.length > 0;
|
const showClearBtn = currentQueue.length > 0;
|
||||||
|
|
||||||
|
|
@ -52,12 +51,12 @@ export function initializeUIInteractions(player, api) {
|
||||||
if (clearBtn) {
|
if (clearBtn) {
|
||||||
clearBtn.addEventListener('click', () => {
|
clearBtn.addEventListener('click', () => {
|
||||||
player.clearQueue();
|
player.clearQueue();
|
||||||
openQueuePanel(); // Re-render to update state
|
refreshQueuePanel();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const renderContent = (container) => {
|
const renderQueueContent = (container) => {
|
||||||
const currentQueue = player.getCurrentQueue();
|
const currentQueue = player.getCurrentQueue();
|
||||||
|
|
||||||
if (currentQueue.length === 0) {
|
if (currentQueue.length === 0) {
|
||||||
|
|
@ -104,11 +103,11 @@ export function initializeUIInteractions(player, api) {
|
||||||
if (removeBtn) {
|
if (removeBtn) {
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
player.removeFromQueue(index);
|
player.removeFromQueue(index);
|
||||||
openQueuePanel(); // Re-render
|
refreshQueuePanel();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
player.playAtIndex(index);
|
player.playAtIndex(index);
|
||||||
openQueuePanel(); // Re-render to update playing state
|
refreshQueuePanel();
|
||||||
});
|
});
|
||||||
|
|
||||||
item.addEventListener('dragstart', (e) => {
|
item.addEventListener('dragstart', (e) => {
|
||||||
|
|
@ -128,13 +127,18 @@ export function initializeUIInteractions(player, api) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
if (draggedQueueIndex !== null && draggedQueueIndex !== index) {
|
if (draggedQueueIndex !== null && draggedQueueIndex !== index) {
|
||||||
player.moveInQueue(draggedQueueIndex, index);
|
player.moveInQueue(draggedQueueIndex, index);
|
||||||
openQueuePanel(); // Re-render
|
refreshQueuePanel();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
sidePanelManager.open('queue', 'Queue', renderControls, renderContent);
|
const refreshQueuePanel = () => {
|
||||||
|
sidePanelManager.refresh('queue', renderQueueControls, renderQueueContent);
|
||||||
|
};
|
||||||
|
|
||||||
|
const openQueuePanel = () => {
|
||||||
|
sidePanelManager.open('queue', 'Queue', renderQueueControls, renderQueueContent);
|
||||||
};
|
};
|
||||||
|
|
||||||
queueBtn.addEventListener('click', openQueuePanel);
|
queueBtn.addEventListener('click', openQueuePanel);
|
||||||
|
|
@ -142,7 +146,7 @@ export function initializeUIInteractions(player, api) {
|
||||||
// Expose renderQueue for external updates (e.g. shuffle, add to queue)
|
// Expose renderQueue for external updates (e.g. shuffle, add to queue)
|
||||||
window.renderQueueFunction = () => {
|
window.renderQueueFunction = () => {
|
||||||
if (sidePanelManager.isActive('queue')) {
|
if (sidePanelManager.isActive('queue')) {
|
||||||
openQueuePanel(); // Re-open acts as update if active
|
refreshQueuePanel();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue