@planningcenter/chat-react-native 3.1.0-rc.13 → 3.1.0-rc.14

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.
Files changed (218) hide show
  1. package/build/components/conversation/attachments/attachment_card.d.ts +9 -0
  2. package/build/components/conversation/attachments/attachment_card.d.ts.map +1 -0
  3. package/build/components/conversation/attachments/attachment_card.js +35 -0
  4. package/build/components/conversation/attachments/attachment_card.js.map +1 -0
  5. package/build/components/conversation/attachments/audio_attachment.d.ts +6 -0
  6. package/build/components/conversation/attachments/audio_attachment.d.ts.map +1 -0
  7. package/build/components/conversation/attachments/audio_attachment.js +84 -0
  8. package/build/components/conversation/attachments/audio_attachment.js.map +1 -0
  9. package/build/components/conversation/attachments/constants.d.ts +3 -0
  10. package/build/components/conversation/attachments/constants.d.ts.map +1 -0
  11. package/build/components/conversation/attachments/constants.js +4 -0
  12. package/build/components/conversation/attachments/constants.js.map +1 -0
  13. package/build/components/conversation/attachments/download_attachment_button.d.ts +9 -0
  14. package/build/components/conversation/attachments/download_attachment_button.d.ts.map +1 -0
  15. package/build/components/conversation/attachments/download_attachment_button.js +29 -0
  16. package/build/components/conversation/attachments/download_attachment_button.js.map +1 -0
  17. package/build/components/conversation/attachments/expanded_link.d.ts +5 -0
  18. package/build/components/conversation/attachments/expanded_link.d.ts.map +1 -0
  19. package/build/components/conversation/attachments/expanded_link.js +44 -0
  20. package/build/components/conversation/attachments/expanded_link.js.map +1 -0
  21. package/build/components/conversation/attachments/generic_file_attachment.d.ts +7 -0
  22. package/build/components/conversation/attachments/generic_file_attachment.d.ts.map +1 -0
  23. package/build/components/conversation/attachments/generic_file_attachment.js +63 -0
  24. package/build/components/conversation/attachments/generic_file_attachment.js.map +1 -0
  25. package/build/components/conversation/attachments/giphy_attachment.d.ts +6 -0
  26. package/build/components/conversation/attachments/giphy_attachment.d.ts.map +1 -0
  27. package/build/components/conversation/attachments/giphy_attachment.js +42 -0
  28. package/build/components/conversation/attachments/giphy_attachment.js.map +1 -0
  29. package/build/components/conversation/attachments/image_attachment.d.ts +5 -0
  30. package/build/components/conversation/attachments/image_attachment.d.ts.map +1 -0
  31. package/build/components/conversation/attachments/image_attachment.js +24 -0
  32. package/build/components/conversation/attachments/image_attachment.js.map +1 -0
  33. package/build/components/conversation/attachments/video_attachment.d.ts +6 -0
  34. package/build/components/conversation/attachments/video_attachment.d.ts.map +1 -0
  35. package/build/components/conversation/attachments/video_attachment.js +64 -0
  36. package/build/components/conversation/attachments/video_attachment.js.map +1 -0
  37. package/build/components/conversation/message.d.ts +1 -1
  38. package/build/components/conversation/message.d.ts.map +1 -1
  39. package/build/components/conversation/message.js +10 -6
  40. package/build/components/conversation/message.js.map +1 -1
  41. package/build/components/conversation/message_attachments.d.ts +6 -0
  42. package/build/components/conversation/message_attachments.d.ts.map +1 -0
  43. package/build/components/conversation/message_attachments.js +52 -0
  44. package/build/components/conversation/message_attachments.js.map +1 -0
  45. package/build/components/conversations.d.ts +6 -1
  46. package/build/components/conversations.d.ts.map +1 -1
  47. package/build/components/conversations.js +19 -24
  48. package/build/components/conversations.js.map +1 -1
  49. package/build/components/display/badge.d.ts +9 -1
  50. package/build/components/display/badge.d.ts.map +1 -1
  51. package/build/components/display/badge.js +22 -10
  52. package/build/components/display/badge.js.map +1 -1
  53. package/build/components/display/button.d.ts +1 -1
  54. package/build/components/display/button.d.ts.map +1 -1
  55. package/build/components/display/button.js.map +1 -1
  56. package/build/components/display/child_notice.js +2 -2
  57. package/build/components/display/child_notice.js.map +1 -1
  58. package/build/components/display/icon.d.ts.map +1 -1
  59. package/build/components/display/icon.js +10 -8
  60. package/build/components/display/icon.js.map +1 -1
  61. package/build/components/page/error_boundary.d.ts +1 -1
  62. package/build/hooks/use_api.d.ts +6 -4
  63. package/build/hooks/use_api.d.ts.map +1 -1
  64. package/build/hooks/use_api.js +5 -2
  65. package/build/hooks/use_api.js.map +1 -1
  66. package/build/hooks/use_api_client.d.ts +1 -2
  67. package/build/hooks/use_api_client.d.ts.map +1 -1
  68. package/build/hooks/use_api_client.js.map +1 -1
  69. package/build/hooks/use_conversation.js +1 -1
  70. package/build/hooks/use_conversation.js.map +1 -1
  71. package/build/hooks/use_conversation_jolt_events.js +1 -1
  72. package/build/hooks/use_conversation_jolt_events.js.map +1 -1
  73. package/build/hooks/use_conversation_messages_jolt_events.js +1 -1
  74. package/build/hooks/use_conversation_messages_jolt_events.js.map +1 -1
  75. package/build/hooks/use_conversations.d.ts +2 -3
  76. package/build/hooks/use_conversations.d.ts.map +1 -1
  77. package/build/hooks/use_conversations.js +3 -29
  78. package/build/hooks/use_conversations.js.map +1 -1
  79. package/build/hooks/use_groups.d.ts +214 -0
  80. package/build/hooks/use_groups.d.ts.map +1 -0
  81. package/build/hooks/use_groups.js +22 -0
  82. package/build/hooks/use_groups.js.map +1 -0
  83. package/build/hooks/use_groups_groups.d.ts +208 -0
  84. package/build/hooks/use_groups_groups.d.ts.map +1 -0
  85. package/build/hooks/use_groups_groups.js +18 -0
  86. package/build/hooks/use_groups_groups.js.map +1 -0
  87. package/build/hooks/use_services_team.d.ts +4 -0
  88. package/build/hooks/use_services_team.d.ts.map +1 -0
  89. package/build/hooks/use_services_team.js +22 -0
  90. package/build/hooks/use_services_team.js.map +1 -0
  91. package/build/hooks/use_suspense_api.d.ts +2 -1
  92. package/build/hooks/use_suspense_api.d.ts.map +1 -1
  93. package/build/hooks/use_suspense_api.js +2 -1
  94. package/build/hooks/use_suspense_api.js.map +1 -1
  95. package/build/hooks/use_teams.d.ts +208 -0
  96. package/build/hooks/use_teams.d.ts.map +1 -0
  97. package/build/hooks/use_teams.js +22 -0
  98. package/build/hooks/use_teams.js.map +1 -0
  99. package/build/navigation/index.d.ts +11 -0
  100. package/build/navigation/index.d.ts.map +1 -1
  101. package/build/navigation/index.js +5 -0
  102. package/build/navigation/index.js.map +1 -1
  103. package/build/screens/conversation_details_screen.d.ts.map +1 -1
  104. package/build/screens/conversation_details_screen.js +86 -62
  105. package/build/screens/conversation_details_screen.js.map +1 -1
  106. package/build/screens/conversation_filters_screen.d.ts +13 -0
  107. package/build/screens/conversation_filters_screen.d.ts.map +1 -0
  108. package/build/screens/conversation_filters_screen.js +346 -0
  109. package/build/screens/conversation_filters_screen.js.map +1 -0
  110. package/build/screens/conversation_screen.js +2 -1
  111. package/build/screens/conversation_screen.js.map +1 -1
  112. package/build/screens/conversations_screen.d.ts +4 -2
  113. package/build/screens/conversations_screen.d.ts.map +1 -1
  114. package/build/screens/conversations_screen.js +139 -11
  115. package/build/screens/conversations_screen.js.map +1 -1
  116. package/build/screens/create/conversation_select_recipients_screen.d.ts.map +1 -1
  117. package/build/screens/create/conversation_select_recipients_screen.js +3 -11
  118. package/build/screens/create/conversation_select_recipients_screen.js.map +1 -1
  119. package/build/types/resources/group_resource.d.ts +4 -2
  120. package/build/types/resources/group_resource.d.ts.map +1 -1
  121. package/build/types/resources/group_resource.js.map +1 -1
  122. package/build/types/resources/index.d.ts +1 -0
  123. package/build/types/resources/index.d.ts.map +1 -1
  124. package/build/types/resources/index.js +1 -0
  125. package/build/types/resources/index.js.map +1 -1
  126. package/build/types/resources/services/index.d.ts +2 -0
  127. package/build/types/resources/services/index.d.ts.map +1 -0
  128. package/build/types/resources/services/index.js +2 -0
  129. package/build/types/resources/services/index.js.map +1 -0
  130. package/build/types/resources/services/team_resource.d.ts +48 -0
  131. package/build/types/resources/services/team_resource.d.ts.map +1 -0
  132. package/build/types/resources/services/team_resource.js +7 -0
  133. package/build/types/resources/services/team_resource.js.map +1 -0
  134. package/build/utils/index.d.ts +1 -0
  135. package/build/utils/index.d.ts.map +1 -1
  136. package/build/utils/index.js +1 -0
  137. package/build/utils/index.js.map +1 -1
  138. package/build/utils/native_adapters/audio.d.ts +13 -0
  139. package/build/utils/native_adapters/audio.d.ts.map +1 -0
  140. package/build/utils/native_adapters/audio.js +7 -0
  141. package/build/utils/native_adapters/audio.js.map +1 -0
  142. package/build/utils/native_adapters/configuration.d.ts +7 -1
  143. package/build/utils/native_adapters/configuration.d.ts.map +1 -1
  144. package/build/utils/native_adapters/configuration.js +17 -1
  145. package/build/utils/native_adapters/configuration.js.map +1 -1
  146. package/build/utils/native_adapters/index.d.ts +2 -0
  147. package/build/utils/native_adapters/index.d.ts.map +1 -1
  148. package/build/utils/native_adapters/index.js +2 -0
  149. package/build/utils/native_adapters/index.js.map +1 -1
  150. package/build/utils/native_adapters/video.d.ts +25 -0
  151. package/build/utils/native_adapters/video.d.ts.map +1 -0
  152. package/build/utils/native_adapters/video.js +7 -0
  153. package/build/utils/native_adapters/video.js.map +1 -0
  154. package/build/utils/pluralize.d.ts +2 -0
  155. package/build/utils/pluralize.d.ts.map +1 -0
  156. package/build/utils/pluralize.js +10 -0
  157. package/build/utils/pluralize.js.map +1 -0
  158. package/build/utils/request/conversation.d.ts +10 -0
  159. package/build/utils/request/conversation.d.ts.map +1 -0
  160. package/build/utils/request/conversation.js +32 -0
  161. package/build/utils/request/conversation.js.map +1 -0
  162. package/build/utils/request/messages.d.ts +15 -0
  163. package/build/utils/request/messages.d.ts.map +1 -0
  164. package/build/utils/request/messages.js +22 -0
  165. package/build/utils/request/messages.js.map +1 -0
  166. package/build/utils/theme.d.ts +1 -1
  167. package/build/utils/theme.d.ts.map +1 -1
  168. package/build/utils/theme.js +1 -1
  169. package/build/utils/theme.js.map +1 -1
  170. package/package.json +2 -2
  171. package/src/__tests__/utils/pluralize.tsx +17 -0
  172. package/src/components/conversation/attachments/attachment_card.tsx +46 -0
  173. package/src/components/conversation/attachments/audio_attachment.tsx +102 -0
  174. package/src/components/conversation/attachments/constants.ts +5 -0
  175. package/src/components/conversation/attachments/download_attachment_button.tsx +46 -0
  176. package/src/components/conversation/attachments/expanded_link.tsx +54 -0
  177. package/src/components/conversation/attachments/generic_file_attachment.tsx +75 -0
  178. package/src/components/conversation/attachments/giphy_attachment.tsx +56 -0
  179. package/src/components/conversation/attachments/image_attachment.tsx +31 -0
  180. package/src/components/conversation/attachments/video_attachment.tsx +92 -0
  181. package/src/components/conversation/message.tsx +10 -5
  182. package/src/components/conversation/message_attachments.tsx +61 -0
  183. package/src/components/conversations.tsx +37 -35
  184. package/src/components/display/badge.tsx +41 -10
  185. package/src/components/display/button.tsx +1 -1
  186. package/src/components/display/child_notice.tsx +2 -2
  187. package/src/components/display/icon.tsx +10 -8
  188. package/src/hooks/use_api.ts +11 -10
  189. package/src/hooks/use_api_client.ts +1 -1
  190. package/src/hooks/use_conversation.ts +1 -1
  191. package/src/hooks/use_conversation_jolt_events.ts +1 -1
  192. package/src/hooks/use_conversation_messages_jolt_events.ts +1 -1
  193. package/src/hooks/use_conversations.ts +3 -31
  194. package/src/hooks/use_groups.ts +31 -0
  195. package/src/hooks/use_groups_groups.ts +20 -0
  196. package/src/hooks/use_services_team.ts +30 -0
  197. package/src/hooks/use_suspense_api.ts +4 -4
  198. package/src/hooks/use_teams.ts +25 -0
  199. package/src/navigation/index.tsx +8 -0
  200. package/src/screens/conversation_details_screen.tsx +149 -117
  201. package/src/screens/conversation_filters_screen.tsx +488 -0
  202. package/src/screens/conversation_screen.tsx +8 -1
  203. package/src/screens/conversations_screen.tsx +210 -13
  204. package/src/screens/create/conversation_select_recipients_screen.tsx +3 -11
  205. package/src/types/resources/group_resource.ts +5 -2
  206. package/src/types/resources/index.ts +1 -0
  207. package/src/types/resources/services/index.ts +1 -0
  208. package/src/types/resources/services/team_resource.ts +60 -0
  209. package/src/utils/client/types.d.ts +2 -1
  210. package/src/utils/index.ts +1 -0
  211. package/src/utils/native_adapters/audio.ts +15 -0
  212. package/src/utils/native_adapters/configuration.ts +24 -1
  213. package/src/utils/native_adapters/index.ts +2 -0
  214. package/src/utils/native_adapters/video.ts +30 -0
  215. package/src/utils/pluralize.ts +11 -0
  216. package/src/utils/request/conversation.ts +46 -0
  217. package/src/utils/request/messages.ts +21 -0
  218. package/src/utils/theme.ts +2 -2
