mirror of
https://github.com/aquatix/alfagok.git
synced 2025-12-06 21:05:10 +01:00
Better async at the start
This commit is contained in:
@@ -24,9 +24,9 @@ document.addEventListener('alpine:init', () => {
|
|||||||
resultGuesses: Alpine.$persist('').as('resultGuesses'),
|
resultGuesses: Alpine.$persist('').as('resultGuesses'),
|
||||||
resultTimeTaken: Alpine.$persist('').as('resultTimeTaken'),
|
resultTimeTaken: Alpine.$persist('').as('resultTimeTaken'),
|
||||||
|
|
||||||
init() {
|
async init() {
|
||||||
/** Initialise the application after loading */
|
/** Initialise the application after loading */
|
||||||
this.getGameID();
|
await this.getGameID();
|
||||||
setInterval(() => {
|
setInterval(() => {
|
||||||
// Update counter to next game (midnight UTC, fetched from API) every second
|
// Update counter to next game (midnight UTC, fetched from API) every second
|
||||||
this.countDownTimer();
|
this.countDownTimer();
|
||||||
@@ -162,6 +162,7 @@ document.addEventListener('alpine:init', () => {
|
|||||||
},
|
},
|
||||||
countDownTimer(){
|
countDownTimer(){
|
||||||
/** Update counter to next game (midnight UTC, fetched from API) */
|
/** Update counter to next game (midnight UTC, fetched from API) */
|
||||||
|
if (this.gameFetchedAt === null) { return; }
|
||||||
let now = new Date();
|
let now = new Date();
|
||||||
let gameDataFetched = new Date(this.gameFetchedAt);
|
let gameDataFetched = new Date(this.gameFetchedAt);
|
||||||
let nextGameStart = gameDataFetched.setSeconds(gameDataFetched.getSeconds() + this.nextGameIn);
|
let nextGameStart = gameDataFetched.setSeconds(gameDataFetched.getSeconds() + this.nextGameIn);
|
||||||
|
|||||||
Reference in New Issue
Block a user