Skip to content

Commit

Permalink
Revert player init checks
Browse files Browse the repository at this point in the history
  • Loading branch information
myovchev committed Nov 6, 2024
1 parent 6130b99 commit 8a1426d
Showing 1 changed file with 4 additions and 16 deletions.
20 changes: 4 additions & 16 deletions modules/@apostrophecms/util/ui/src/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ export default () => {
target[prop] = value;
// run the player if we missed the initial run
if (widgetPlayersConfig.initialized) {
apos.util.runPlayers(null, { newPlayersOnly: true });
apos.util.runPlayers();
}
return true;
}
Expand Down Expand Up @@ -196,21 +196,9 @@ export default () => {
// Your player is guaranteed to run only once per widget. Hint:
// DON'T try to find all the widgets. DO just enhance `el`.
// This is a computer science principle known as "separation of concerns."
//
// The second argument is an options object.
// If the `newPlayersOnly` option is true, only widget player types whose players
// have not been invoked before will be invoked. This option is used internally
// and shouldn't be needed outside of the core initialization process.

apos.util.runPlayers = function (el, { newPlayersOnly = false } = {}) {
apos.util.runPlayers = function (el) {
const players = apos.util.widgetPlayers;
let playerList = Object.keys(players);

// Guard against multiple player runs early during initialization.
if (newPlayersOnly) {
playerList = playerList.filter(player => !players[player].initialized);
playerList.forEach(player => (players[player].initialized = true));
}
const playerList = Object.keys(players);

for (let i = 0; i < playerList.length; i++) {
const playerOpts = players[playerList[i]];
Expand All @@ -236,7 +224,7 @@ export default () => {
if (!apos.bus) {
apos.util.onReady(function () {
widgetPlayersConfig.initialized = true;
apos.util.runPlayers(null, { newPlayersOnly: true });
apos.util.runPlayers();
});
}

Expand Down

0 comments on commit 8a1426d

Please sign in to comment.