Merge pull request #182 from UniversityRadioYork/markspolakovs-reduce-item-render

Reduce Item renders
This commit is contained in:
Marks Polakovs 2020-11-10 23:06:18 +00:00 committed by GitHub
commit ae37c73b3c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -25,14 +25,15 @@ export const Item = memo(function Item({
const isReal = "timeslotitemid" in x; const isReal = "timeslotitemid" in x;
const isGhost = "ghostid" in x; const isGhost = "ghostid" in x;
const playerState = useSelector((state: RootState) => const loadedItem = useSelector(
column > -1 ? state.mixer.players[column] : undefined (state: RootState) =>
column > -1 ? state.mixer.players[column]?.loadedItem : null,
(a, b) =>
(a === null && b === null) ||
(a !== null && b !== null && itemId(a) === itemId(b))
); );
const isLoaded = const isLoaded = loadedItem !== null ? itemId(loadedItem) === id : false;
playerState &&
playerState.loadedItem !== null &&
itemId(playerState.loadedItem) === id;
const showDebug = useSelector( const showDebug = useSelector(
(state: RootState) => state.settings.showDebugInfo (state: RootState) => state.settings.showDebugInfo
@ -59,14 +60,7 @@ export const Item = memo(function Item({
"item " + "item " +
("played" in x ? (x.played ? "played " : "") : "") + ("played" in x ? (x.played ? "played " : "") : "") +
x.type + x.type +
`${ `${column >= 0 && isLoaded ? " active" : ""}`
column >= 0 &&
playerState &&
playerState.loadedItem !== null &&
itemId(playerState.loadedItem) === id
? " active"
: ""
}`
} }
onClick={triggerClick} onClick={triggerClick}
{...provided.draggableProps} {...provided.draggableProps}