From 3b247c0f3a712417699b9b9f54a4b88de98cc40c Mon Sep 17 00:00:00 2001 From: Benjamin Reed Date: Mon, 16 Nov 2020 22:56:11 -0500 Subject: [PATCH] feat: only show standings during regular season --- src/app/tabs/tabs.page.html | 6 +++--- src/app/tabs/tabs.page.ts | 28 +++++++++++++++++++++++++--- src/lib/model/sim.ts | 11 +++++++++++ 3 files changed, 39 insertions(+), 6 deletions(-) diff --git a/src/app/tabs/tabs.page.html b/src/app/tabs/tabs.page.html index 59f2d590..205caca3 100644 --- a/src/app/tabs/tabs.page.html +++ b/src/app/tabs/tabs.page.html @@ -3,15 +3,15 @@ - Live Feed + Live - + Standings - + Matchups diff --git a/src/app/tabs/tabs.page.ts b/src/app/tabs/tabs.page.ts index 07421155..d2243940 100644 --- a/src/app/tabs/tabs.page.ts +++ b/src/app/tabs/tabs.page.ts @@ -1,4 +1,7 @@ -import { Component } from '@angular/core'; +import { Component, OnInit } from '@angular/core'; +import { Subscription } from 'rxjs'; +import { APIStream } from 'src/lib/api/stream'; +import { StreamData } from 'src/lib/model/streamData'; import { UpdateService } from '../../lib/update.service'; @@ -7,10 +10,29 @@ import { UpdateService } from '../../lib/update.service'; templateUrl: 'tabs.page.html', styleUrls: ['tabs.page.scss'] }) -export class TabsPage { +export class TabsPage implements OnInit { + public streamData = new StreamData({}); + public subscription: Subscription; constructor( - public updateService: UpdateService + public stream: APIStream, + public updateService: UpdateService, ) {} + async ngOnInit() { + this.subscription?.unsubscribe(); + this.subscription = await this.stream.subscribe((evt) => { + if (evt instanceof StreamData) { + this.streamData = evt; + } + }); + } + + showStandings() { + if (this.streamData?.sim?.showStandings !== undefined) { + return this.streamData.sim.showStandings; + } + return true; + } + } diff --git a/src/lib/model/sim.ts b/src/lib/model/sim.ts index cf2e7ef3..35953842 100644 --- a/src/lib/model/sim.ts +++ b/src/lib/model/sim.ts @@ -50,6 +50,17 @@ export class Sim extends Entry { return this.data?.phase || 0; } + public get showStandings(): boolean { + switch (this.phase) { + case PHASES.REGULAR_SEASON: + case PHASES.PRE_OFFSEASON: + case PHASES.OFFSEASON: + return true; + default: + return false; + } + } + countdownToNextPhase(from?: number) { const start = from || Date.now(); const end = new Date(this.data.nextPhaseTime).getTime();