ISSUE-045 - Chyron Body - Taking a moment to rename some reducers to be more consistant (verb in front).

This commit is contained in:
Kyle Geib committed 2022-02-09 13:55:52 -05:00
1 parent dbab285578
commit fd18703d1a
5 files changed
+28 -28

No files matched your search

@@ -8,9 +8,9 @@ import { FaPlay, FaStepForward, FaStop } from "react-icons/fa";
import { broadcastGraphicsSelector } from "../../../../features/broadcast/graphics/broadcastGraphicsSelector"; import { broadcastGraphicsSelector } from "../../../../features/broadcast/graphics/broadcastGraphicsSelector";
import { broadcastDirectorSelector } from "../../../../features/broadcast/director/broadcastDirectorSelector"; import { broadcastDirectorSelector } from "../../../../features/broadcast/director/broadcastDirectorSelector";
import { import {
chyronsClear, clearChyrons,
chyronsOpenStateIncrement, incrementChyronsOpenState,
chyronsSet, setChyrons,
} 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 } from "../../../../types/state";
@@ -63,16 +63,16 @@ export function ChyronsDirectorControls() {
secondary: secondaryCar != null ? buildDriverChyron(secondaryCar) : null, secondary: secondaryCar != null ? buildDriverChyron(secondaryCar) : null,
}, },
}; };
dispatch(chyronsSet(newChyrons)); dispatch(setChyrons(newChyrons));
} }
}; };
const onNext = () => { const onNext = () => {
dispatch(chyronsOpenStateIncrement()); dispatch(incrementChyronsOpenState());
}; };
const onClose = () => { const onClose = () => {
dispatch(chyronsClear()); dispatch(clearChyrons());
}; };
const buildDriverChyron = (car: Car): BGChyronDriver => ({ const buildDriverChyron = (car: Car): BGChyronDriver => ({
@@ -3,7 +3,7 @@ import { findIndex } from "lodash";
import { useDispatch, useSelector } from "react-redux"; import { useDispatch, useSelector } from "react-redux";
import { broadcastDirectorSelector } from "../../../../features/broadcast/director/broadcastDirectorSelector"; import { broadcastDirectorSelector } from "../../../../features/broadcast/director/broadcastDirectorSelector";
import { selectedCarsAdd, selectedCarsClear, selectedCarsRemove } from "../../../../features/broadcast/director/broadcastDirectorSlice"; import { pushSelectedCars, clearSelectedCars, removeSelectedCars } from "../../../../features/broadcast/director/broadcastDirectorSlice";
import { eventSelector } from "../../../../features/event/eventSelector"; import { eventSelector } from "../../../../features/event/eventSelector";
import { Car } from "../../../../types/state"; import { Car } from "../../../../types/state";
import { carMatch } from "../../../../utils/comparators"; import { carMatch } from "../../../../utils/comparators";
@@ -21,13 +21,13 @@ export function GridSelection() {
const carClick = (car: Car, selected: boolean) => () => { const carClick = (car: Car, selected: boolean) => () => {
if (selected) { if (selected) {
dispatch(selectedCarsRemove(car)); dispatch(removeSelectedCars(car));
} else { } else {
dispatch(selectedCarsAdd(car)); dispatch(pushSelectedCars(car));
} }
}; };
const carDoubleClick = (car: Car) => () => { const carDoubleClick = (car: Car) => () => {
dispatch(selectedCarsClear(car)); dispatch(clearSelectedCars(car));
}; };
return ( return (
@@ -13,16 +13,16 @@ export const broadcastDirectorSlice = createSlice({
name: "broadcastDirector", name: "broadcastDirector",
initialState, initialState,
reducers: { reducers: {
selectedCarsAdd: (state, action: PayloadAction<Car>) => { pushSelectedCars: (state, action: PayloadAction<Car>) => {
const index = findIndex(state.selectedCars, carMatch(action.payload)); const index = findIndex(state.selectedCars, carMatch(action.payload));
if (index === -1) { if (index === -1) {
state.selectedCars = state.selectedCars.concat(action.payload); state.selectedCars = state.selectedCars.concat(action.payload);
} }
}, },
selectedCarsSet: (state, action: PayloadAction<Car>) => { // Might be removed. setSelectedCars: (state, action: PayloadAction<Car>) => { // Might be removed.
state.selectedCars = [action.payload]; state.selectedCars = [action.payload];
}, },
selectedCarsRemove: (state, action: PayloadAction<Car | number>) => { removeSelectedCars: (state, action: PayloadAction<Car | number>) => {
const index = typeof action.payload === "number" const index = typeof action.payload === "number"
? action.payload ? action.payload
: findIndex(state.selectedCars, carMatch(action.payload)); : findIndex(state.selectedCars, carMatch(action.payload));
@@ -36,7 +36,7 @@ export const broadcastDirectorSlice = createSlice({
* car. * car.
* @param action Car (optional) * @param action Car (optional)
*/ */
selectedCarsClear: (state, action: PayloadAction<Optional<Car>>) => { clearSelectedCars: (state, action: PayloadAction<Optional<Car>>) => {
if (action.payload == null) { if (action.payload == null) {
state.selectedCars = []; state.selectedCars = [];
} else { } else {
@@ -47,9 +47,9 @@ export const broadcastDirectorSlice = createSlice({
}); });
export const { export const {
selectedCarsAdd, pushSelectedCars,
selectedCarsSet, setSelectedCars,
selectedCarsRemove, removeSelectedCars,
selectedCarsClear, clearSelectedCars,
} = broadcastDirectorSlice.actions; } = broadcastDirectorSlice.actions;
export default broadcastDirectorSlice.reducer; export default broadcastDirectorSlice.reducer;
@@ -10,10 +10,10 @@ export const broadcastGraphicsSlice = createSlice({
name: "broadcastGraphics", name: "broadcastGraphics",
initialState, initialState,
reducers: { reducers: {
chyronsSet: (state, action: PayloadAction<BGChyrons>) => { setChyrons: (state, action: PayloadAction<BGChyrons>) => {
state.chyrons = action.payload; state.chyrons = action.payload;
}, },
chyronsOpenStateSet: (state, action: PayloadAction<OpenState>) => { setChyronsOpenState: (state, action: PayloadAction<OpenState>) => {
if (state.chyrons == null) return; if (state.chyrons == null) return;
state.chyrons.openState = action.payload; state.chyrons.openState = action.payload;
@@ -21,7 +21,7 @@ export const broadcastGraphicsSlice = createSlice({
state.chyrons.openState = action.payload; state.chyrons.openState = action.payload;
} }
}, },
chyronsOpenStateIncrement: (state) => { incrementChyronsOpenState: (state) => {
if (state.chyrons == null) return; if (state.chyrons == null) return;
++state.chyrons.openState; ++state.chyrons.openState;
@@ -29,16 +29,16 @@ export const broadcastGraphicsSlice = createSlice({
++state.chyrons.openState; ++state.chyrons.openState;
} }
}, },
chyronsClear: (state) => { clearChyrons: (state) => {
state.chyrons = null; state.chyrons = null;
}, },
}, },
}); });
export const { export const {
chyronsSet, setChyrons,
chyronsOpenStateSet, setChyronsOpenState,
chyronsOpenStateIncrement, incrementChyronsOpenState,
chyronsClear, clearChyrons,
} = broadcastGraphicsSlice.actions; } = broadcastGraphicsSlice.actions;
export default broadcastGraphicsSlice.reducer; export default broadcastGraphicsSlice.reducer;
+2 -2
View File
@@ -46,13 +46,13 @@ export const eventSlice = createSlice({
name: "event", name: "event",
initialState, initialState,
reducers: { reducers: {
courseFlagSet: (state, action: PayloadAction<CourseFlag>) => { setCourseFlag: (state, action: PayloadAction<CourseFlag>) => {
state.courseStatus.courseFlag = action.payload; state.courseStatus.courseFlag = action.payload;
}, },
}, },
}); });
export const { export const {
courseFlagSet, setCourseFlag,
} = eventSlice.actions; } = eventSlice.actions;
export default eventSlice.reducer; export default eventSlice.reducer;