Changeset View
Changeset View
Standalone View
Standalone View
lib/selectors/account-selectors.js
// @flow | // @flow | ||||
import { createSelector } from 'reselect'; | import { createSelector } from 'reselect'; | ||||
import { currentCalendarQuery } from './nav-selectors.js'; | import { currentCalendarQuery } from './nav-selectors.js'; | ||||
import type { LogInExtraInfo } from '../types/account-types.js'; | import type { LogInExtraInfo } from '../types/account-types.js'; | ||||
import { isDeviceType } from '../types/device-types.js'; | |||||
import type { CalendarQuery } from '../types/entry-types.js'; | import type { CalendarQuery } from '../types/entry-types.js'; | ||||
import type { AppState } from '../types/redux-types.js'; | import type { AppState } from '../types/redux-types.js'; | ||||
import type { PreRequestUserState } from '../types/session-types.js'; | import type { PreRequestUserState } from '../types/session-types.js'; | ||||
import type { CurrentUserInfo } from '../types/user-types.js'; | import type { CurrentUserInfo } from '../types/user-types.js'; | ||||
import { getConfig } from '../utils/config.js'; | |||||
const logInExtraInfoSelector: ( | const logInExtraInfoSelector: ( | ||||
state: AppState, | state: AppState, | ||||
) => (calendarActive: boolean) => LogInExtraInfo = createSelector( | ) => (calendarActive: boolean) => LogInExtraInfo = createSelector( | ||||
(state: AppState) => state.deviceToken, | (state: AppState) => state.deviceToken, | ||||
currentCalendarQuery, | currentCalendarQuery, | ||||
( | ( | ||||
deviceToken: ?string, | deviceToken: ?string, | ||||
calendarQuery: (calendarActive: boolean) => CalendarQuery, | calendarQuery: (calendarActive: boolean) => CalendarQuery, | ||||
) => { | ) => { | ||||
let deviceTokenUpdateRequest = null; | let deviceTokenUpdateRequest = null; | ||||
const platform = getConfig().platformDetails.platform; | if (deviceToken) { | ||||
if (deviceToken && isDeviceType(platform)) { | |||||
deviceTokenUpdateRequest = { deviceToken }; | deviceTokenUpdateRequest = { deviceToken }; | ||||
} | } | ||||
// Return a function since we depend on the time of evaluation | // Return a function since we depend on the time of evaluation | ||||
return (calendarActive: boolean): LogInExtraInfo => ({ | return (calendarActive: boolean): LogInExtraInfo => ({ | ||||
calendarQuery: calendarQuery(calendarActive), | calendarQuery: calendarQuery(calendarActive), | ||||
deviceTokenUpdateRequest, | deviceTokenUpdateRequest, | ||||
}); | }); | ||||
}, | }, | ||||
Show All 19 Lines |