diff --git a/keyserver/src/session/cookies.js b/keyserver/src/session/cookies.js --- a/keyserver/src/session/cookies.js +++ b/keyserver/src/session/cookies.js @@ -9,6 +9,7 @@ import { hasMinCodeVersion } from 'lib/shared/version-utils.js'; import type { Shape } from 'lib/types/core.js'; import type { SignedIdentityKeysBlob } from 'lib/types/crypto-types.js'; +import { isWebPlatform } from 'lib/types/device-types.js'; import type { Platform, PlatformDetails } from 'lib/types/device-types.js'; import type { CalendarQuery } from 'lib/types/entry-types.js'; import { @@ -317,7 +318,7 @@ invariant( req.method === 'GET' || viewer.sessionIdentifierType !== sessionIdentifierTypes.COOKIE_ID || - viewer.platform !== 'web', + !isWebPlatform(viewer.platform), 'non-GET request from web using sessionIdentifierTypes.COOKIE_ID', ); } diff --git a/lib/shared/message-utils.js b/lib/shared/message-utils.js --- a/lib/shared/message-utils.js +++ b/lib/shared/message-utils.js @@ -11,7 +11,7 @@ import { threadIsGroupChat } from './thread-utils.js'; import { useStringForUser } from '../hooks/ens-cache.js'; import { userIDsToRelativeUserInfos } from '../selectors/user-selectors.js'; -import type { PlatformDetails } from '../types/device-types.js'; +import { type PlatformDetails, isWebPlatform } from '../types/device-types.js'; import type { Media } from '../types/media-types.js'; import { type MessageInfo, @@ -219,7 +219,7 @@ rawMessageInfos: $ReadOnlyArray, platformDetails: ?PlatformDetails, ): RawMessageInfo[] { - if (platformDetails && platformDetails.platform === 'web') { + if (platformDetails && isWebPlatform(platformDetails.platform)) { return [...rawMessageInfos]; } return rawMessageInfos.map(rawMessageInfo => { diff --git a/lib/shared/version-utils.js b/lib/shared/version-utils.js --- a/lib/shared/version-utils.js +++ b/lib/shared/version-utils.js @@ -1,12 +1,12 @@ // @flow -import type { PlatformDetails } from '../types/device-types.js'; +import { type PlatformDetails, isWebPlatform } from '../types/device-types.js'; function hasMinCodeVersion( platformDetails: ?PlatformDetails, minCodeVersion: number, ): boolean { - if (!platformDetails || platformDetails.platform === 'web') { + if (!platformDetails || isWebPlatform(platformDetails.platform)) { return true; } const { codeVersion } = platformDetails; diff --git a/lib/socket/socket.react.js b/lib/socket/socket.react.js --- a/lib/socket/socket.react.js +++ b/lib/socket/socket.react.js @@ -29,6 +29,7 @@ logInActionSources, type LogOutResult, } from '../types/account-types.js'; +import { isWebPlatform } from '../types/device-types.js'; import type { CalendarQuery } from '../types/entry-types.js'; import { forcePolicyAcknowledgmentActionType } from '../types/policy-types.js'; import type { Dispatch } from '../types/redux-types.js'; @@ -120,8 +121,9 @@ listeners: Set = new Set(); pingTimeoutID: ?TimeoutID; messageLastReceived: ?number; - initialPlatformDetailsSent: boolean = - getConfig().platformDetails.platform === 'web'; + initialPlatformDetailsSent: boolean = isWebPlatform( + getConfig().platformDetails.platform, + ); reopenConnectionAfterClosing: boolean = false; invalidationRecoveryInProgress: boolean = false; initializedWithUserState: ?PreRequestUserState; @@ -130,7 +132,7 @@ openSocket(newStatus: ConnectionStatus) { if ( this.props.frozen || - (getConfig().platformDetails.platform !== 'web' && + (!isWebPlatform(getConfig().platformDetails.platform) && (!this.props.cookie || !this.props.cookie.startsWith('user='))) ) { return; diff --git a/lib/types/device-types.js b/lib/types/device-types.js --- a/lib/types/device-types.js +++ b/lib/types/device-types.js @@ -17,6 +17,10 @@ return deviceType; } +export function isWebPlatform(platform: ?string): boolean { + return platform === 'web'; +} + export type DeviceTokenUpdateRequest = { +deviceToken: string, +deviceType?: DeviceType, diff --git a/lib/types/entry-types.js b/lib/types/entry-types.js --- a/lib/types/entry-types.js +++ b/lib/types/entry-types.js @@ -1,6 +1,6 @@ // @flow -import type { Platform } from './device-types.js'; +import { type Platform, isWebPlatform } from './device-types.js'; import { type CalendarFilter, defaultCalendarFilters } from './filter-types.js'; import type { RawMessageInfo } from './message-types.js'; import type { @@ -56,7 +56,7 @@ platform: ?Platform, timeZone?: ?string, ): CalendarQuery => { - if (platform === 'web') { + if (isWebPlatform(platform)) { return { ...thisMonthDates(timeZone), filters: defaultCalendarFilters,