import { DriveUser } from '../util/googleDriveUtils' ; import { NetworkedAction } from '../util/types' ; export enum LoggedInUserActionTypes { SET_LOGGED_IN_USER = 'set-logged-in-user' } export type LoggedInUserReducerType = DriveUser | null ; interface SetLoggedInUserActionType extends NetworkedAction { type : LoggedInUserActionTypes . SET_LOGGED_IN_USER ; user : LoggedInUserReducerType ; } export function setLoggedInUserAction ( user ) { return { type : LoggedInUserActionTypes . SET_LOGGED_IN_USER , user } ; } function loggedInUserReducer ( state = null , action ) { switch ( action . type ) { case LoggedInUserActionTypes . SET_LOGGED_IN_USER : return action . fromPeerId ? state : action . user ; default : return state ; } } export default loggedInUserReducer ;