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

Commit

Permalink
fix(live-feed): rework display, show countdown to postseason now
Browse files Browse the repository at this point in the history
  • Loading branch information
Benjamin Reed committed Sep 18, 2020
1 parent a201c71 commit 52db567
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 29 deletions.
42 changes: 24 additions & 18 deletions src/app/live-feed/live-feed.page.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@
<ion-spinner></ion-spinner>
</ion-button>
<!--
<ion-button *ngIf="errors &gt; 0 && !isFinished()">
<ion-button *ngIf="errors &gt; 0 && !isPostseasonComplete()">
<ion-icon name="alert-circle-outline" color="danger"></ion-icon>
</ion-button>
-->
</ion-buttons>
</ion-toolbar>
<ion-toolbar *ngIf="ready && !isFinished()">
<ion-toolbar *ngIf="ready && !showCountdown()">
<ion-buttons slot="primary">
<!-- this is just to fix spacing for now, I'll figure out something better eventually -->
<ion-button>
Expand Down Expand Up @@ -49,21 +49,27 @@
</ion-refresher>
<ion-searchbar *ngIf="filterVisible" debounce="200" value="{{searchTerm}}" showCancelButton="focus" (ionInput)="filterList($event)"></ion-searchbar>
<span *ngIf="ready">
<span *ngIf="isFinished()">
<ion-item lines="none">
<h4>Season {{streamData.seasonNumber}} is over.</h4>
</ion-item>
<ion-item lines="none" *ngIf="getWinner() && getWinner().fullName">
<h4>The <span [style]="'color: ' + getWinner().mainColor">{{getWinner().fullName}}</span> are the Champions!</h4>
</ion-item>
<ion-item lines="none">
<h4 *ngIf="countdown">Next Season Starts In:<br>{{getNextSeasonStart()}}.</h4>
</ion-item>
<!--
<ion-item lines="none" class="ticker-wrap">
</ion-item>
-->
<div id="marquee" data-speed="0.8">
<span *ngIf="showCountdown()">
<span *ngIf="isPostseasonComplete()">
<ion-item lines="none">
<h4>Season {{streamData.seasonNumber}} is over.</h4>
</ion-item>
<ion-item lines="none" *ngIf="getWinner() && getWinner().fullName">
<h4>The <span [style]="'color: ' + getWinner().mainColor">{{getWinner().fullName}}</span> are the Champions!</h4>
</ion-item>
<ion-item lines="none">
<h4 *ngIf="countdown">Next Season Starts In:<br>{{getCountdown()}}.</h4>
</ion-item>
</span>
<span *ngIf="isPostseason()">
<ion-item lines="none">
<h4>Regular season is over.</h4>
</ion-item>
<ion-item lines="none">
<h4 *ngIf="countdown">Postseason Starts In:<br>{{getCountdown()}}.</h4>
</ion-item>
</span>
<div id="marquee" data-speed="1">
<div class="marquee">
<div class="marquee-item" *ngFor="let event of globalEvents">
{{event.msg}}...
Expand All @@ -74,7 +80,7 @@ <h4 *ngIf="countdown">Next Season Starts In:<br>{{getNextSeasonStart()}}.</h4>
</div>
</div>
</span>
<span *ngIf="!isFinished()">
<span *ngIf="!showCountdown()">
<ion-item lines="none" *ngIf="streamData.games.isPostseason()">
<h4 *ngIf="streamData && streamData.games" class="ion-no-margin">Postseason Round {{streamData.games.postseason.round.roundNumber}}, Day {{getPlayoffDay()}}</h4>
</ion-item>
Expand Down
42 changes: 32 additions & 10 deletions src/app/live-feed/live-feed.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -179,24 +179,46 @@ export class LiveFeedPage implements OnInit, OnDestroy {
});
}

isPostseason(): boolean {
doCountdown(type: string) {
if (!this.clockUpdater) {
this.clockUpdater = setInterval(() => {
this.countdown = this.streamData.sim[type]();
}, 1000) as unknown as number;
}
}

isRegularSeason() {
return this.streamData?.games?.isRegularSeason() || false;
}

isPostseason() {
return this.streamData?.games?.isPostseason() || false;
}

isFinished() {
const isFinished = this.streamData?.games?.isPostseasonComplete() || false;
isPostseasonComplete() {
return this.streamData?.games?.isPostseasonComplete() || false;
}

if (this.clockUpdater && !isFinished) {
showCountdown(): boolean {
const isRegularSeason = this.isRegularSeason();
const isPostseason = this.isPostseason();
const isFinished = this.isPostseasonComplete();

if (isRegularSeason && isPostseason) {
this.doCountdown('countdownToNextPhase');
return true;
} else if (isFinished) {
this.doCountdown('countdownToNextSeason');
return true;
}

if (this.clockUpdater) {
clearInterval(this.clockUpdater);
this.clockUpdater = undefined;
this.countdown = undefined;
} else if (!this.clockUpdater && isFinished) {
this.clockUpdater = setInterval(() => {
this.countdown = this.streamData.sim.countdownToNextSeason();
}, 1000) as unknown as number;
}

return isFinished;
return false;
}

getWinner() {
Expand All @@ -211,7 +233,7 @@ export class LiveFeedPage implements OnInit, OnDestroy {
return (this.streamData?.games?.postseason?.playoffs?.playoffDay || 0);
}

getNextSeasonStart() {
getCountdown() {
return `${this.countdown.hours} ${this.countdown.hours === 1 ? 'hour' : 'hours'}, ${this.countdown.minutes} ${this.countdown.minutes === 1 ? 'minute' : 'minutes'}, ${this.countdown.seconds} ${this.countdown.seconds === 1 ? 'second' : 'seconds'}`;
}

Expand Down
1 change: 0 additions & 1 deletion src/lib/model/games.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ export class Games extends Entry {
const incompleteRegularSeason = this.incompleteGames(this.schedule)
.filter((game: Game) => !game.isPostseason);

console.debug('day=', this.sim.data);
if (incompleteRegularSeason.length === 0) {
if (this.sim.day === 99) {
// no games are left for day 99
Expand Down

0 comments on commit 52db567

Please sign in to comment.