import { Injectable } from '@angular/core' ; import { Preferences } from '../models/preferences' ; import { LocalStorageService } from './local-storage' ; declare let amplitude ; @ Injectable ( ) export class GenericStorageService { constructor ( private readonly localStorageService ) { } public async saveUserPreferences ( preferences ) { this . localStorageService . setItem ( LocalStorageService . LOCAL_STORAGE_USER_PREFERENCES , preferences ) ; return preferences ; } public async getUserPreferences ( ) { const strPrefs = localStorage . getItem ( LocalStorageService . LOCAL_STORAGE_USER_PREFERENCES ) ; const result = ! ! strPrefs ? Object . assign ( new Preferences ( ) , JSON . parse ( strPrefs ) ) : new Preferences ( ) ; const resultWithDate = { ... result , lastUpdateDate : result . lastUpdateDate ? new Date ( result . lastUpdateDate ) : null , } ; return resultWithDate ; } }