From c05d5bb9e0ade4d4b5ab693bf83722e85c5a7bf2 Mon Sep 17 00:00:00 2001 From: Felix Hamme Date: Wed, 6 Nov 2019 11:20:53 +0100 Subject: [PATCH] Fullscreen page: update matches every 3 seconds --- pages/tournament-fullscreen.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/pages/tournament-fullscreen.js b/pages/tournament-fullscreen.js index 5aa3f9f..dd422a7 100644 --- a/pages/tournament-fullscreen.js +++ b/pages/tournament-fullscreen.js @@ -51,11 +51,23 @@ class Main extends React.Component { this.onTournamentRequestError = this.onTournamentRequestError.bind(this); this.onTournamentMatchesRequestSuccess = this.onTournamentMatchesRequestSuccess.bind(this); this.onTournamentMatchesRequestError = this.onTournamentMatchesRequestError.bind(this); + this.updateMatches = this.updateMatches.bind(this); } componentDidMount() { const tournamentId = this.props.query.code; getTournamentMeta(tournamentId, this.onTournamentRequestSuccess, this.onTournamentRequestError); + this.updateMatches(); + const intervalId = setInterval(this.updateMatches, 3000); + this.setState({intervalId: intervalId}); + } + + componentWillUnmount() { + clearInterval(this.state.intervalId); + } + + updateMatches() { + const tournamentId = this.props.query.code; getTournamentMatches(tournamentId, this.onTournamentMatchesRequestSuccess, this.onTournamentMatchesRequestError); }