Allow setting refresh rate through url
This commit is contained in:
parent
68ea44eb02
commit
0bb97fc4a7
1 changed files with 7 additions and 1 deletions
|
@ -11,11 +11,17 @@ interface IAppState {
|
||||||
|
|
||||||
class App extends React.Component<{}, IAppState> {
|
class App extends React.Component<{}, IAppState> {
|
||||||
timerId?: ReturnType<typeof setInterval>;
|
timerId?: ReturnType<typeof setInterval>;
|
||||||
|
refreshSeconds: number;
|
||||||
|
|
||||||
constructor(props: {}) {
|
constructor(props: {}) {
|
||||||
super(props);
|
super(props);
|
||||||
this.state = {passages: [{ligne: undefined, delais: [undefined]}]};
|
this.state = {passages: [{ligne: undefined, delais: [undefined]}]};
|
||||||
this.timerId = undefined;
|
this.timerId = undefined;
|
||||||
|
const urlParams = new URLSearchParams(window.location.search);
|
||||||
|
this.refreshSeconds = Number(urlParams.get("refreshSeconds"));
|
||||||
|
if (this.refreshSeconds <= 5) {
|
||||||
|
this.refreshSeconds = 60;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
|
@ -42,7 +48,7 @@ class App extends React.Component<{}, IAppState> {
|
||||||
|
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
this.refresh();
|
this.refresh();
|
||||||
this.timerId = setInterval(this.refresh.bind(this), 60000);
|
this.timerId = setInterval(this.refresh.bind(this), this.refreshSeconds * 1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
componentWillUnmount() {
|
componentWillUnmount() {
|
||||||
|
|
Loading…
Reference in a new issue