Skip to content

Commit

Permalink
Show timer also for spectator
Browse files Browse the repository at this point in the history
  • Loading branch information
ChristophNiehoff committed Jun 9, 2023
1 parent 1574fe9 commit 6dd4bdf
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/client/components/board/board.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,8 @@ class Board extends React.Component {
this.props.ctx.activePlayers[this.props.playerID] === 'threats'
? true
: false;
// If this.props.playerID is unset, then we are in spectator mode and check whether the first player is in threat stage.
const shouldShowTimer = isInThreatStage || (!this.props.playerID && this.props.ctx.activePlayers?.[0] === 'threats');
const active = current || isInThreatStage;

let dealtCard = getDealtCard(this.props.G);
Expand Down Expand Up @@ -164,7 +166,7 @@ class Board extends React.Component {
secret={this.props.credentials}
/>
<Timer
active={isInThreatStage}
active={shouldShowTimer}
targetTime={this.props.G.turnFinishTargetTime}
duration={parseInt(this.props.G.turnDuration)}
key={isInThreatStage}
Expand Down
2 changes: 2 additions & 0 deletions src/client/components/timer/timer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ type TimerProps = {
const Timer: FC<TimerProps> = ({ active = true, duration, targetTime }) => {
const [painted, setPainted] = useState(false);

console.log(`Printing TIMER: active=${active}`);

useEffect(() => {
// This is a bit of a workaround
// The timer is updated with window.requestAnimationFrame however the page can be rendered before
Expand Down

0 comments on commit 6dd4bdf

Please sign in to comment.