@planningcenter/chat-react-native 4.7.0-rc.0 → 4.7.0-rc.2
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/contexts/api_provider.d.ts +1 -0
- package/build/contexts/api_provider.d.ts.map +1 -1
- package/build/contexts/api_provider.js +11 -5
- package/build/contexts/api_provider.js.map +1 -1
- package/build/hooks/index.d.ts +1 -0
- package/build/hooks/index.d.ts.map +1 -1
- package/build/hooks/index.js +1 -0
- package/build/hooks/index.js.map +1 -1
- package/build/hooks/use_system_message_people.d.ts +14 -0
- package/build/hooks/use_system_message_people.d.ts.map +1 -0
- package/build/hooks/use_system_message_people.js +101 -0
- package/build/hooks/use_system_message_people.js.map +1 -0
- package/build/screens/system_message_people_screen.d.ts.map +1 -1
- package/build/screens/system_message_people_screen.js +33 -96
- package/build/screens/system_message_people_screen.js.map +1 -1
- 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/contexts/__tests__/configured_retry.test.ts +39 -0
- package/src/contexts/api_provider.tsx +12 -5
- package/src/hooks/__tests__/use_system_message_people.test.tsx +79 -0
- package/src/hooks/index.ts +1 -0
- package/src/hooks/use_system_message_people.ts +55 -0
- package/src/screens/system_message_people_screen.tsx +6 -20
- 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
|
@@ -5,8 +5,7 @@ import { FlatList } from 'react-native-gesture-handler'
|
|
|
5
5
|
import { useSafeAreaInsets } from 'react-native-safe-area-context'
|
|
6
6
|
import { Avatar, Text } from '../components'
|
|
7
7
|
import FormSheet, { getFormSheetScreenOptions } from '../components/primitive/form_sheet'
|
|
8
|
-
import {
|
|
9
|
-
import { MemberResource } from '../types'
|
|
8
|
+
import { SystemMessagePerson, useSystemMessagePeople } from '../hooks/use_system_message_people'
|
|
10
9
|
|
|
11
10
|
export const SystemMessagePeopleScreenOptions = getFormSheetScreenOptions({
|
|
12
11
|
sheetAllowedDetents: Platform.select({
|
|
@@ -25,26 +24,15 @@ export function SystemMessagePeopleScreen({ route }: SystemMessagePeopleScreenPr
|
|
|
25
24
|
const { conversation_id, person_ids } = route.params
|
|
26
25
|
const styles = useStyles()
|
|
27
26
|
|
|
28
|
-
const { data:
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
fields: {
|
|
32
|
-
Member: ['id', 'name', 'avatar'],
|
|
33
|
-
},
|
|
34
|
-
where: {
|
|
35
|
-
id: person_ids,
|
|
36
|
-
},
|
|
37
|
-
limit: person_ids.length,
|
|
38
|
-
},
|
|
27
|
+
const { data: people } = useSystemMessagePeople({
|
|
28
|
+
conversationId: conversation_id,
|
|
29
|
+
personIds: person_ids,
|
|
39
30
|
})
|
|
40
31
|
|
|
41
|
-
const orderById = Object.fromEntries(person_ids.map((id, i) => [id, i]))
|
|
42
|
-
const sortedMembers = [...members].sort((a, b) => (orderById[a.id] ?? 0) - (orderById[b.id] ?? 0))
|
|
43
|
-
|
|
44
32
|
return (
|
|
45
33
|
<FormSheet.Root contentStyle={styles.formSheetContent}>
|
|
46
34
|
<FlatList
|
|
47
|
-
data={
|
|
35
|
+
data={people}
|
|
48
36
|
contentContainerStyle={styles.contentContainer}
|
|
49
37
|
keyExtractor={item => item.id.toString()}
|
|
50
38
|
renderItem={({ item }) => <Person person={item} />}
|
|
@@ -53,9 +41,7 @@ export function SystemMessagePeopleScreen({ route }: SystemMessagePeopleScreenPr
|
|
|
53
41
|
)
|
|
54
42
|
}
|
|
55
43
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
const Person = memo(({ person }: { person: PersonProps }) => {
|
|
44
|
+
const Person = memo(({ person }: { person: SystemMessagePerson }) => {
|
|
59
45
|
const styles = useStyles()
|
|
60
46
|
|
|
61
47
|
return (
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { CustomMessage } from '@planningcenter/jolt-client/dist/types/JoltConnection'
|
|
2
2
|
import { DenormalizedAttachmentResource } from '../resources/denormalized_attachment_resource'
|
|
3
|
+
import type { FallbackContent } from '../resources/fallback_content'
|
|
3
4
|
import type { SystemTextFormat } from '../resources/message'
|
|
4
5
|
|
|
5
6
|
interface BaseMessageEventData extends Record<string, unknown> {
|
|
@@ -20,6 +21,8 @@ interface BaseMessageEventData extends Record<string, unknown> {
|
|
|
20
21
|
reply_count: number
|
|
21
22
|
reply_root_id: string | null
|
|
22
23
|
message_type: string
|
|
24
|
+
unsupported_message_type?: string | null
|
|
25
|
+
fallback_content?: FallbackContent | null
|
|
23
26
|
system_event_person_ids: number[] | null
|
|
24
27
|
system_text_parts: { names: string[]; overflow_count: number; action: string } | null
|
|
25
28
|
system_text_format: SystemTextFormat | null
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/** FallbackContent
|
|
2
|
+
* The read-only shape the server sends for a message type this build can't render: text and
|
|
3
|
+
* numbers only, nothing actionable, and only `title` is guaranteed. It is a contract with
|
|
4
|
+
* shipped builds, so it only ever gains optional fields.
|
|
5
|
+
*/
|
|
6
|
+
export interface FallbackContentItem {
|
|
7
|
+
label: string
|
|
8
|
+
detail?: string | null
|
|
9
|
+
fraction?: number | null
|
|
10
|
+
selected?: boolean | null
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export interface FallbackContent {
|
|
14
|
+
kind: string
|
|
15
|
+
title: string
|
|
16
|
+
subtitle?: string | null
|
|
17
|
+
items?: FallbackContentItem[] | null
|
|
18
|
+
footer?: string | null
|
|
19
|
+
hint?: string | null
|
|
20
|
+
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { DenormalizedAttachmentResource } from './denormalized_attachment_resource'
|
|
2
2
|
import { DenormalizedAttachmentResourceForCreate } from './denormalized_attachment_resource_for_create'
|
|
3
|
+
import type { FallbackContent } from './fallback_content'
|
|
3
4
|
import type { PersonResource } from './person'
|
|
4
5
|
import type { ReactionCountResource } from './reaction'
|
|
5
6
|
|
|
@@ -22,6 +23,10 @@ export interface MessageResource {
|
|
|
22
23
|
replyRoot?: MessageResource | null
|
|
23
24
|
idempotentKey?: string | null
|
|
24
25
|
messageType: string
|
|
26
|
+
// Set when messageType is 'unsupported': the type the server would have sent a newer client.
|
|
27
|
+
unsupportedMessageType?: string | null
|
|
28
|
+
// Set when messageType is 'unsupported': what to show read-only in place of the type.
|
|
29
|
+
fallbackContent?: FallbackContent | null
|
|
25
30
|
personIdsForSystemEvent?: number[] | null
|
|
26
31
|
systemTextParts?: { names: string[]; overflowCount: number; action: string } | null
|
|
27
32
|
systemTextFormat?: SystemTextFormat | null
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { isUnsupportedMessage } from '../message_types'
|
|
2
|
+
|
|
3
|
+
describe('isUnsupportedMessage', () => {
|
|
4
|
+
it('is false for every type this build renders', () => {
|
|
5
|
+
for (const messageType of [
|
|
6
|
+
'user',
|
|
7
|
+
'user_joined',
|
|
8
|
+
'conversation_archived',
|
|
9
|
+
'conversation_unarchived',
|
|
10
|
+
]) {
|
|
11
|
+
expect(isUnsupportedMessage({ messageType })).toBe(false)
|
|
12
|
+
}
|
|
13
|
+
})
|
|
14
|
+
|
|
15
|
+
it("is true for the server's unsupported placeholder", () => {
|
|
16
|
+
expect(isUnsupportedMessage({ messageType: 'unsupported' })).toBe(true)
|
|
17
|
+
})
|
|
18
|
+
|
|
19
|
+
it('is true for a type this build has no code for, as Jolt can deliver one', () => {
|
|
20
|
+
expect(isUnsupportedMessage({ messageType: 'poll' })).toBe(true)
|
|
21
|
+
})
|
|
22
|
+
})
|
|
@@ -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
|
+
}
|