import { Component , ElementRef , Inject , OnInit , ViewChild , } from "@angular/core" ; import { Changelog } from "../changelog" ; import { MAT_DIALOG_DATA , MatDialogRef } from "@angular/material/dialog" ; import { isObservable , Observable } from "rxjs" ; import { LatestChangesService } from "../latest-changes.service" ; import { UntilDestroy , untilDestroyed } from "@ngneat/until-destroy" ; /**
 * Display information from the changelog for the latest version.
 *
 * This component is used as content of a dialog.
 */ @ UntilDestroy ( ) @ Component ( { templateUrl : "./changelog.component.html" , styleUrls : [ "./changelog.component.scss" ] , } ) export class ChangelogComponent implements OnInit { /** The array of relevant changelog entries to be displayed */ changelogs : Changelog [ ] ; /** Display advanced information that may not be useful to normal users */ showAdvancedDetails = false ; @ ViewChild ( "changelogContainer" ) contentContainer : ElementRef ; example param dialogRef param data param latestChangesService constructor ( public dialogRef , @ Inject ( MAT_DIALOG_DATA ) public data , private latestChangesService ) { } ngOnInit ( ) { if ( this . data && isObservable ( this . data ) ) { this . data . pipe ( untilDestroyed ( this ) ) . subscribe ( ( changelog ) => ( this . changelogs = changelog ) ) ; } } get noChangelogAvailable ( ) : string { return $localize `No Changelog Available` ; } /**
     * Add one more previous release card to the end of the currently displayed list of changelogs.
     */ loadPreviousRelease ( ) { if ( ! this . changelogs ) { return ; } const lastDisplayedVersion = this . changelogs [ this . changelogs . length - 1 ] . tag_name ; this . latestChangesService . getChangelogsBeforeVersion ( lastDisplayedVersion , 1 ) . pipe ( untilDestroyed ( this ) ) . subscribe ( ( additionalChangelog ) => { this . changelogs . push ( ... additionalChangelog ) ; setTimeout ( ( ) => this . scrollToBottomOfReleases ( ) ) ; } ) ; } private scrollToBottomOfReleases ( ) { this . contentContainer . nativeElement . scrollTop = this . contentContainer . nativeElement . scrollHeight ; } }