Changeset View
Changeset View
Standalone View
Standalone View
lib/shared/messages/create-sidebar-message-spec.js
// @flow | // @flow | ||||
import invariant from 'invariant'; | import invariant from 'invariant'; | ||||
import { | import { | ||||
pushTypes, | pushTypes, | ||||
type CreateMessageInfoParams, | type CreateMessageInfoParams, | ||||
type MessageSpec, | type MessageSpec, | ||||
type NotificationTextsParams, | type NotificationTextsParams, | ||||
type RobotextParams, | |||||
} from './message-spec.js'; | } from './message-spec.js'; | ||||
import { joinResult } from './utils.js'; | import { joinResult } from './utils.js'; | ||||
import type { PlatformDetails } from '../../types/device-types.js'; | import type { PlatformDetails } from '../../types/device-types.js'; | ||||
import { messageTypes } from '../../types/message-types.js'; | import { messageTypes } from '../../types/message-types.js'; | ||||
import type { | import type { | ||||
MessageInfo, | MessageInfo, | ||||
ClientDBMessageInfo, | ClientDBMessageInfo, | ||||
} from '../../types/message-types.js'; | } from '../../types/message-types.js'; | ||||
▲ Show 20 Lines • Show All 110 Lines • ▼ Show 20 Lines | > = Object.freeze({ | ||||
rawMessageInfoFromMessageData( | rawMessageInfoFromMessageData( | ||||
messageData: CreateSidebarMessageData, | messageData: CreateSidebarMessageData, | ||||
id: ?string, | id: ?string, | ||||
): RawCreateSidebarMessageInfo { | ): RawCreateSidebarMessageInfo { | ||||
invariant(id, 'RawCreateSidebarMessageInfo needs id'); | invariant(id, 'RawCreateSidebarMessageInfo needs id'); | ||||
return { ...messageData, id }; | return { ...messageData, id }; | ||||
}, | }, | ||||
robotext(messageInfo: CreateSidebarMessageInfo): EntityText { | robotext( | ||||
messageInfo: CreateSidebarMessageInfo, | |||||
params: RobotextParams, | |||||
): EntityText { | |||||
let text = ET`started ${ET.thread({ | let text = ET`started ${ET.thread({ | ||||
display: 'alwaysDisplayShortName', | display: 'alwaysDisplayShortName', | ||||
threadID: messageInfo.threadID, | threadID: messageInfo.threadID, | ||||
threadType: params.threadInfo?.type, | |||||
parentThreadID: params.threadInfo?.parentThreadID, | |||||
})}`; | })}`; | ||||
const users = messageInfo.initialThreadState.otherMembers.filter( | const users = messageInfo.initialThreadState.otherMembers.filter( | ||||
member => member.id !== messageInfo.sourceMessageAuthor.id, | member => member.id !== messageInfo.sourceMessageAuthor.id, | ||||
); | ); | ||||
if (users.length !== 0) { | if (users.length !== 0) { | ||||
const initialUsers = pluralizeEntityText( | const initialUsers = pluralizeEntityText( | ||||
users.map(user => ET`${ET.user({ userInfo: user })}`), | users.map(user => ET`${ET.user({ userInfo: user })}`), | ||||
); | ); | ||||
▲ Show 20 Lines • Show All 77 Lines • Show Last 20 Lines |