import { AthleteModel , AthleteSettingsModel , DatedAthleteSettingsModel , Gender , SyncedActivityModel , UserLactateThresholdModel , UserSettingsModel , UserZonesModel } from "@elevate/shared/models" ; import { Helper } from "./helper" ; import * as semver from "semver" ; import * as _ from "lodash" ; import { BrowserStorage } from "./browser-storage" ; import { Constant } from "@elevate/shared/constants" ; import { userSettingsData } from "@elevate/shared/data" ; import { YearToDateProgressPresetModel } from "../../app/src/app/year-progress/shared/models/year-to-date-progress-preset.model" ; import { ProgressMode } from "../../app/src/app/year-progress/shared/enums/progress-mode.enum" ; import { BrowserStorageType } from "./models/browser-storage-type.enum" ; import { Tools } from "@elevate/shared/tools" ; class Installer { public previousVersion : string ; public currentVersion : string ; public listen ( ) { chrome . runtime . onInstalled . addListener ( ( details ) => { if ( details . reason === "install" ) { this . handleInstall ( ) ; } else if ( details . reason === "update" ) { this . currentVersion = chrome . runtime . getManifest ( ) . version ; this . previousVersion = details . previousVersion ; this . handleUpdate ( ) . then ( ( ) => { return Promise . all ( [ BrowserStorage . getInstance ( ) . get ( BrowserStorageType . SYNC ) , BrowserStorage . getInstance ( ) . get ( BrowserStorageType . LOCAL ) ] ) ; } ) . then ( ( result ) => { console . log ( "Migration finished!" ) ; console . log ( "Synced data: " , result [ 0 ] ) ; console . log ( "Local data: " , result [ 1 ] ) ; } ) . catch ( ( error ) => { console . error ( error ) ; } ) ; } } ) ; } protected isPreviousVersionLowerThanOrEqualsTo ( oldVersion , upgradingVersion ) { return semver . gte ( upgradingVersion , oldVersion ) ; } protected handleInstall ( ) { chrome . tabs . create ( { url : Constant . LANDING_PAGE_URL , } , ( tab ) => { console . log ( "First install. Display website new tab:" , tab ) ; chrome . tabs . create ( { url : chrome . extension . getURL ( Constant . APP_ROOT_URL ) , } , ( tab ) => { console . log ( "First install. Display settings:" , tab ) ; } ) ; } ) ; } returns { Promise < void > } protected migrate_to_5_1_1 ( ) { let promise = Promise . resolve ( ) ; if ( this . isPreviousVersionLowerThanOrEqualsTo ( this . previousVersion , "5.1.1" ) ) { console . log ( "Migrate to 5.1.1" ) ; promise = BrowserStorage . getInstance ( ) . rm ( BrowserStorageType . LOCAL , "computedActivities" ) . then ( ( ) => { return BrowserStorage . getInstance ( ) . rm ( BrowserStorageType . LOCAL , "lastSyncDateTime" ) ; } ) . then ( ( ) => { console . log ( "Local History cleared" ) ; return Promise . resolve ( ) ; } ) . catch ( ( error ) => { return Promise . reject ( error ) ; } ) ; } else { console . log ( "Skip migrate to 5.1.1" ) ; } return promise ; } returns { Promise < void > } protected migrate_to_5_11_0 ( ) { let promise = Promise . resolve ( ) ; if ( this . isPreviousVersionLowerThanOrEqualsTo ( this . previousVersion , "5.11.0" ) ) { console . log ( "Migrate to 5.11.0" ) ; promise = BrowserStorage . getInstance ( ) . rm ( BrowserStorageType . SYNC , [ "enableAlphaFitnessTrend" ] ) . then ( ( ) => { return BrowserStorage . getInstance ( ) . get ( BrowserStorageType . SYNC ) ; } ) . then ( ( currentUserSavedSettings ) => { const oldUserHrrZones = currentUserSavedSettings . userHrrZones ; if ( oldUserHrrZones ) { if ( oldUserHrrZones . length > 0 ) { const newHeartRateZones = [ ] ; for ( let i = 0 ; i < oldUserHrrZones . length ; i ++ ) { const hrrZone = oldUserHrrZones [ i ] ; newHeartRateZones . push ( { from : Helper . heartrateFromHeartRateReserve ( hrrZone . fromHrr , currentUserSavedSettings . userMaxHr , currentUserSavedSettings . userRestHr ) , to : Helper . heartrateFromHeartRateReserve ( hrrZone . toHrr , currentUserSavedSettings . userMaxHr , currentUserSavedSettings . userRestHr ) , } ) ; } if ( ! currentUserSavedSettings . zones ) { currentUserSavedSettings . zones = { } ; } currentUserSavedSettings . zones . heartRate = newHeartRateZones ; return BrowserStorage . getInstance ( ) . set ( BrowserStorageType . SYNC , null , currentUserSavedSettings ) . then ( ( ) => { return BrowserStorage . getInstance ( ) . rm ( BrowserStorageType . SYNC , [ "userHrrZones" ] ) ; } ) ; } else { return BrowserStorage . getInstance ( ) . rm ( BrowserStorageType . SYNC , [ "userHrrZones" ] ) ; } } else { return Promise . resolve ( ) ; } } ) ; } else { console . log ( "Skip migrate to 5.11.0" ) ; } return promise ; } returns { Promise < void > } protected migrate_to_6_1_2 ( ) { let promise = Promise . resolve ( ) ; if ( this . isPreviousVersionLowerThanOrEqualsTo ( this . previousVersion , "6.1.2" ) ) { console . log ( "Migrate to 6.1.2" ) ; promise = BrowserStorage . getInstance ( ) . rm ( BrowserStorageType . LOCAL , [ "syncWithAthleteProfile" ] ) . then ( ( ) => { return BrowserStorage . getInstance ( ) . get < SyncedActivityModel [ ] > ( BrowserStorageType . LOCAL , "computedActivities" ) . then ( ( computedActivities ) => { if ( computedActivities ) { return BrowserStorage . getInstance ( ) . set ( BrowserStorageType . LOCAL , "syncedActivities" , computedActivities ) . then ( ( ) => { return BrowserStorage . getInstance ( ) . rm ( BrowserStorageType . LOCAL , [ "computedActivities" ] ) ; } ) ; } else { return Promise . resolve ( ) ; } } ) . then ( ( ) => { return BrowserStorage . getInstance ( ) . rm ( BrowserStorageType . SYNC , [ "autoSyncMinutes" ] ) ; } ) ; } ) ; } else { console . log ( "Skip migrate to 6.1.2" ) ; } return promise ; } returns { Promise < void > } protected migrate_to_6_4_0 ( ) { let promise = Promise . resolve ( ) ; if ( this . isPreviousVersionLowerThanOrEqualsTo ( this . previousVersion , "6.4.0" ) ) { console . log ( "Migrate to 6.4.0" ) ; promise = BrowserStorage . getInstance ( ) . rm ( BrowserStorageType . SYNC , [ "displayMotivationScore" ] ) ; } else { console . log ( "Skip migrate to 6.4.0" ) ; } return promise ; } returns { Promise < void > } protected migrate_to_6_5_0 ( ) { let promise = Promise . resolve ( ) ; if ( this . isPreviousVersionLowerThanOrEqualsTo ( this . previousVersion , "6.5.0" ) ) { console . log ( "Migrate to 6.5.0" ) ; promise = BrowserStorage . getInstance ( ) . get ( BrowserStorageType . SYNC ) . then ( ( userSettingsModel ) => { if ( userSettingsModel . userGender ) { const userGender = ( userSettingsModel . userGender === "men" ) ? Gender . MEN : Gender . WOMEN ; const athleteModel = new AthleteModel ( userGender , < any > new AthleteSettingsModel ( ( _ . isNumber ( userSettingsModel . userMaxHr ) ) ? userSettingsModel . userMaxHr : null , ( _ . isNumber ( userSettingsModel . userRestHr ) ) ? userSettingsModel . userRestHr : null , ( ! _ . isEmpty ( userSettingsModel . userLTHR ) ) ? userSettingsModel . userLTHR : UserLactateThresholdModel . DEFAULT_MODEL , ( _ . isNumber ( userSettingsModel . userFTP ) ) ? userSettingsModel . userFTP : null , ( _ . isNumber ( userSettingsModel . userRunningFTP ) ) ? userSettingsModel . userRunningFTP : null , ( _ . isNumber ( userSettingsModel . userSwimFTP ) ) ? userSettingsModel . userSwimFTP : null , ( _ . isNumber ( userSettingsModel . userWeight ) ) ? userSettingsModel . userWeight : null ) ) ; return BrowserStorage . getInstance ( ) . set ( BrowserStorageType . SYNC , "athleteModel" , athleteModel ) ; } else { return Promise . resolve ( ) ; } } ) . then ( ( ) => { return BrowserStorage . getInstance ( ) . rm ( BrowserStorageType . SYNC , [ "userGender" , "userMaxHr" , "userRestHr" , "userLTHR" , "userFTP" , "userRunningFTP" , "userSwimFTP" , "userWeight" ] ) ; } ) . then ( ( ) => { return BrowserStorage . getInstance ( ) . rm ( BrowserStorageType . LOCAL , "profileConfigured" ) ; } ) ; } else { console . log ( "Skip migrate to 6.5.0" ) ; } return promise ; } protected migrate_to_6_6_0 ( ) { let promise = Promise . resolve ( ) ; if ( this . isPreviousVersionLowerThanOrEqualsTo ( this . previousVersion , "6.6.0" ) ) { console . log ( "Migrate to 6.6.0" ) ; promise = BrowserStorage . getInstance ( ) . get ( BrowserStorageType . SYNC ) . then ( ( userSettingsModel ) => { const userZonesModel = userSettingsModel . zones ; let promiseMigrate ; try { userZonesModel . speed = UserZonesModel . serialize ( userZonesModel . speed ) ; userZonesModel . pace = UserZonesModel . serialize ( userZonesModel . pace ) ; userZonesModel . gradeAdjustedPace = UserZonesModel . serialize ( userZonesModel . gradeAdjustedPace ) ; userZonesModel . heartRate = UserZonesModel . serialize ( userZonesModel . heartRate ) ; userZonesModel . power = UserZonesModel . serialize ( userZonesModel . power ) ; userZonesModel . runningPower = UserZonesModel . serialize ( userZonesModel . runningPower ) ; userZonesModel . cyclingCadence = UserZonesModel . serialize ( userZonesModel . cyclingCadence ) ; userZonesModel . runningCadence = UserZonesModel . serialize ( userZonesModel . runningCadence ) ; userZonesModel . grade = UserZonesModel . serialize ( userZonesModel . grade ) ; userZonesModel . elevation = UserZonesModel . serialize ( userZonesModel . elevation ) ; userZonesModel . ascent = UserZonesModel . serialize ( userZonesModel . ascent ) ; promiseMigrate = BrowserStorage . getInstance ( ) . set ( BrowserStorageType . SYNC , "zones" , userZonesModel ) ; } catch ( err ) { console . warn ( err ) ; promiseMigrate = BrowserStorage . getInstance ( ) . set ( BrowserStorageType . SYNC , "zones" , userSettingsData . zones ) ; } return promiseMigrate ; } ) ; } else { console . log ( "Skip migrate to 6.6.0" ) ; } return promise ; } /**
     * Force user using single athlete settings to use dated ones
     */ protected migrate_to_6_7_0 ( ) { let promise = Promise . resolve ( ) ; if ( this . isPreviousVersionLowerThanOrEqualsTo ( this . previousVersion , "6.7.0" ) ) { console . log ( "Migrate to 6.7.0" ) ; promise = BrowserStorage . getInstance ( ) . get < DatedAthleteSettingsModel [ ] > ( BrowserStorageType . LOCAL , "datedAthleteSettings" ) . then ( ( localDatedAthleteSettingsModels ) => { if ( _ . isEmpty ( localDatedAthleteSettingsModels ) ) { return BrowserStorage . getInstance ( ) . get ( BrowserStorageType . SYNC ) . then ( ( userSettingsModel ) => { const athleteSettings = ( userSettingsModel && userSettingsModel . athleteModel && userSettingsModel . athleteModel . athleteSettings ) ? userSettingsModel . athleteModel . athleteSettings : AthleteSettingsModel . DEFAULT_MODEL ; const datedAthleteSettings = [ new DatedAthleteSettingsModel ( DatedAthleteSettingsModel . DEFAULT_SINCE , athleteSettings ) , new DatedAthleteSettingsModel ( null , athleteSettings ) ] ; return BrowserStorage . getInstance ( ) . set ( BrowserStorageType . LOCAL , "datedAthleteSettings" , datedAthleteSettings ) . then ( ( ) => { return BrowserStorage . getInstance ( ) . set ( BrowserStorageType . SYNC , "hasDatedAthleteSettings" , true ) ; } ) ; } ) ; } else { return Promise . resolve ( ) ; } } ) ; } else { console . log ( "Skip migrate to 6.7.0" ) ; } return promise ; } protected migrate_to_6_8_1 ( ) { let promise ; if ( this . isPreviousVersionLowerThanOrEqualsTo ( this . previousVersion , "6.8.1" ) ) { console . log ( "Migrate to 6.8.1" ) ; let userSettingsModel ; promise = BrowserStorage . getInstance ( ) . get ( BrowserStorageType . SYNC ) . then ( ( settings ) => { const hasUserSettingsKey = ! _ . isEmpty ( ( < any > settings ) . userSettings ) ; if ( hasUserSettingsKey ) { return Promise . resolve ( ) ; } else { userSettingsModel = settings ; delete ( userSettingsModel as any ) . bestSplitsConfiguration ; return BrowserStorage . getInstance ( ) . clear ( BrowserStorageType . SYNC ) . then ( ( ) => { return BrowserStorage . getInstance ( ) . set ( BrowserStorageType . SYNC , "userSettings" , userSettingsModel ) ; } ) ; } } ) ; } else { console . log ( "Skip migrate to 6.8.1" ) ; promise = Promise . resolve ( ) ; } return promise ; } protected migrate_to_6_9_0 ( ) { let promise ; if ( this . isPreviousVersionLowerThanOrEqualsTo ( this . previousVersion , "6.9.0" ) ) { console . log ( "Migrate to 6.9.0" ) ; let userSettingsModel ; promise = BrowserStorage . getInstance ( ) . get ( BrowserStorageType . SYNC , "userSettings" ) . then ( ( settings ) => { const hasOldYearProgressTargets = _ . isNumber ( ( < any > settings ) . targetsYearRide ) || _ . isNumber ( ( < any > settings ) . targetsYearRun ) ; if ( hasOldYearProgressTargets ) { userSettingsModel = settings ; delete ( userSettingsModel as any ) . targetsYearRide ; delete ( userSettingsModel as any ) . targetsYearRun ; return BrowserStorage . getInstance ( ) . set ( BrowserStorageType . SYNC , "userSettings" , userSettingsModel ) ; } else { return Promise . resolve ( ) ; } } ) ; } else { console . log ( "Skip migrate to 6.9.0" ) ; promise = Promise . resolve ( ) ; } return promise ; } protected migrate_to_6_10_0 ( ) { let promise ; if ( this . isPreviousVersionLowerThanOrEqualsTo ( this . previousVersion , "6.10.0" ) ) { console . log ( "Migrate to 6.10.0" ) ; promise = BrowserStorage . getInstance ( ) . get ( BrowserStorageType . LOCAL , "yearProgressPresets" ) . then ( ( oldPresetModels ) => { const migratedPresets = [ ] ; let hasUpgradedPresets = false ; _ . forEach ( oldPresetModels , ( presetModel ) => { if ( _ . isUndefined ( presetModel . mode ) ) { presetModel . mode = ProgressMode . YEAR_TO_DATE ; hasUpgradedPresets = true ; } migratedPresets . push ( presetModel ) ; } ) ; if ( hasUpgradedPresets ) { return BrowserStorage . getInstance ( ) . set ( BrowserStorageType . LOCAL , "yearProgressPresets" , migratedPresets ) ; } else { return Promise . resolve ( ) ; } } ) ; } else { console . log ( "Skip migrate to 6.10.0" ) ; promise = Promise . resolve ( ) ; } return promise ; } protected migrate_to_6_11_0 ( ) { let promise = Promise . resolve ( ) ; if ( this . isPreviousVersionLowerThanOrEqualsTo ( this . previousVersion , "6.11.0" ) ) { console . log ( "Migrate to 6.11.0" ) ; const alreadyMigratedMessage = "Abort 6.11.0 migration. Already migrated" ; promise = Promise . all ( [ BrowserStorage . getInstance ( ) . get ( BrowserStorageType . SYNC , "userSettings" ) , BrowserStorage . getInstance ( ) . get ( BrowserStorageType . LOCAL ) ] ) . then ( result => { if ( ! result [ 0 ] ) { throw Error ( alreadyMigratedMessage ) ; } const userSettingsModel = < UserSettingsModel > result [ 0 ] ; const localBrowserStorage = < any > result [ 1 ] || < any > { } ; localBrowserStorage [ "userSettings" ] = userSettingsModel ; return BrowserStorage . getInstance ( ) . set ( BrowserStorageType . LOCAL , null , localBrowserStorage ) ; } ) . then ( ( ) => { return BrowserStorage . getInstance ( ) . rm ( BrowserStorageType . SYNC , "userSettings" ) ; } ) . then ( ( ) => { return Promise . all ( [ BrowserStorage . getInstance ( ) . get ( BrowserStorageType . LOCAL , "userSettings" ) , BrowserStorage . getInstance ( ) . get ( BrowserStorageType . LOCAL , "datedAthleteSettings" ) ] ) ; } ) . then ( result => { const userSettingsModel = < UserSettingsModel > result [ 0 ] ; const datedAthleteSettings = < DatedAthleteSettingsModel [ ] > result [ 1 ] ; const athleteModel = ( < any > userSettingsModel ) . athleteModel ; const isSingleAthleteSettingsMode = ( < any > userSettingsModel ) . hasDatedAthleteSettings === false ; if ( isSingleAthleteSettingsMode ) { const athleteSettings = ( athleteModel && ( < any > athleteModel ) . athleteSettings ) ? ( < any > athleteModel ) . athleteSettings : AthleteSettingsModel . DEFAULT_MODEL ; athleteModel . datedAthleteSettings = [ new DatedAthleteSettingsModel ( DatedAthleteSettingsModel . DEFAULT_SINCE , athleteSettings ) , new DatedAthleteSettingsModel ( null , athleteSettings ) ] ; } else if ( athleteModel ) { athleteModel . datedAthleteSettings = datedAthleteSettings ; } delete ( < any > athleteModel ) . athleteSettings ; delete ( < any > userSettingsModel ) . athleteModel ; delete ( < any > userSettingsModel ) . hasDatedAthleteSettings ; return Promise . all ( [ BrowserStorage . getInstance ( ) . set ( BrowserStorageType . LOCAL , "userSettings" , userSettingsModel ) , BrowserStorage . getInstance ( ) . set ( BrowserStorageType . LOCAL , "athlete" , athleteModel ) , BrowserStorage . getInstance ( ) . rm ( BrowserStorageType . LOCAL , "datedAthleteSettings" ) , ] ) ; } ) . then ( ( ) => { return BrowserStorage . getInstance ( ) . get ( BrowserStorageType . LOCAL , "syncedActivities" ) ; } ) . then ( ( syncedActivities ) => { _ . forEach ( syncedActivities , ( activity ) => { activity . athleteSnapshot = ( < any > activity ) . athleteModel ; delete ( < any > activity ) . athleteModel ; } ) ; return BrowserStorage . getInstance ( ) . set ( BrowserStorageType . LOCAL , "syncedActivities" , syncedActivities ) ; } ) . catch ( error => { if ( error . message === alreadyMigratedMessage ) { console . log ( alreadyMigratedMessage ) ; } else { console . error ( error ) ; } return Promise . resolve ( ) ; } ) . then ( ( ) => { return BrowserStorage . getInstance ( ) . get ( BrowserStorageType . LOCAL , "yearProgressPresets" ) . then ( ( yearProgressPresets ) => { yearProgressPresets = _ . map ( yearProgressPresets , preset => { preset [ "id" ] = Tools . genId ( ) ; return preset ; } ) ; return BrowserStorage . getInstance ( ) . set ( BrowserStorageType . LOCAL , "yearProgressPresets" , yearProgressPresets ) ; } ) ; } ) ; } else { console . log ( "Skip migrate to 6.11.0" ) ; } return promise ; } protected migrate_to_6_11_1 ( ) { let promise = Promise . resolve ( ) ; if ( this . isPreviousVersionLowerThanOrEqualsTo ( this . previousVersion , "6.11.1" ) ) { console . log ( "Migrate to 6.11.1" ) ; promise = BrowserStorage . getInstance ( ) . get < AthleteModel > ( BrowserStorageType . LOCAL , "athlete" ) . then ( athleteModel => { if ( athleteModel . datedAthleteSettings && athleteModel . datedAthleteSettings . length > 0 ) { athleteModel . datedAthleteSettings = _ . sortBy ( athleteModel . datedAthleteSettings , ( model ) => { const sortOnDate = ( _ . isNull ( model . since ) ) ? new Date ( 0 ) : new Date ( model . since ) ; return sortOnDate . getTime ( ) * - 1 ; } ) ; if ( _ . last ( athleteModel . datedAthleteSettings ) . since !== null ) { _ . last ( athleteModel . datedAthleteSettings ) . since = null ; return BrowserStorage . getInstance ( ) . set ( BrowserStorageType . LOCAL , "athlete" , athleteModel ) ; } else { return Promise . resolve ( ) ; } } } ) ; } else { console . log ( "Skip migrate to 6.11.1" ) ; } return promise ; } protected migrate_to_6_14_0 ( ) { let promise = Promise . resolve ( ) ; if ( this . isPreviousVersionLowerThanOrEqualsTo ( this . previousVersion , "6.14.0" ) ) { console . log ( "Migrate to 6.14.0" ) ; promise = BrowserStorage . getInstance ( ) . get < UserSettingsModel > ( BrowserStorageType . LOCAL , "userSettings" ) . then ( ( userSettingsModel ) => { delete ( < any > userSettingsModel ) . displayReliveCCLink ; return BrowserStorage . getInstance ( ) . set < UserSettingsModel > ( BrowserStorageType . LOCAL , "userSettings" , userSettingsModel ) ; } ) ; } else { console . log ( "Skip migrate to 6.14.0" ) ; } return promise ; } protected migrate_to_6_15_0 ( ) { let promise = Promise . resolve ( ) ; if ( this . isPreviousVersionLowerThanOrEqualsTo ( this . previousVersion , "6.15.0" ) ) { console . log ( "Migrate to 6.15.0" ) ; promise = BrowserStorage . getInstance ( ) . get < number > ( BrowserStorageType . LOCAL , "lastSyncDateTime" ) . then ( ( lastSyncDateTime ) => { if ( ! lastSyncDateTime ) { console . log ( "Skip migrate to 6.15.0" ) ; return Promise . resolve ( ) ; } return BrowserStorage . getInstance ( ) . set < number > ( BrowserStorageType . LOCAL , "syncDateTime" , lastSyncDateTime ) ; } ) . then ( ( ) => { return BrowserStorage . getInstance ( ) . rm < number > ( BrowserStorageType . LOCAL , "lastSyncDateTime" ) ; } ) ; } else { console . log ( "Skip migrate to 6.15.0" ) ; } return promise ; } protected migrate_to_6_15_1 ( ) { let promise = Promise . resolve ( ) ; if ( this . isPreviousVersionLowerThanOrEqualsTo ( this . previousVersion , "6.15.1" ) ) { console . log ( "Migrate to 6.15.1" ) ; promise = BrowserStorage . getInstance ( ) . get < number > ( BrowserStorageType . LOCAL , "lastSyncDateTime" ) . then ( ( lastSyncDateTime ) => { if ( ! lastSyncDateTime ) { console . log ( "Skip migrate to 6.15.1" ) ; return Promise . resolve ( ) ; } return BrowserStorage . getInstance ( ) . set < number > ( BrowserStorageType . LOCAL , "syncDateTime" , lastSyncDateTime ) ; } ) . then ( ( ) => { return BrowserStorage . getInstance ( ) . rm < number > ( BrowserStorageType . LOCAL , "lastSyncDateTime" ) ; } ) ; } else { console . log ( "Skip migrate to 6.15.1" ) ; } return promise ; } protected migrate_to_6_16_2 ( ) { let promise = Promise . resolve ( ) ; if ( this . isPreviousVersionLowerThanOrEqualsTo ( this . previousVersion , "6.16.2" ) ) { console . log ( "Migrate to 6.16.2" ) ; promise = BrowserStorage . getInstance ( ) . get < UserSettingsModel > ( BrowserStorageType . LOCAL , "userSettings" ) . then ( ( userSettingsModel ) => { userSettingsModel . displaySegmentTimeComparisonToKOM = false ; userSettingsModel . displaySegmentTimeComparisonToPR = false ; userSettingsModel . displaySegmentTimeComparisonToCurrentYearPR = false ; userSettingsModel . displaySegmentTimeComparisonPosition = false ; return BrowserStorage . getInstance ( ) . set < UserSettingsModel > ( BrowserStorageType . LOCAL , "userSettings" , userSettingsModel ) ; } ) ; } else { console . log ( "Skip migrate to 6.16.2" ) ; } return promise ; } protected handleUpdate ( ) { console . log ( "Updated from " + this . previousVersion + " to " + this . currentVersion ) ; console . debug ( "UserSettings on update" , userSettingsData ) ; return this . migrate_to_5_1_1 ( ) . then ( ( ) => { return this . migrate_to_5_11_0 ( ) ; } ) . then ( ( ) => { return this . migrate_to_6_1_2 ( ) ; } ) . then ( ( ) => { return this . migrate_to_6_4_0 ( ) ; } ) . then ( ( ) => { return this . migrate_to_6_5_0 ( ) ; } ) . then ( ( ) => { return this . migrate_to_6_6_0 ( ) ; } ) . then ( ( ) => { return this . migrate_to_6_7_0 ( ) ; } ) . then ( ( ) => { return this . migrate_to_6_8_1 ( ) ; } ) . then ( ( ) => { return this . migrate_to_6_9_0 ( ) ; } ) . then ( ( ) => { return this . migrate_to_6_10_0 ( ) ; } ) . then ( ( ) => { return this . migrate_to_6_11_0 ( ) ; } ) . then ( ( ) => { return this . migrate_to_6_11_1 ( ) ; } ) . then ( ( ) => { return this . migrate_to_6_14_0 ( ) ; } ) . then ( ( ) => { return this . migrate_to_6_15_0 ( ) ; } ) . then ( ( ) => { return this . migrate_to_6_15_1 ( ) ; } ) . then ( ( ) => { return this . migrate_to_6_16_2 ( ) ; } ) . catch ( error => console . error ( error ) ) ; } } const installer = new Installer ( ) ; installer . listen ( ) ;