Merge pull request #288 from UniversityRadioYork/mstratford/webstudio-played
Fix repeat all not triggering
This commit is contained in:
commit
87ca8a8106
1 changed files with 17 additions and 26 deletions
|
@ -666,19 +666,7 @@ export const load = (
|
||||||
}
|
}
|
||||||
if (state.repeat === "one") {
|
if (state.repeat === "one") {
|
||||||
playerInstance.play();
|
playerInstance.play();
|
||||||
} else if (state.repeat === "all") {
|
} else if (state.autoAdvance && "channel" in item) {
|
||||||
if ("channel" in item) {
|
|
||||||
// it's not in the CML/libraries "column"
|
|
||||||
const itsChannel = getState()
|
|
||||||
.showplan.plan!.filter((x) => x.channel === item.channel)
|
|
||||||
.sort((x, y) => x.weight - y.weight);
|
|
||||||
const itsIndex = itsChannel.indexOf(item);
|
|
||||||
if (itsIndex === itsChannel.length - 1) {
|
|
||||||
dispatch(load(player, itsChannel[0]));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else if (state.autoAdvance) {
|
|
||||||
if ("channel" in item) {
|
|
||||||
// it's not in the CML/libraries "column"
|
// it's not in the CML/libraries "column"
|
||||||
const itsChannel = getState()
|
const itsChannel = getState()
|
||||||
.showplan.plan!.filter((x) => x.channel === item.channel)
|
.showplan.plan!.filter((x) => x.channel === item.channel)
|
||||||
|
@ -689,11 +677,14 @@ export const load = (
|
||||||
const itsIndex = itsChannel.findIndex(
|
const itsIndex = itsChannel.findIndex(
|
||||||
(x) => itemId(x) === itemId(item)
|
(x) => itemId(x) === itemId(item)
|
||||||
);
|
);
|
||||||
if (itsIndex > -1 && itsIndex !== itsChannel.length - 1) {
|
if (itsIndex === itsChannel.length - 1 && state.repeat === "all") {
|
||||||
|
// Autoadvance and repeat all, we're on last item so jump to top!
|
||||||
|
dispatch(load(player, itsChannel[0]));
|
||||||
|
} else if (itsIndex > -1 && itsIndex !== itsChannel.length - 1) {
|
||||||
|
// We found the item and we're not the last item, load the next one!
|
||||||
dispatch(load(player, itsChannel[itsIndex + 1]));
|
dispatch(load(player, itsChannel[itsIndex + 1]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// Double-check we haven't been aborted since
|
// Double-check we haven't been aborted since
|
||||||
|
|
Loading…
Reference in a new issue