@planningcenter/chat-react-native 4.7.0-rc.0 → 4.7.0-rc.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/components/conversation/message_list.d.ts.map +1 -1
- package/build/components/conversation/message_list.js +7 -0
- package/build/components/conversation/message_list.js.map +1 -1
- package/build/components/conversation/unsupported_message.d.ts +15 -0
- package/build/components/conversation/unsupported_message.d.ts.map +1 -0
- package/build/components/conversation/unsupported_message.js +415 -0
- package/build/components/conversation/unsupported_message.js.map +1 -0
- package/build/types/jolt_events/message_events.d.ts +3 -0
- package/build/types/jolt_events/message_events.d.ts.map +1 -1
- package/build/types/jolt_events/message_events.js.map +1 -1
- package/build/types/resources/fallback_content.d.ts +20 -0
- package/build/types/resources/fallback_content.d.ts.map +1 -0
- package/build/types/resources/fallback_content.js +2 -0
- package/build/types/resources/fallback_content.js.map +1 -0
- package/build/types/resources/message.d.ts +3 -0
- package/build/types/resources/message.d.ts.map +1 -1
- package/build/types/resources/message.js.map +1 -1
- package/build/utils/jolt/transform_message_event_data_to_message_resource.d.ts.map +1 -1
- package/build/utils/jolt/transform_message_event_data_to_message_resource.js +2 -0
- package/build/utils/jolt/transform_message_event_data_to_message_resource.js.map +1 -1
- package/build/utils/message_types.d.ts +5 -0
- package/build/utils/message_types.d.ts.map +1 -0
- package/build/utils/message_types.js +10 -0
- package/build/utils/message_types.js.map +1 -0
- package/build/utils/request/messages_data_options.d.ts.map +1 -1
- package/build/utils/request/messages_data_options.js +1 -1
- package/build/utils/request/messages_data_options.js.map +1 -1
- package/package.json +2 -2
- package/src/components/conversation/__tests__/message_list.test.tsx +1 -1
- package/src/components/conversation/__tests__/unsupported_message.test.tsx +109 -0
- package/src/components/conversation/message_list.tsx +6 -0
- package/src/components/conversation/unsupported_message.tsx +202 -0
- package/src/types/jolt_events/message_events.ts +3 -0
- package/src/types/resources/fallback_content.ts +20 -0
- package/src/types/resources/message.ts +5 -0
- package/src/utils/__tests__/message_types.test.ts +22 -0
- package/src/utils/jolt/__tests__/transform_message_event_data_to_message_resource.test.ts +10 -0
- package/src/utils/jolt/transform_message_event_data_to_message_resource.ts +2 -0
- package/src/utils/message_types.ts +22 -0
- package/src/utils/request/messages_data_options.ts +1 -0
|
@@ -32,4 +32,14 @@ describe('transformMessageEventDataToMessageResource', () => {
|
|
|
32
32
|
|
|
33
33
|
expect(isSystemMessage(message)).toBe(true)
|
|
34
34
|
})
|
|
35
|
+
|
|
36
|
+
it('carries the fallback content through so unsupported types render read-only in realtime', () => {
|
|
37
|
+
const fallback = { kind: 'poll', title: 'Lunch?', items: [{ label: 'Tacos', detail: '2' }] }
|
|
38
|
+
const message = transformMessageEventDataToMessageResource({
|
|
39
|
+
data: { ...archivedEventData, message_type: 'poll', fallback_content: fallback },
|
|
40
|
+
currentPersonId: 2,
|
|
41
|
+
})
|
|
42
|
+
|
|
43
|
+
expect(message.fallbackContent).toEqual(fallback)
|
|
44
|
+
})
|
|
35
45
|
})
|
|
@@ -31,6 +31,8 @@ export function transformMessageEventDataToMessageResource({
|
|
|
31
31
|
replyRootId: data.reply_root_id || null,
|
|
32
32
|
idempotentKey: data.idempotent_key ?? null,
|
|
33
33
|
messageType: data.message_type,
|
|
34
|
+
unsupportedMessageType: data.unsupported_message_type ?? null,
|
|
35
|
+
fallbackContent: data.fallback_content ?? null,
|
|
34
36
|
personIdsForSystemEvent: data.system_event_person_ids,
|
|
35
37
|
systemTextParts: data.system_text_parts
|
|
36
38
|
? {
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { MessageResource } from '../types/resources/message'
|
|
2
|
+
|
|
3
|
+
// The server reports a type newer than this build's API version as 'unsupported'. Jolt payloads
|
|
4
|
+
// are not versioned, so a type this build has no code for can still arrive under its real name
|
|
5
|
+
// and gets the same treatment.
|
|
6
|
+
export const UNSUPPORTED_MESSAGE_TYPE = 'unsupported'
|
|
7
|
+
|
|
8
|
+
export const SUPPORTED_MESSAGE_TYPES = [
|
|
9
|
+
'user',
|
|
10
|
+
'user_joined',
|
|
11
|
+
'conversation_archived',
|
|
12
|
+
'conversation_unarchived',
|
|
13
|
+
] as const
|
|
14
|
+
|
|
15
|
+
export function isUnsupportedMessage(message: Pick<MessageResource, 'messageType'>): boolean {
|
|
16
|
+
if (!message.messageType) return false
|
|
17
|
+
|
|
18
|
+
return (
|
|
19
|
+
message.messageType === UNSUPPORTED_MESSAGE_TYPE ||
|
|
20
|
+
!(SUPPORTED_MESSAGE_TYPES as readonly string[]).includes(message.messageType)
|
|
21
|
+
)
|
|
22
|
+
}
|