import { Injectable } from "@angular/core" ; import { MatDialog } from "@angular/material/dialog" ; import { ChangelogComponent } from "./changelog/changelog.component" ; import { environment } from "../../../environments/environment" ; import { LatestChangesService } from "./latest-changes.service" ; /**
 * Manage the changelog information and display it to the user
 * on request or automatically on the first visit of a new version after update.
 */ @ Injectable ( ) export class LatestChangesDialogService { public static VERSION_KEY = "AppVersion" ; constructor ( private dialog , private latestChangesService ) { } /**
     * Get current app version inferred from the latest changelog entry.
     */ getCurrentVersion ( ) { return environment . appVersion ; } param previousVersion public showLatestChanges ( previousVersion ? ) { this . dialog . open ( ChangelogComponent , { width : "80%" , data : this . latestChangesService . getChangelogsBetweenVersions ( this . getCurrentVersion ( ) , previousVersion ) , } ) ; } /**
     * Display the latest changes info box automatically if the current user has not seen this version before.
     */ public showLatestChangesIfUpdated ( ) { const previousVersion = window . localStorage . getItem ( LatestChangesDialogService . VERSION_KEY ) ; if ( previousVersion && this . getCurrentVersion ( ) !== previousVersion ) { this . showLatestChanges ( previousVersion ) ; } window . localStorage . setItem ( LatestChangesDialogService . VERSION_KEY , this . getCurrentVersion ( ) ) ; } }