ISSUE-075 - Switched Chyrons state to using gridSpot instead of Car data. This lets the car's data update in real time.

Got a good result as the chyrons will not swap positions while open. But will swap if closed and opened a moment later. So, it all works the way I want it to.
This commit is contained in:
Kyle Geib committed 2022-03-17 13:00:59 -04:00
1 parent d9b30f64f2
commit 86b12a1f84
3 files changed
+20 -15

No files matched your search

@@ -14,7 +14,7 @@ import {
setChyronsOpenState, setChyronsOpenState,
} from "../../../../features/broadcast/graphics/broadcastGraphicsSlice"; } from "../../../../features/broadcast/graphics/broadcastGraphicsSlice";
import { flagModeList, getChyronModesList, getChyronSubModesList } from "../../../../domain/data/broadcastGraphics"; import { flagModeList, getChyronModesList, getChyronSubModesList } from "../../../../domain/data/broadcastGraphics";
import { BGChyronDriver, BGChyronMode, BGChyrons, BGChyronSubMode, Car, FlagMode } from "../../../../types/state"; import { BGChyronDriver, BGChyronMode, BGChyrons, BGChyronSubMode, Car, FlagMode, GridSpot } from "../../../../types/state";
import { SlotSelector } from "../../../Common/Inputs/SlotSelector"; import { SlotSelector } from "../../../Common/Inputs/SlotSelector";
import { Button, CloseButton, OpenButton, Title } from "./styles"; import { Button, CloseButton, OpenButton, Title } from "./styles";
@@ -62,29 +62,31 @@ export function ChyronsDirectorControls() {
const buildDriver = () => { const buildDriver = () => {
if (selectedCars.length === 0) return; if (selectedCars.length === 0) return;
let primaryCar = grid[selectedCars[0]]; let primaryCarGridSpot = selectedCars[0];
let secondaryCar = selectedCars.length > 1 ? grid[selectedCars[1]] : null; let secondaryCarGridSpot = selectedCars[1] ?? -1;
// Auto-sort drivers by position so trailing car always appears second. // Auto-sort drivers by position so trailing car appears second on mounting.
if (chyronSubMode === "medium" && secondaryCar != null if (chyronSubMode === "medium" && secondaryCarGridSpot != -1
&& secondaryCar.position < primaryCar.position) { && grid[secondaryCarGridSpot].position < grid[primaryCarGridSpot].position) {
secondaryCar = grid[selectedCars[0]]; secondaryCarGridSpot = selectedCars[0];
primaryCar = grid[selectedCars[1]]; primaryCarGridSpot = selectedCars[1];
} }
const newChyrons: BGChyrons = { const newChyrons: BGChyrons = {
openState: 0, openState: 0,
mode: chyronMode, mode: chyronMode,
subMode: chyronSubMode, subMode: chyronSubMode,
driver: { driver: {
primary: buildDriverChyron(primaryCar), primary: buildDriverChyron(primaryCarGridSpot),
secondary: secondaryCar != null ? buildDriverChyron(secondaryCar) : null, secondary: secondaryCarGridSpot !== -1
? buildDriverChyron(secondaryCarGridSpot) : null,
}, },
}; };
dispatch(setChyrons(newChyrons)); dispatch(setChyrons(newChyrons));
}; };
const buildDriverChyron = (car: Car): BGChyronDriver => ({ const buildDriverChyron = (carGridSpot: GridSpot): BGChyronDriver => ({
car, carGridSpot,
flagMode, flagMode,
showPosFlag: posFlag, showPosFlag: posFlag,
showDriverNumber: driverNum, showDriverNumber: driverNum,
@@ -1,11 +1,12 @@
import { useSpring } from "@react-spring/web"; import { useSpring } from "@react-spring/web";
import { useDispatch } from "react-redux"; import { useDispatch, useSelector } from "react-redux";
import { BGChyronDriver, BGChyronSubMode, CarStatus, OpenState } from "../../../../types/state"; import { BGChyronDriver, BGChyronSubMode, CarStatus, OpenState } from "../../../../types/state";
import { DebugDurationProps } from "../../../../types/style"; import { DebugDurationProps } from "../../../../types/style";
import { clearChyrons } from "../../../../features/broadcast/graphics/broadcastGraphicsSlice"; import { clearChyrons } from "../../../../features/broadcast/graphics/broadcastGraphicsSlice";
import { theme } from "../../../../shared/theme"; import { theme } from "../../../../shared/theme";
import { outlineClipPath } from "../../../../utils/styling"; import { outlineClipPath } from "../../../../utils/styling";
import { eventSelector } from "../../../../features/event/eventSelector";
import { DriverNumber } from "../../Common/DriverNumber"; import { DriverNumber } from "../../Common/DriverNumber";
import { AngledFlag } from "../../Common/AngledFlag"; import { AngledFlag } from "../../Common/AngledFlag";
@@ -45,7 +46,9 @@ export function ChyronDriver({
: subMode === "large" ? [638, 98] : subMode === "large" ? [638, 98]
: [0, 0]; : [0, 0];
const { car, flagMode, showPosFlag, showDriverNumber, showPortrait } = chyronData; const { carGridSpot, flagMode, showPosFlag, showDriverNumber, showPortrait } = chyronData;
const { grid } = useSelector(eventSelector);
const car = grid[carGridSpot];
const flagProps = flagMode === "country" const flagProps = flagMode === "country"
? { flagMode, flag: car.driver.nationality } ? { flagMode, flag: car.driver.nationality }
+1 -1
View File
@@ -321,7 +321,7 @@ export interface BGChyrons extends BGBaseState {
} }
export interface BGChyronDriver { export interface BGChyronDriver {
car: Car; carGridSpot: GridSpot;
flagMode: FlagMode; flagMode: FlagMode;
showPosFlag: boolean; showPosFlag: boolean;
showDriverNumber: boolean; showDriverNumber: boolean;