Changeset View
Changeset View
Standalone View
Standalone View
lib/shared/message-utils.js
// @flow | // @flow | ||||
import invariant from 'invariant'; | import invariant from 'invariant'; | ||||
import _maxBy from 'lodash/fp/maxBy.js'; | import _maxBy from 'lodash/fp/maxBy.js'; | ||||
import _orderBy from 'lodash/fp/orderBy.js'; | import _orderBy from 'lodash/fp/orderBy.js'; | ||||
import * as React from 'react'; | import * as React from 'react'; | ||||
import { codeBlockRegex, type ParserRules } from './markdown.js'; | import { codeBlockRegex, type ParserRules } from './markdown.js'; | ||||
import type { CreationSideEffectsFunc } from './messages/message-spec.js'; | import type { CreationSideEffectsFunc } from './messages/message-spec.js'; | ||||
import { messageSpecs } from './messages/message-specs.js'; | import { messageSpecs } from './messages/message-specs.js'; | ||||
import { threadIsGroupChat } from './thread-utils.js'; | import { threadIsGroupChat } from './thread-utils.js'; | ||||
import { useStringForUser } from '../hooks/ens-cache.js'; | import { useStringForUser } from '../hooks/ens-cache.js'; | ||||
import { userIDsToRelativeUserInfos } from '../selectors/user-selectors.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 { Media } from '../types/media-types.js'; | ||||
import { | import { | ||||
type MessageInfo, | type MessageInfo, | ||||
type RawMessageInfo, | type RawMessageInfo, | ||||
type RobotextMessageInfo, | type RobotextMessageInfo, | ||||
type RawMultimediaMessageInfo, | type RawMultimediaMessageInfo, | ||||
type MessageData, | type MessageData, | ||||
type MessageTruncationStatus, | type MessageTruncationStatus, | ||||
▲ Show 20 Lines • Show All 191 Lines • ▼ Show 20 Lines | ) { | ||||
return first; | return first; | ||||
} | } | ||||
} | } | ||||
function shimUnsupportedRawMessageInfos( | function shimUnsupportedRawMessageInfos( | ||||
rawMessageInfos: $ReadOnlyArray<RawMessageInfo>, | rawMessageInfos: $ReadOnlyArray<RawMessageInfo>, | ||||
platformDetails: ?PlatformDetails, | platformDetails: ?PlatformDetails, | ||||
): RawMessageInfo[] { | ): RawMessageInfo[] { | ||||
if (platformDetails && platformDetails.platform === 'web') { | if (platformDetails && isWebPlatform(platformDetails.platform)) { | ||||
return [...rawMessageInfos]; | return [...rawMessageInfos]; | ||||
} | } | ||||
return rawMessageInfos.map(rawMessageInfo => { | return rawMessageInfos.map(rawMessageInfo => { | ||||
const { shimUnsupportedMessageInfo } = messageSpecs[rawMessageInfo.type]; | const { shimUnsupportedMessageInfo } = messageSpecs[rawMessageInfo.type]; | ||||
if (shimUnsupportedMessageInfo) { | if (shimUnsupportedMessageInfo) { | ||||
return shimUnsupportedMessageInfo(rawMessageInfo, platformDetails); | return shimUnsupportedMessageInfo(rawMessageInfo, platformDetails); | ||||
} | } | ||||
return rawMessageInfo; | return rawMessageInfo; | ||||
▲ Show 20 Lines • Show All 348 Lines • Show Last 20 Lines |