@@ -1,25 +1,222 @@
1
- import { StaticScreenProps } from '@react-navigation/native'
2
- import React from 'react'
1
+ import { RouteProp, StaticScreenProps, useNavigation, useRoute } from '@react-navigation/native'
2
+ import React, { useCallback, useMemo } from 'react'
3
3
  import { StyleSheet, View } from 'react-native'
4
- import { Conversations } from '../components'
4
+ import { Badge, Button, ButtonProps, Conversations, Heading, TextButton } from '../components'
5
+ import { ActionButton } from '../components/display/action_button'
6
+ import { useCanCreateConversations, useTheme } from '../hooks'
7
+ import { useApiGet } from '../hooks/use_api'
8
+ import { GraphId, GroupResource } from '../types/resources/group_resource'
9
+ import { useCanDisplayGroups } from '../hooks/use_groups'
5
10
 
6
11
  export type ConversationScreenProps = StaticScreenProps<{
7
12
  title?: string
8
- chat_group_graph_id?: string
13
+ chat_group_graph_id?: GraphId
14
+ group_source_app_name?: string
9
15
  }>
10
16
 
11
- export function ConversationsScreen(_props: ConversationScreenProps) {
17
+ export function ConversationsScreen({ route }: ConversationScreenProps) {
18
+ const navigation = useNavigation()
19
+ const canCreateConversations = useCanCreateConversations()
20
+ const styles = useStyles()
21
+ const { chat_group_graph_id, group_source_app_name } = route.params
22
+
23
+ const filter = useMemo(() => {
24
+ if (chat_group_graph_id) {
25
+ return 'group'
26
+ } else if (group_source_app_name) {
27
+ return 'group_source_app_name'
28
+ }
29
+
30
+ return 'mine_or_not_empty'
31
+ }, [chat_group_graph_id, group_source_app_name])
32
+
12
33
  return (
13
34
  <View style={styles.container}>
14
- <Conversations />
35
+ <Conversations
36
+ ListHeaderComponent={ListHeaderComponent}
37
+ group={chat_group_graph_id}
38
+ group_source_app_name={group_source_app_name}
39
+ filter={filter}
40
+ />
41
+ <ActionButton
42
+ visible={canCreateConversations}
43
+ title="New conversation"
44
+ onPress={() => navigation.navigate('Create')}
45
+ />
46
+ </View>
47
+ )
48
+ }
49
+
50
+ enum FilterTypes {
51
+ All = 'All',
52
+ Groups = 'Groups',
53
+ Teams = 'Teams',
54
+ More = 'More',
55
+ }
56
+
57
+ const ListHeaderComponent = () => {
58
+ const styles = useStyles()
59
+ const navigation = useNavigation()
60
+ const canFilterByTeams = useCanDisplayGroups({ source_app_name: 'Services', source_type: 'Team' })
61
+ const canFilterByGroups = useCanDisplayGroups({ source_app_name: 'Groups', source_type: 'Group' })
62
+ const route = useRoute<RouteProp<ConversationScreenProps['route']>>()
63
+ const { chat_group_graph_id, group_source_app_name = '' } = route.params
64
+
65
+ const active: FilterTypes = useMemo(() => {
66
+ if (chat_group_graph_id) {
67
+ return FilterTypes.More
68
+ } else if (/groups/i.test(group_source_app_name)) {
69
+ return FilterTypes.Groups
70
+ } else if (/services/i.test(group_source_app_name)) {
71
+ return FilterTypes.Teams
72
+ }
73
+
74
+ return FilterTypes.All
75
+ }, [chat_group_graph_id, group_source_app_name])
76
+
77
+ const hideAppFilters = !canFilterByGroups || !canFilterByTeams
78
+
79
+ return (
80
+ <View style={styles.listHeader}>
81
+ <View style={styles.titleRow}>
82
+ <Heading numberOfLines={1} variant="h2">
83
+ Conversations
84
+ </Heading>
85
+ <TextButton>Mark all read</TextButton>
86
+ </View>
87
+ <View style={styles.filterRow}>
88
+ <FilterButton
89
+ title={FilterTypes.All}
90
+ activeTitle={active}
91
+ hidden={!canFilterByGroups || !canFilterByTeams}
92
+ onPress={() =>
93
+ navigation.setParams({
94
+ chat_group_graph_id: undefined,
95
+ group_source_app_name: undefined,
96
+ })
97
+ }
98
+ />
99
+ <FilterButton
100
+ title={FilterTypes.Groups}
101
+ activeTitle={active}
102
+ hidden={hideAppFilters}
103
+ onPress={() =>
104
+ navigation.setParams({
105
+ chat_group_graph_id: undefined,
106
+ group_source_app_name: 'Groups',
107
+ })
108
+ }
109
+ />
110
+ <FilterButton
111
+ title={FilterTypes.Teams}
112
+ activeTitle={active}
113
+ hidden={hideAppFilters}
114
+ onPress={() =>
115
+ navigation.setParams({
116
+ chat_group_graph_id: undefined,
117
+ group_source_app_name: 'Services',
118
+ })
119
+ }
120
+ />
121
+ <Button
122
+ title={hideAppFilters ? 'Filter' : FilterTypes.More}
123
+ onPress={() =>
124
+ navigation.navigate('ConversationFilters', {
125
+ chat_group_graph_id,
126
+ group_source_app_name,
127
+ })
128
+ }
129
+ variant={active === FilterTypes.More ? 'fill' : 'outline'}
130
+ iconNameRight="general.threeReducingHorizontalBars"
131
+ />
132
+ </View>
133
+ <Badges />
15
134
  </View>
16
135
  )
17
136
  }
18
137
 
19
- const styles = StyleSheet.create({
20
- container: {
21
- flex: 1,
22
- justifyContent: 'center',
23
- gap: 8,
24
- },
25
- })
138
+ const Badges = () => {
139
+ const styles = useStyles()
140
+ const navigation = useNavigation()
141
+ const route = useRoute<RouteProp<ConversationScreenProps['route']>>()
142
+ const { chat_group_graph_id } = route.params
143
+ const { data: group } = useApiGet<GroupResource>({
144
+ url: `/me/groups/${chat_group_graph_id}`,
145
+ data: {
146
+ fields: {
147
+ Group: [],
148
+ },
149
+ },
150
+ enabled: !!chat_group_graph_id,
151
+ app: 'chat',
152
+ })
153
+
154
+ const handleBadgePress = useCallback(() => {
155
+ navigation.setParams({
156
+ chat_group_graph_id: undefined,
157
+ group_source_app_name: undefined,
158
+ })
159
+ }, [navigation])
160
+
161
+ if (!group) return null
162
+
163
+ return (
164
+ <View style={styles.groupBadge}>
165
+ <Badge iconNameRight="general.x" label={group?.name || ''} onPress={handleBadgePress} />
166
+ </View>
167
+ )
168
+ }
169
+
170
+ function FilterButton({
171
+ title,
172
+ activeTitle,
173
+ onPress,
174
+ hidden = false,
175
+ ...restProps
176
+ }: {
177
+ title: string
178
+ activeTitle: string
179
+ onPress: () => void
180
+ hidden?: boolean
181
+ } & ButtonProps) {
182
+ if (hidden) return null
183
+
184
+ return (
185
+ <Button
186
+ title={title}
187
+ variant={activeTitle === title ? 'fill' : 'outline'}
188
+ onPress={onPress}
189
+ {...restProps}
190
+ />
191
+ )
192
+ }
193
+
194
+ const useStyles = () => {
195
+ const theme = useTheme()
196
+ return StyleSheet.create({
197
+ container: {
198
+ flex: 1,
199
+ justifyContent: 'center',
200
+ },
201
+ listHeader: {
202
+ borderBottomWidth: 1,
203
+ borderBottomColor: theme.colors.fillColorNeutral050Base,
204
+ paddingHorizontal: 16,
205
+ paddingBottom: 16,
206
+ gap: 12,
207
+ },
208
+ titleRow: {
209
+ flexDirection: 'row',
210
+ justifyContent: 'space-between',
211
+ paddingTop: 8,
212
+ },
213
+ filterRow: {
214
+ flexDirection: 'row',
215
+ justifyContent: 'flex-start',
216
+ gap: 8,
217
+ },
218
+ groupBadge: {
219
+ flexDirection: 'row',
220
+ },
221
+ })
222
+ }
@@ -4,8 +4,9 @@ import React from 'react'
4
4
  import { ScrollView, StyleSheet, View } from 'react-native'
5
5
  import { useSafeAreaInsets } from 'react-native-safe-area-context'
6
6
  import { Button, Heading, Icon, Image, Text } from '../../components'
7
- import { useSuspenseGet, useTheme } from '../../hooks'
7
+ import { useTheme } from '../../hooks'
8
8
  import { GroupsGroupResource } from '../../types'
9
+ import { useGroupsGroups } from '../../hooks/use_groups_groups'
9
10
 
10
11
  type ConversationSelectRecipientsScreenProps = StaticScreenProps<{
11
12
  chat_group_graph_id?: string
@@ -18,16 +19,7 @@ const THUMBNAIL_HEIGHT = THUMBNAIL_WIDTH / ASPECT_RATIO
18
19
  export const ConversationSelectRecipientsScreen = ({}: ConversationSelectRecipientsScreenProps) => {
19
20
  const styles = useStyles()
20
21
  const navigation = useNavigation()
21
- const { data: groups = [] } = useSuspenseGet<GroupsGroupResource[]>({
22
- url: '/me/groups',
23
- data: {
24
- perPage: 100,
25
- fields: {
26
- Group: ['can_create_conversation', 'name', 'header_image', 'memberships_count'],
27
- },
28
- },
29
- app: 'groups',
30
- })
22
+ const { data: groups = [] } = useGroupsGroups()
31
23
  const groupsWithCreatePermission = groups.filter(g => g.canCreateConversation)
32
24
 
33
25
  const handleNavigateToCreateConversation = (group: GroupsGroupResource) => {
@@ -1,10 +1,13 @@
1
1
  import { AppName } from './app_name'
2
2
 
3
+ export type SourceType = 'Team' | 'Group' | 'PlanTeam'
4
+ export type GraphId = `${AppName}-${SourceType}-${number}`
5
+
3
6
  export interface GroupResource {
7
+ id: GraphId
4
8
  type: 'Group'
5
- id: string
6
9
  links: { self: string }
7
10
  name: string | null
8
11
  sourceAppName: AppName
9
- sourceType: string
12
+ sourceType: SourceType
10
13
  }
@@ -5,3 +5,4 @@ export * from './oauth_token'
5
5
  export * from './person'
6
6
  export * from './groups'
7
7
  export * from './app_grant'
8
+ export * from './services'
@@ -0,0 +1 @@
1
+ export * from './team_resource'
@@ -0,0 +1,60 @@
1
+ // All of our calls out to services go out to /chat, which isn't a typical pco-api vertex.
2
+ // They all have a shared type of 'Chat' which has the following array attributes:
3
+ // group_identifiers, people, plans, teams and, teams_i_lead.
4
+ // All of these have a type array, are only rendered on request, and are exclusively used for this form.
5
+ // There is also a payload which is a string, and is used to create a conversation in chat.
6
+
7
+ import { ResourceObject } from '../../api_primitives'
8
+
9
+ interface ServicesChatResource extends ResourceObject {
10
+ type: 'Chat'
11
+ }
12
+
13
+ export interface TeamResource extends ServicesChatResource {
14
+ teamsILead: TeamResponseItem[]
15
+ }
16
+ export interface TeamResponseItem {
17
+ name: string
18
+ value: {
19
+ teamId: number
20
+ serviceTypeId: number
21
+ }
22
+ serviceTypeName: string
23
+ teamName: string
24
+ order: [number, string, string] // [serviceTypeId, serviceTypeName, teamName]
25
+ }
26
+
27
+ export interface TeamOptionResource extends ServicesChatResource {
28
+ teams: TeamOptionResponseItem[]
29
+ }
30
+
31
+ export interface TeamOptionResponseItem extends TeamResponseItem {
32
+ group: TeamOptionResponseItemGroupName
33
+ }
34
+
35
+ export type TeamOptionResponseItemGroupName = 'teams_i_lead' | 'other_teams'
36
+
37
+ export interface PlansResource extends ServicesChatResource {
38
+ plans: PlansResponseItem[]
39
+ }
40
+
41
+ interface PlansResponseItem {
42
+ value: number
43
+ name: string
44
+ }
45
+
46
+ export interface TeamPeopleResource extends ServicesChatResource {
47
+ people: PersonResponseItem[]
48
+ }
49
+
50
+ interface PersonResponseItem {
51
+ id: number
52
+ name: string
53
+ avatar: string
54
+ badges: { title: string }[]
55
+ child: boolean
56
+ }
57
+
58
+ export interface ServicesChatPayloadResource extends ServicesChatResource {
59
+ payload: string
60
+ }
@@ -16,6 +16,7 @@ export interface GenericRequest {
16
16
 
17
17
  export interface GetRequest extends GenericRequest {
18
18
  data: {
19
+ filter?: string
19
20
  fields: Record<string, string[]>
20
21
  where?: Record<string, string>
21
22
  include?: string[]
@@ -23,7 +24,7 @@ export interface GetRequest extends GenericRequest {
23
24
  perPage?: number
24
25
  offset?: number
25
26
  walk?: boolean
26
- }
27
+ } & Record<string, unknown>
27
28
  }
28
29
 
29
30
  export interface Relationship {
@@ -6,3 +6,4 @@ export * from './client'
6
6
  export * from './uri'
7
7
  export * from './cache'
8
8
  export * from './native_adapters'
9
+ export * from './pluralize'
@@ -0,0 +1,15 @@
1
+ interface Audio {
2
+ play: () => void
3
+ pause: () => void
4
+ isPlaying: boolean
5
+ duration: number
6
+ position: number
7
+ }
8
+
9
+ export class AudioAdapter {
10
+ useAudio: (_: string) => Audio
11
+
12
+ constructor(methods: AudioAdapter) {
13
+ this.useAudio = methods.useAudio
14
+ }
15
+ }
@@ -1,12 +1,18 @@
1
+ import { AudioAdapter } from './audio'
1
2
  import { ClipboardAdapter } from './clipboard'
3
+ import { VideoAdapter } from './video'
2
4
 
3
5
  type ChatConfigurations = {
4
6
  clipboard: ClipboardAdapter
7
+ audio: AudioAdapter
8
+ video: VideoAdapter
5
9
  }
6
10
 
7
11
  export class ChatAdapters {
8
12
  static configure(configurations: ChatConfigurations) {
9
13
  Clipboard = configurations.clipboard
14
+ Audio = configurations.audio
15
+ Video = configurations.video
10
16
  }
11
17
  }
12
18
 
@@ -22,4 +28,21 @@ let Clipboard: ClipboardAdapter = new ClipboardAdapter({
22
28
  setStringAsync: async (_: string) => methodMissing(),
23
29
  })
24
30
 
25
- export { Clipboard }
31
+ let Audio: AudioAdapter = new AudioAdapter({
32
+ useAudio: (_: string) => {
33
+ methodMissing()
34
+ return {} as any
35
+ },
36
+ })
37
+
38
+ let Video: VideoAdapter = new VideoAdapter({
39
+ Player: Object.assign(
40
+ () => {
41
+ methodMissing()
42
+ return null
43
+ },
44
+ { $$typeof: Symbol.for('react.forward_ref') }
45
+ ),
46
+ })
47
+
48
+ export { Clipboard, Audio, Video }
@@ -1,2 +1,4 @@
1
1
  export * from './clipboard'
2
2
  export * from './configuration'
3
+ export * from './audio'
4
+ export * from './video'
@@ -0,0 +1,30 @@
1
+ import { StyleProp, ViewStyle } from 'react-native'
2
+
3
+ export interface VideoPlayerProps {
4
+ source: { uri: string }
5
+ aspectRatio?: number
6
+ style?: StyleProp<ViewStyle>
7
+ onFullscreenPlayerWillPresent?: () => void
8
+ onFullscreenPlayerDidPresent?: () => void
9
+ onFullscreenPlayerWillDismiss?: () => void
10
+ onFullscreenPlayerDidDismiss?: () => void
11
+ }
12
+
13
+ export interface VideoPlayerHandle {
14
+ play: () => void
15
+ pause: () => void
16
+ presentFullscreenPlayer: () => void
17
+ dismissFullscreen: () => void
18
+ }
19
+
20
+ type VideoPlayer = React.ForwardRefExoticComponent<
21
+ VideoPlayerProps & React.RefAttributes<VideoPlayerHandle>
22
+ >
23
+
24
+ export class VideoAdapter {
25
+ Player: VideoPlayer
26
+
27
+ constructor(methods: VideoAdapter) {
28
+ this.Player = methods.Player
29
+ }
30
+ }
@@ -0,0 +1,11 @@
1
+ const irregularInflections: Record<string, string> = { person: 'people' }
2
+
3
+ export function pluralize(count: number, singularWord: string, includeCount = true) {
4
+ const plural = count !== 1
5
+ const pluralWord = irregularInflections[singularWord] || `${singularWord}s`
6
+
7
+ return [
8
+ includeCount ? `${count.toLocaleString()} ` : '',
9
+ plural ? pluralWord : singularWord,
10
+ ].join('')
11
+ }
@@ -0,0 +1,46 @@
1
+ import { GetRequest } from '../client/types'
2
+
3
+ export interface ConversationRequestArgs {
4
+ filter: string
5
+ gids: string
6
+ group: string
7
+ chat_group_graph_id?: string
8
+ group_source_app_name?: string
9
+ }
10
+
11
+ export const getConversationsRequestArgs = ({
12
+ filter,
13
+ gids,
14
+ group,
15
+ group_source_app_name,
16
+ }: Partial<ConversationRequestArgs> = {}): GetRequest => ({
17
+ url: '/me/conversations',
18
+ data: {
19
+ perPage: 20,
20
+ order: '-last_message',
21
+ filter,
22
+ group,
23
+ gids,
24
+ group_source_app_name,
25
+ fields: {
26
+ Conversation: [
27
+ 'created_at',
28
+ 'badges',
29
+ 'groups',
30
+ 'last_message_author_id',
31
+ 'last_message_author_name',
32
+ 'last_message_created_at',
33
+ 'last_message_text_preview',
34
+ 'preview_avatar_urls',
35
+ 'member_ability',
36
+ 'muted',
37
+ 'replies_disabled',
38
+ 'title',
39
+ 'unread_count',
40
+ 'updated_at',
41
+ ],
42
+ ConversationBadge: ['app_name', 'pco_resource_type', 'text'],
43
+ },
44
+ include: ['badges'],
45
+ },
46
+ })
@@ -0,0 +1,21 @@
1
+ export const getMessagesRequestArgs = ({ conversation_id }: { conversation_id: number }) => ({
2
+ url: `/me/conversations/${conversation_id}/messages`,
3
+ data: {
4
+ perPage: 25,
5
+ fields: {
6
+ Message: [
7
+ 'text',
8
+ 'text_edited_at',
9
+ 'mine',
10
+ 'attachments',
11
+ 'created_at',
12
+ 'deleted_at',
13
+ 'author',
14
+ 'reaction_counts',
15
+ ],
16
+ Person: ['name', 'avatar'],
17
+ ReactionCount: ['value', 'count', 'mine', 'message_id', 'author_ids'],
18
+ },
19
+ include: ['author', 'reaction_counts'],
20
+ },
21
+ })
@@ -27,7 +27,7 @@ export interface DefaultTheme {
27
27
  button: {
28
28
  borderRadius: number
29
29
  }
30
- showBadgeLogo: boolean
30
+ showBadgeProductLogo: boolean
31
31
  }
32
32
 
33
33
  export const defaultTheme = (colorScheme: ColorSchemeName): ChatTheme => {
@@ -43,7 +43,7 @@ export const defaultTheme = (colorScheme: ColorSchemeName): ChatTheme => {
43
43
  button: {
44
44
  borderRadius: 40,
45
45
  },
46
- showBadgeLogo: true, // Overrides visibility of the product logo in `src/display/badge.tsx`
46
+ showBadgeProductLogo: true, // Overrides visibility of the product logo in `src/display/badge.tsx`
47
47
  }
48
48
  }
49
49