Fix triggering blinky play. Fixes #120

This commit is contained in:
Matthew Stratford 2020-10-27 19:22:21 +00:00
parent 529f86bcc6
commit 4e9c57befb
No known key found for this signature in database
GPG key ID: 9E53C8B3F0B57395

View file

@ -192,9 +192,17 @@ function TimingButtons({ id }: { id: number }) {
}
export function Player({ id }: { id: number }) {
// Define time remaining (secs) when the play icon should flash.
const SECS_REMAINING_WARNING = 20;
// We want to force update the selector when we pass the SECS_REMAINING_WARNING barrier.
const playerState = useSelector(
(state: RootState) => state.mixer.players[id],
(a, b) =>
!(
a.timeRemaining <= SECS_REMAINING_WARNING &&
b.timeRemaining > SECS_REMAINING_WARNING
) &&
shallowEqual(
omit(a, "timeCurrent", "timeRemaining"),
omit(b, "timeCurrent", "timeRemaining")
@ -319,7 +327,7 @@ export function Player({ id }: { id: number }) {
onClick={() => dispatch(MixerState.play(id))}
className={
playerState.state === "playing"
? playerState.timeRemaining <= 15
? playerState.timeRemaining <= SECS_REMAINING_WARNING
? "sp-state-playing sp-ending-soon"
: "sp-state-playing"
: ""