diff --git a/modules/src/xibo-player.js b/modules/src/xibo-player.js index df2519cb87..e14eb77c39 100644 --- a/modules/src/xibo-player.js +++ b/modules/src/xibo-player.js @@ -335,6 +335,7 @@ const XiboPlayer = function() { if (data.length > 0) { let lastSlotFilled = null; + const filledPinnedSlot = []; dataLoop: for (const [dataItemKey] of Object.entries(data)) { let hasSlotFilled = false; @@ -356,6 +357,11 @@ const XiboPlayer = function() { const slotItems = itemObj.items; const pinnedItems = itemObj.pinnedItems; const currentSlot = itemObj.slot; + let nextSlot = currentSlot + 1; + + if (nextSlot > maxSlot) { + nextSlot = currentSlot; + } // Skip if currentKey is less than the currentSlot // This occurs when a data slot has been skipped @@ -411,6 +417,13 @@ const XiboPlayer = function() { lastSlotFilled = currentSlot; } + if (pinnedSlots.includes(currentSlot) && + lastSlotFilled === currentSlot && + !filledPinnedSlot.includes(currentSlot) + ) { + filledPinnedSlot.push(currentSlot); + } + itemObj.dataKeys = [ ...itemObj.dataKeys, currentKey, @@ -420,6 +433,18 @@ const XiboPlayer = function() { hasSlotFilled = false; if (lastSlotFilled % maxSlot === 0) { lastSlotFilled = null; + } else if (currentKey > maxSlot && + nextSlot !== currentSlot && + pinnedSlots.includes(nextSlot) && + filledPinnedSlot.includes(nextSlot) + ) { + // Next slot is a pinned slot and has been filled + // So, current item must be passed to next non-pinned slot + if (nextSlot === maxSlot) { + lastSlotFilled = null; + } else { + lastSlotFilled = nextSlot; + } } break;