diff --git a/keyserver/src/responders/website-responders.js b/keyserver/src/responders/website-responders.js --- a/keyserver/src/responders/website-responders.js +++ b/keyserver/src/responders/website-responders.js @@ -396,7 +396,7 @@ }, nextLocalID: 0, cookie: undefined, - deviceToken: undefined, + deviceToken: null, dataLoaded: viewer.loggedIn, windowActive: true, userPolicies: {}, diff --git a/keyserver/src/updaters/device-token-updaters.js b/keyserver/src/updaters/device-token-updaters.js --- a/keyserver/src/updaters/device-token-updaters.js +++ b/keyserver/src/updaters/device-token-updaters.js @@ -1,9 +1,6 @@ // @flow -import { - type DeviceTokenUpdateRequest, - isDeviceType, -} from 'lib/types/device-types.js'; +import { type DeviceTokenUpdateRequest } from 'lib/types/device-types.js'; import { ServerError } from 'lib/utils/errors.js'; import { dbQuery, SQL } from '../database/database.js'; @@ -14,7 +11,7 @@ update: DeviceTokenUpdateRequest, ): Promise { const deviceType = update.platformDetails?.platform ?? update.deviceType; - if (!isDeviceType(deviceType)) { + if (deviceType === undefined) { throw new ServerError('invalid_parameters'); } diff --git a/lib/reducers/master-reducer.js b/lib/reducers/master-reducer.js --- a/lib/reducers/master-reducer.js +++ b/lib/reducers/master-reducer.js @@ -3,6 +3,7 @@ import reduceCalendarFilters from './calendar-filters-reducer.js'; import reduceConnectionInfo from './connection-reducer.js'; import reduceDataLoaded from './data-loaded-reducer.js'; +import { reduceDeviceToken } from './device-token-reducer.js'; import { reduceDraftStore } from './draft-reducer.js'; import reduceEnabledApps from './enabled-apps-reducer.js'; import { reduceEntryInfos } from './entry-reducer.js'; @@ -107,6 +108,7 @@ nextLocalID: reduceNextLocalID(state.nextLocalID, action), dataLoaded: reduceDataLoaded(state.dataLoaded, action), userPolicies: policiesReducer(state.userPolicies, action), + deviceToken: reduceDeviceToken(state.deviceToken, action), }, storeOperations: { draftStoreOperations, diff --git a/lib/selectors/account-selectors.js b/lib/selectors/account-selectors.js --- a/lib/selectors/account-selectors.js +++ b/lib/selectors/account-selectors.js @@ -4,12 +4,10 @@ import { currentCalendarQuery } from './nav-selectors.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 { AppState } from '../types/redux-types.js'; import type { PreRequestUserState } from '../types/session-types.js'; import type { CurrentUserInfo } from '../types/user-types.js'; -import { getConfig } from '../utils/config.js'; const logInExtraInfoSelector: ( state: AppState, @@ -21,8 +19,7 @@ calendarQuery: (calendarActive: boolean) => CalendarQuery, ) => { let deviceTokenUpdateRequest = null; - const platform = getConfig().platformDetails.platform; - if (deviceToken && isDeviceType(platform)) { + if (deviceToken) { deviceTokenUpdateRequest = { deviceToken }; } // Return a function since we depend on the time of evaluation diff --git a/lib/types/redux-types.js b/lib/types/redux-types.js --- a/lib/types/redux-types.js +++ b/lib/types/redux-types.js @@ -105,21 +105,19 @@ nextLocalID: number, dataLoaded: boolean, userPolicies: UserPolicies, + deviceToken: ?string, ... }; // Web JS runtime doesn't have access to the cookie for security reasons. // Native JS doesn't have a sessionID because the cookieID is used instead. -// Web JS doesn't have a device token because it's not a device... export type NativeAppState = BaseAppState<*> & { sessionID?: void, - deviceToken: ?string, cookie: ?string, ... }; export type WebAppState = BaseAppState<*> & { sessionID: ?string, - deviceToken?: void, cookie?: void, cryptoStore: CryptoStore, pushApiPublicKey: ?string, diff --git a/lib/utils/sanitization.js b/lib/utils/sanitization.js --- a/lib/utils/sanitization.js +++ b/lib/utils/sanitization.js @@ -300,7 +300,7 @@ state = { ...oldState, cookie: null }; } if (state.deviceToken !== undefined && state.deviceToken !== null) { - const oldState: NativeAppState = state; + const oldState: AppState = state; state = { ...oldState, deviceToken: null }; } const stateCopy = clone(state); diff --git a/native/redux/redux-setup.js b/native/redux/redux-setup.js --- a/native/redux/redux-setup.js +++ b/native/redux/redux-setup.js @@ -13,7 +13,6 @@ deleteAccountActionTypes, logInActionTypes, } from 'lib/actions/user-actions.js'; -import { reduceDeviceToken } from 'lib/reducers/device-token-reducer.js'; import baseReducer from 'lib/reducers/master-reducer.js'; import { processThreadStoreOperations } from 'lib/reducers/thread-reducer.js'; import { @@ -332,10 +331,6 @@ } } - state = { - ...state, - deviceToken: reduceDeviceToken(state.deviceToken, action), - }; const baseReducerResult = baseReducer(state, (action: BaseAction)); state = baseReducerResult.state; diff --git a/web/redux/redux-setup.js b/web/redux/redux-setup.js --- a/web/redux/redux-setup.js +++ b/web/redux/redux-setup.js @@ -77,7 +77,7 @@ urlPrefix: string, windowDimensions: WindowDimensions, cookie?: void, - deviceToken?: void, + deviceToken: ?string, baseHref: string, connection: ConnectionInfo, watchedThreadIDs: $ReadOnlyArray,