feat: migrate legacy playout workflow and scenes
This commit is contained in:
@@ -32,6 +32,7 @@
|
||||
if (!snapshot || snapshot.pending) return "busy";
|
||||
if (snapshot.outcomeUnknown) return "outcome-unknown";
|
||||
if (!snapshot.commandAvailable) return "unavailable";
|
||||
if (snapshot.refreshFaulted && command !== "take-out") return "refresh-fault";
|
||||
|
||||
const onAir = snapshot.engineState === "PROGRAM" || Boolean(snapshot.onAirCode);
|
||||
const prepared = snapshot.engineState === "PREPARED" || Boolean(snapshot.preparedCode);
|
||||
@@ -48,10 +49,47 @@
|
||||
payload.command === pending.command);
|
||||
}
|
||||
|
||||
function canClearCommandError(error, sessionQuarantined) {
|
||||
if (sessionQuarantined || !error) return !sessionQuarantined;
|
||||
return error.outcomeUnknown !== true && error.code !== "WEB_TIMEOUT" &&
|
||||
error.nonClearable !== true;
|
||||
}
|
||||
|
||||
function playlistSnapshotLocked(snapshot) {
|
||||
return Boolean(snapshot && (
|
||||
snapshot.pending ||
|
||||
snapshot.outcomeUnknown ||
|
||||
snapshot.engineState === "PREPARED" ||
|
||||
snapshot.engineState === "PROGRAM" ||
|
||||
snapshot.preparedCode ||
|
||||
snapshot.onAirCode));
|
||||
}
|
||||
|
||||
function shouldClearRefreshError(error, refreshFaulted) {
|
||||
return !refreshFaulted && error?.isRefreshFault === true;
|
||||
}
|
||||
|
||||
function resolveStoredCatalogIndex(catalog, builderKey, cutCode) {
|
||||
if (!Array.isArray(catalog)) return -1;
|
||||
const exact = catalog.findIndex(item =>
|
||||
item && item.reachable !== false && item.builderKey === builderKey);
|
||||
if (exact >= 0) return exact;
|
||||
const code = String(cutCode || "");
|
||||
return catalog.findIndex(item => {
|
||||
if (!item || item.reachable === false) return false;
|
||||
const aliases = Array.isArray(item.aliases) ? item.aliases : [String(item.code || "")];
|
||||
return aliases.includes(code);
|
||||
});
|
||||
}
|
||||
|
||||
return {
|
||||
normalizeConnectionState,
|
||||
responseTimeoutFromNative,
|
||||
commandBlockReason,
|
||||
matchesPendingCommand
|
||||
matchesPendingCommand,
|
||||
canClearCommandError,
|
||||
playlistSnapshotLocked,
|
||||
shouldClearRefreshError,
|
||||
resolveStoredCatalogIndex
|
||||
};
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user