- askGameAgain: function() {
- this.gameIsLoading = true;
- const currentUrl = document.location.href;
- const doAskGame = () => {
- if (document.location.href != currentUrl) return; //page change
- this.fetchGame((game) => {
- if (!!game)
- // This is my game: just reload.
- this.loadGame(game);
- else
- // Just ask fullgame again (once!), this is much simpler.
- // If this fails, the user could just reload page :/
- this.send("askfullgame");
- });
- };
- // Delay of at least 2s between two game requests
- const now = Date.now();
- const delay = Math.max(2000 - (now - this.askGameTime), 0);
- this.askGameTime = now;
- setTimeout(doAskGame, delay);
- },