diff --git a/src/app/primitives/appstate/index.ts b/src/app/primitives/appstate/index.ts index e0ab586..09ff715 100644 --- a/src/app/primitives/appstate/index.ts +++ b/src/app/primitives/appstate/index.ts @@ -19,7 +19,7 @@ */ import { Outcome, AppOutcome } from '../../interfaces/app'; -import { NgZone } from '@angular/core'; +import { NgZone, isDevMode } from '@angular/core'; import { getHan, getFixedFu } from '../yaku-values'; import { Outcome as OutcomeType, Player } from '../../interfaces/common'; import { YakuId } from '../yaku'; @@ -113,6 +113,7 @@ export class AppState { this.api.getGameConfig(), this.api.getTimerState() ]; + Promise.all(promises).then(([games, playerInfo, gameConfig, timerState]) => { this._currentPlayerDisplayName = playerInfo.displayName; this._currentPlayerId = playerInfo.id; @@ -140,6 +141,8 @@ export class AppState { window.localStorage.removeItem('authToken'); this._reset(); this.reinit(); + } else if (isDevMode()) { + console.error('Caught error or exception: ', e); } }); } diff --git a/src/app/services/riichiApi.ts b/src/app/services/riichiApi.ts index d7f90d1..b4628eb 100644 --- a/src/app/services/riichiApi.ts +++ b/src/app/services/riichiApi.ts @@ -137,7 +137,7 @@ export class RiichiApiService { .post(config.apiUrl, jsonRpcBody, { headers: commonHeaders }) .toPromise() .then((response) => { - this._checkCompatibility(response.headers.get('X-Api-Headers')); + this._checkCompatibility(response.headers.get('x-api-version')); // for some reason headers are lowercase const json = response.json(); if (json.error) { if (isDevMode()) { @@ -151,7 +151,7 @@ export class RiichiApiService { } private _checkCompatibility(versionString) { - const [major, minor] = versionString.split('.').map((v) => parseInt(v, 10)); + const [major, minor] = (versionString || '').split('.').map((v) => parseInt(v, 10)); const [localMajor, localMinor] = config.apiVersion; if (major !== localMajor) { console.error('API major version mismatch. Update your app or API instance!');