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');
|
||||
}
|
||||
|
||||
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) {
|
||||
if (this.isActive(view)) {
|
||||
this.contentElement.innerHTML = '';
|
||||
|
|
|
|||
|
|
@ -30,8 +30,7 @@ export function initializeUIInteractions(player, api) {
|
|||
});
|
||||
|
||||
// Queue panel
|
||||
const openQueuePanel = () => {
|
||||
const renderControls = (container) => {
|
||||
const renderQueueControls = (container) => {
|
||||
const currentQueue = player.getCurrentQueue();
|
||||
const showClearBtn = currentQueue.length > 0;
|
||||
|
||||
|
|
@ -52,12 +51,12 @@ export function initializeUIInteractions(player, api) {
|
|||
if (clearBtn) {
|
||||
clearBtn.addEventListener('click', () => {
|
||||
player.clearQueue();
|
||||
openQueuePanel(); // Re-render to update state
|
||||
refreshQueuePanel();
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
const renderContent = (container) => {
|
||||
const renderQueueContent = (container) => {
|
||||
const currentQueue = player.getCurrentQueue();
|
||||
|
||||
if (currentQueue.length === 0) {
|
||||
|
|
@ -104,11 +103,11 @@ export function initializeUIInteractions(player, api) {
|
|||
if (removeBtn) {
|
||||
e.stopPropagation();
|
||||
player.removeFromQueue(index);
|
||||
openQueuePanel(); // Re-render
|
||||
refreshQueuePanel();
|
||||
return;
|
||||
}
|
||||
player.playAtIndex(index);
|
||||
openQueuePanel(); // Re-render to update playing state
|
||||
refreshQueuePanel();
|
||||
});
|
||||
|
||||
item.addEventListener('dragstart', (e) => {
|
||||
|
|
@ -128,13 +127,18 @@ export function initializeUIInteractions(player, api) {
|
|||
e.preventDefault();
|
||||
if (draggedQueueIndex !== null && 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);
|
||||
|
|
@ -142,7 +146,7 @@ export function initializeUIInteractions(player, api) {
|
|||
// Expose renderQueue for external updates (e.g. shuffle, add to queue)
|
||||
window.renderQueueFunction = () => {
|
||||
if (sidePanelManager.isActive('queue')) {
|
||||
openQueuePanel(); // Re-open acts as update if active
|
||||
refreshQueuePanel();
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue