Skip to content

Commit

Permalink
Adapt Starter Component to SSR
Browse files Browse the repository at this point in the history
Define window to execute in PlaformBrowser
  • Loading branch information
PacMM79 committed Nov 28, 2024
1 parent 44baf88 commit 025c686
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions src/app/modules/starter/components/starter/starter.component.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import { type FilterChallenge } from './../../../../models/filter-challenge.model'
import { Component, Inject, type OnInit, ViewChild, type ElementRef } from '@angular/core'
import { Component, Inject, type OnInit, ViewChild, type ElementRef, PLATFORM_ID } from '@angular/core'
import { type Subscription } from 'rxjs'
import { StarterService } from '../../../../services/starter.service'
import { Challenge } from '../../../../models/challenge.model'
import { environment } from '../../../../../environments/environment'
import { type FiltersModalComponent } from 'src/app/modules/modals/filters-modal/filters-modal.component'
import { TranslateService } from '@ngx-translate/core'
import { isPlatformBrowser } from '@angular/common'
/* import { RouteConfigLoadEnd } from '@angular/router'
*/
@Component({
Expand Down Expand Up @@ -35,13 +36,21 @@ export class StarterComponent implements OnInit {
isAscending: boolean = false
startIndex: number = 0
paginationFilters: Challenge[] = []
isMobile: boolean = window.innerWidth < 768
isMobile: boolean = false

constructor (
@Inject(StarterService) private readonly starterService: StarterService,
@Inject(TranslateService) readonly translate: TranslateService
@Inject(TranslateService) readonly translate: TranslateService,
@Inject(PLATFORM_ID) private readonly platformId: unknown
) {}

ngOnInit (): void {
if (typeof this.platformId === 'object' && this.platformId !== null) {
if (isPlatformBrowser(this.platformId)) {
this.isMobile = window.innerWidth < 768
}
}

this.getChallenge()
}

Expand Down

0 comments on commit 025c686

Please sign in to comment.