From d5165ad451bc77ca4e03305ac827fbc4942ae48b Mon Sep 17 00:00:00 2001 From: Dan Date: Mon, 27 Nov 2023 14:49:50 +0000 Subject: [PATCH] Fix standings --- .../season-standings.component.ts | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/packages/bridge-ui/src/app/components/season-standings/season-standings.component.ts b/packages/bridge-ui/src/app/components/season-standings/season-standings.component.ts index d510453..26726c7 100644 --- a/packages/bridge-ui/src/app/components/season-standings/season-standings.component.ts +++ b/packages/bridge-ui/src/app/components/season-standings/season-standings.component.ts @@ -55,7 +55,7 @@ export class SeasonStandingsComponent { return; } - this.onUpdatedStandings(this.season.standings); + this.sortStandings(this.season.standings); console.log("Season Standings - Begin") console.log(this.season); console.log(this.sortedStandings); @@ -68,6 +68,15 @@ export class SeasonStandingsComponent { this.sseService.unregisterEventHandler('season-standings.updated', this.updatedStandingsListener); } + sortStandings(data:SeasonStanding[]) { + let sorted = [...data] + sorted.sort((a, b) => { + return a.points - b.points + }) + + this.sortedStandings = [...sorted]; + } + onUpdatedStandings(data: any) { if(this.season != undefined && data.seasonId != this.season.id){ return; @@ -78,11 +87,7 @@ export class SeasonStandingsComponent { sorted.push(result) } - sorted.sort((a, b) => { - return a.points - b.points - }) - - this.sortedStandings = [...sorted]; + this.sortStandings(sorted); } getRacerName(racer: any): string {