import * as Immutable from 'immutable' ; interface UserData { endpoint : string ; email : string ; resetPasswordToken : string ; name : string ; } export interface StoredState { hasRead : { [ key ] : boolean ; } ; user : UserData | null ; skippedAuth : boolean ; } const initialState = { hasRead : { } , user : null , skippedAuth : false , } ; let state = window . localStorage . hasOwnProperty ( 'learnrelay_state' ) ? JSON . parse ( window . localStorage . getItem ( 'learnrelay_state' ) ! ) as StoredState : initialState ; export function getStoredState ( ) { return state ; } export function update ( keyPath , value ) { state = Immutable . fromJS ( state ) . setIn ( keyPath , value ) . toJS ( ) as StoredState ; window . localStorage . setItem ( 'learnrelay_state' , JSON . stringify ( state ) ) ; return state ; }