Skip to content
This repository has been archived by the owner on Nov 8, 2022. It is now read-only.

Commit

Permalink
feat: only show standings during regular season
Browse files Browse the repository at this point in the history
  • Loading branch information
Benjamin Reed committed Nov 17, 2020
1 parent df0ef01 commit 3b247c0
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 6 deletions.
6 changes: 3 additions & 3 deletions src/app/tabs/tabs.page.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
<ion-tab-bar slot="bottom">
<ion-tab-button tab="live-feed">
<ion-icon name="baseball-outline"></ion-icon>
<ion-label>Live Feed</ion-label>
<ion-label>Live</ion-label>
</ion-tab-button>

<ion-tab-button tab="standings">
<ion-tab-button tab="standings" *ngIf="showStandings()">
<ion-icon name="podium-outline"></ion-icon>
<ion-label>Standings</ion-label>
</ion-tab-button>

<ion-tab-button tab="matchups">
<ion-tab-button tab="matchups" *ngIf="!showStandings()">
<ion-icon name="trophy-outline"></ion-icon>
<ion-label>Matchups</ion-label>
</ion-tab-button>
Expand Down
28 changes: 25 additions & 3 deletions src/app/tabs/tabs.page.ts
Original file line number Diff line number Diff line change
@@ -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';

Expand All @@ -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;
}

}
11 changes: 11 additions & 0 deletions src/lib/model/sim.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit 3b247c0

Please sign in to comment.