Merge pull request #182 from UniversityRadioYork/markspolakovs-reduce-item-render
Reduce Item renders
This commit is contained in:
commit
ae37c73b3c
1 changed files with 8 additions and 14 deletions
|
@ -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}
|
||||||
|
|
Loading…
Reference in a new issue