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