Skip to content

Commit

Permalink
Elements: Fix pin slot (#2465)
Browse files Browse the repository at this point in the history
  • Loading branch information
rubenpingol-xibo committed Apr 2, 2024
1 parent 31e71df commit 3e4b955
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions modules/src/xibo-player.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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
Expand Down Expand Up @@ -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,
Expand All @@ -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;
Expand Down

0 comments on commit 3e4b955

Please sign in to comment.