@planningcenter/chat-react-native 4.5.1-rc.0 → 4.6.0-qa-1063.0

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 (166) hide show
  1. package/assets/powered_by_giphy.png +0 -0
  2. package/assets/powered_by_giphy_dark.png +0 -0
  3. package/build/components/conversation/attachments/giphy_attachment.d.ts.map +1 -1
  4. package/build/components/conversation/attachments/giphy_attachment.js +2 -2
  5. package/build/components/conversation/attachments/giphy_attachment.js.map +1 -1
  6. package/build/components/conversation/attachments/image_attachment.d.ts.map +1 -1
  7. package/build/components/conversation/attachments/image_attachment.js +5 -3
  8. package/build/components/conversation/attachments/image_attachment.js.map +1 -1
  9. package/build/components/conversation/message_form.d.ts.map +1 -1
  10. package/build/components/conversation/message_form.js +2 -2
  11. package/build/components/conversation/message_form.js.map +1 -1
  12. package/build/components/conversation/message_list.d.ts.map +1 -1
  13. package/build/components/conversation/message_list.js +155 -123
  14. package/build/components/conversation/message_list.js.map +1 -1
  15. package/build/components/conversations/conversations.d.ts.map +1 -1
  16. package/build/components/conversations/conversations.js +1 -0
  17. package/build/components/conversations/conversations.js.map +1 -1
  18. package/build/components/display/conversation_avatar.d.ts +3 -1
  19. package/build/components/display/conversation_avatar.d.ts.map +1 -1
  20. package/build/components/display/conversation_avatar.js +77 -66
  21. package/build/components/display/conversation_avatar.js.map +1 -1
  22. package/build/components/display/keyboard_scroll_view.d.ts.map +1 -1
  23. package/build/components/display/keyboard_scroll_view.js +1 -0
  24. package/build/components/display/keyboard_scroll_view.js.map +1 -1
  25. package/build/components/page/page_error_boundary.d.ts +9 -1
  26. package/build/components/page/page_error_boundary.d.ts.map +1 -1
  27. package/build/components/page/page_error_boundary.js +56 -31
  28. package/build/components/page/page_error_boundary.js.map +1 -1
  29. package/build/hooks/use_conversation_avatar_update.d.ts +4 -3
  30. package/build/hooks/use_conversation_avatar_update.d.ts.map +1 -1
  31. package/build/hooks/use_conversation_avatar_update.js +146 -48
  32. package/build/hooks/use_conversation_avatar_update.js.map +1 -1
  33. package/build/navigation/index.d.ts.map +1 -1
  34. package/build/navigation/index.js +3 -1
  35. package/build/navigation/index.js.map +1 -1
  36. package/build/navigation/page_error_fallbacks.d.ts +7 -0
  37. package/build/navigation/page_error_fallbacks.d.ts.map +1 -0
  38. package/build/navigation/page_error_fallbacks.js +7 -0
  39. package/build/navigation/page_error_fallbacks.js.map +1 -0
  40. package/build/navigation/screenLayout.d.ts.map +1 -1
  41. package/build/navigation/screenLayout.js +10 -6
  42. package/build/navigation/screenLayout.js.map +1 -1
  43. package/build/screens/age_check/age_check_required_screen.d.ts.map +1 -1
  44. package/build/screens/age_check/age_check_required_screen.js +1 -0
  45. package/build/screens/age_check/age_check_required_screen.js.map +1 -1
  46. package/build/screens/age_check/age_check_underage_screen.d.ts.map +1 -1
  47. package/build/screens/age_check/age_check_underage_screen.js +2 -1
  48. package/build/screens/age_check/age_check_underage_screen.js.map +1 -1
  49. package/build/screens/attachment_actions/attachment_actions_screen.d.ts.map +1 -1
  50. package/build/screens/attachment_actions/attachment_actions_screen.js +5 -2
  51. package/build/screens/attachment_actions/attachment_actions_screen.js.map +1 -1
  52. package/build/screens/avatar_picker/avatar_picker_screen.d.ts.map +1 -1
  53. package/build/screens/avatar_picker/avatar_picker_screen.js +76 -66
  54. package/build/screens/avatar_picker/avatar_picker_screen.js.map +1 -1
  55. package/build/screens/bug_report_screen.d.ts.map +1 -1
  56. package/build/screens/bug_report_screen.js +3 -3
  57. package/build/screens/bug_report_screen.js.map +1 -1
  58. package/build/screens/conversation_details_screen.d.ts.map +1 -1
  59. package/build/screens/conversation_details_screen.js +1 -0
  60. package/build/screens/conversation_details_screen.js.map +1 -1
  61. package/build/screens/conversation_new/components/form_list.d.ts.map +1 -1
  62. package/build/screens/conversation_new/components/form_list.js +1 -0
  63. package/build/screens/conversation_new/components/form_list.js.map +1 -1
  64. package/build/screens/conversation_new/components/groups_form.js +25 -18
  65. package/build/screens/conversation_new/components/groups_form.js.map +1 -1
  66. package/build/screens/conversation_new/components/services_form.js +51 -40
  67. package/build/screens/conversation_new/components/services_form.js.map +1 -1
  68. package/build/screens/conversation_select_recipients/conversation_new_entry_screen.d.ts.map +1 -1
  69. package/build/screens/conversation_select_recipients/conversation_new_entry_screen.js +1 -0
  70. package/build/screens/conversation_select_recipients/conversation_new_entry_screen.js.map +1 -1
  71. package/build/screens/conversation_select_recipients/conversation_select_direct_message_recipients_screen.d.ts.map +1 -1
  72. package/build/screens/conversation_select_recipients/conversation_select_direct_message_recipients_screen.js +332 -291
  73. package/build/screens/conversation_select_recipients/conversation_select_direct_message_recipients_screen.js.map +1 -1
  74. package/build/screens/conversation_select_recipients/conversation_select_group_recipients_screen.d.ts.map +1 -1
  75. package/build/screens/conversation_select_recipients/conversation_select_group_recipients_screen.js +2 -1
  76. package/build/screens/conversation_select_recipients/conversation_select_group_recipients_screen.js.map +1 -1
  77. package/build/screens/conversation_select_recipients/conversation_select_teams_i_lead_recipients_screen.d.ts.map +1 -1
  78. package/build/screens/conversation_select_recipients/conversation_select_teams_i_lead_recipients_screen.js +1 -0
  79. package/build/screens/conversation_select_recipients/conversation_select_teams_i_lead_recipients_screen.js.map +1 -1
  80. package/build/screens/get_help_screen.js +57 -63
  81. package/build/screens/get_help_screen.js.map +1 -1
  82. package/build/screens/group_notification_settings_screen.js +3 -2
  83. package/build/screens/group_notification_settings_screen.js.map +1 -1
  84. package/build/screens/notification_settings_screen.d.ts.map +1 -1
  85. package/build/screens/notification_settings_screen.js +1 -0
  86. package/build/screens/notification_settings_screen.js.map +1 -1
  87. package/build/screens/preferred_app_selection_screen.js +45 -39
  88. package/build/screens/preferred_app_selection_screen.js.map +1 -1
  89. package/build/screens/search/components/search_results_list.d.ts +4 -1
  90. package/build/screens/search/components/search_results_list.d.ts.map +1 -1
  91. package/build/screens/search/components/search_results_list.js +136 -110
  92. package/build/screens/search/components/search_results_list.js.map +1 -1
  93. package/build/screens/search/search_screen.d.ts.map +1 -1
  94. package/build/screens/search/search_screen.js +21 -28
  95. package/build/screens/search/search_screen.js.map +1 -1
  96. package/build/screens/send_giphy_screen.d.ts.map +1 -1
  97. package/build/screens/send_giphy_screen.js +93 -136
  98. package/build/screens/send_giphy_screen.js.map +1 -1
  99. package/build/screens/settings_screen.d.ts.map +1 -1
  100. package/build/screens/settings_screen.js +7 -6
  101. package/build/screens/settings_screen.js.map +1 -1
  102. package/build/utils/index.d.ts +1 -0
  103. package/build/utils/index.d.ts.map +1 -1
  104. package/build/utils/index.js +1 -0
  105. package/build/utils/index.js.map +1 -1
  106. package/build/utils/membership_sync_info_text.d.ts +2 -0
  107. package/build/utils/membership_sync_info_text.d.ts.map +1 -0
  108. package/build/utils/membership_sync_info_text.js +4 -0
  109. package/build/utils/membership_sync_info_text.js.map +1 -0
  110. package/build/utils/native_adapters/linking.d.ts +11 -3
  111. package/build/utils/native_adapters/linking.d.ts.map +1 -1
  112. package/build/utils/native_adapters/linking.js.map +1 -1
  113. package/package.json +3 -3
  114. package/src/__tests__/components/conversation/attachments/giphy_attachment.test.tsx +76 -0
  115. package/src/__tests__/screens/get_help_screen.test.ts +36 -0
  116. package/src/__utils__/render_with_query_client.tsx +13 -0
  117. package/src/components/conversation/__tests__/message_list.test.tsx +4 -0
  118. package/src/components/conversation/attachments/giphy_attachment.tsx +2 -3
  119. package/src/components/conversation/attachments/image_attachment.tsx +2 -3
  120. package/src/components/conversation/message_form.tsx +1 -1
  121. package/src/components/conversation/message_list.tsx +6 -0
  122. package/src/components/conversations/__tests__/conversation_preview.test.tsx +2 -2
  123. package/src/components/conversations/conversations.tsx +1 -0
  124. package/src/components/display/__tests__/conversation_avatar.test.tsx +94 -0
  125. package/src/components/display/conversation_avatar.tsx +9 -2
  126. package/src/components/display/keyboard_scroll_view.tsx +1 -0
  127. package/src/components/page/__tests__/page_error_boundary.test.tsx +33 -0
  128. package/src/components/page/page_error_boundary.tsx +43 -12
  129. package/src/hooks/__tests__/use_conversation_avatar_update.test.tsx +40 -0
  130. package/src/hooks/use_conversation_avatar_update.ts +67 -11
  131. package/src/navigation/index.tsx +6 -2
  132. package/src/navigation/page_error_fallbacks.ts +14 -0
  133. package/src/navigation/screenLayout.tsx +3 -1
  134. package/src/screens/age_check/age_check_required_screen.tsx +5 -1
  135. package/src/screens/age_check/age_check_underage_screen.tsx +2 -1
  136. package/src/screens/attachment_actions/__tests__/attachment_actions_screen.test.tsx +37 -1
  137. package/src/screens/attachment_actions/attachment_actions_screen.tsx +3 -2
  138. package/src/screens/avatar_picker/__tests__/avatar_picker_screen.test.tsx +67 -0
  139. package/src/screens/avatar_picker/avatar_picker_screen.tsx +7 -1
  140. package/src/screens/bug_report_screen.tsx +3 -11
  141. package/src/screens/conversation_details_screen.tsx +1 -0
  142. package/src/screens/conversation_new/components/form_list.tsx +1 -0
  143. package/src/screens/conversation_new/components/groups_form.tsx +2 -2
  144. package/src/screens/conversation_new/components/services_form.tsx +2 -2
  145. package/src/screens/conversation_select_recipients/__tests__/conversation_select_direct_message_recipients_screen.test.tsx +100 -0
  146. package/src/screens/conversation_select_recipients/conversation_new_entry_screen.tsx +4 -1
  147. package/src/screens/conversation_select_recipients/conversation_select_direct_message_recipients_screen.tsx +78 -68
  148. package/src/screens/conversation_select_recipients/conversation_select_group_recipients_screen.tsx +2 -1
  149. package/src/screens/conversation_select_recipients/conversation_select_teams_i_lead_recipients_screen.tsx +1 -0
  150. package/src/screens/get_help_screen.tsx +5 -5
  151. package/src/screens/group_notification_settings_screen.tsx +3 -3
  152. package/src/screens/notification_settings_screen.tsx +1 -0
  153. package/src/screens/preferred_app_selection_screen.tsx +4 -4
  154. package/src/screens/search/__tests__/search_screen.test.tsx +11 -12
  155. package/src/screens/search/components/__tests__/conversation_results.test.tsx +14 -5
  156. package/src/screens/search/components/__tests__/message_result_row.test.tsx +5 -4
  157. package/src/screens/search/components/__tests__/search_results_list.test.tsx +10 -5
  158. package/src/screens/search/components/search_results_list.tsx +34 -13
  159. package/src/screens/search/search_screen.tsx +8 -18
  160. package/src/screens/send_giphy_screen.tsx +13 -44
  161. package/src/screens/settings_screen.tsx +25 -25
  162. package/src/utils/__tests__/membership_sync_info_text.test.ts +15 -0
  163. package/src/utils/index.ts +1 -0
  164. package/src/utils/membership_sync_info_text.ts +3 -0
  165. package/src/utils/native_adapters/__tests__/linking.test.ts +12 -0
  166. package/src/utils/native_adapters/linking.ts +12 -3
@@ -1,11 +1,10 @@
1
1
  import { PlatformPressable } from '@react-navigation/elements'
2
2
  import { StackActions, useNavigation } from '@react-navigation/native'
3
- import { RefObject, useRef, useState } from 'react'
3
+ import { ReactElement, RefObject, useRef, useState } from 'react'
4
4
  import { FlatList, Pressable, StyleSheet, TextInput, View } from 'react-native'
5
5
  import { Avatar, Badge, Banner, Icon, KeyboardView, Spinner, Text } from '../../components'
6
6
  import { ActionButton } from '../../components/display/action_button'
7
7
  import { AutoFocusAwareTextInput } from '../../components/display/text_input'
8
- import { ComponentErrorBoundary } from '../../components/page/component_error_boundary'
9
8
  import { useTheme } from '../../hooks'
10
9
  import { useDirectMessageAffiliations } from '../../hooks/direct_messages/use_direct_message_affiliations'
11
10
  import { useDirectMessageCandidates } from '../../hooks/direct_messages/use_direct_message_candidates'
@@ -92,38 +91,31 @@ export function ConversationSelectDirectMessageRecipientsScreen({
92
91
 
93
92
  return (
94
93
  <KeyboardView>
95
- {isError && (
96
- <Banner
97
- appearance="error"
98
- description="There was an issue starting the conversation. Please try again."
99
- style={styles.errorBanner}
100
- />
101
- )}
102
- <ToField
103
- selectedPeople={selectedPeople}
104
- searchTerm={searchTerm}
105
- onSearchChange={setSearchTerm}
106
- onRemove={removePerson}
107
- onClear={() => setSelectedPeople(new Map())}
108
- searchInputRef={searchInputRef}
109
- />
110
94
  <View style={styles.candidateResultsContainer}>
111
- <ComponentErrorBoundary
112
- key={debouncedTerm}
113
- fallback={
114
- <Banner
115
- appearance="error"
116
- description="Couldn't load people right now. Try again."
117
- style={styles.errorBanner}
118
- />
95
+ <CandidateResults
96
+ term={debouncedTerm}
97
+ selectedPeople={selectedPeople}
98
+ onSelect={selectPerson}
99
+ header={
100
+ <>
101
+ {isError && (
102
+ <Banner
103
+ appearance="error"
104
+ description="There was an issue starting the conversation. Please try again."
105
+ style={styles.errorBanner}
106
+ />
107
+ )}
108
+ <ToField
109
+ selectedPeople={selectedPeople}
110
+ searchTerm={searchTerm}
111
+ onSearchChange={setSearchTerm}
112
+ onRemove={removePerson}
113
+ onClear={() => setSelectedPeople(new Map())}
114
+ searchInputRef={searchInputRef}
115
+ />
116
+ </>
119
117
  }
120
- >
121
- <CandidateResults
122
- term={debouncedTerm}
123
- selectedPeople={selectedPeople}
124
- onSelect={selectPerson}
125
- />
126
- </ComponentErrorBoundary>
118
+ />
127
119
  </View>
128
120
  <ActionButton
129
121
  title={buttonText}
@@ -214,53 +206,57 @@ function CandidateResults({
214
206
  term,
215
207
  selectedPeople,
216
208
  onSelect,
209
+ header,
217
210
  }: {
218
211
  term: string
219
212
  selectedPeople: Map<string, DirectMessageCandidateResource>
220
213
  onSelect: (candidate: DirectMessageCandidateResource) => void
214
+ header: ReactElement
221
215
  }) {
222
216
  const styles = useStyles()
223
217
  const { data, isFetching } = useDirectMessageCandidates(term)
224
218
  const { groups, teams, resultsDescription } = useDirectMessageAffiliations()
225
219
 
226
- if (term.length < 1) {
227
- if (selectedPeople.size > 0) return null
220
+ const unselectedCandidates = (data?.data ?? []).filter(c => !selectedPeople.has(c.id))
221
+ const hasTruncated = (data?.meta.totalCount ?? 0) > (data?.data.length ?? 0)
222
+ const isAtLimit = selectedPeople.size >= MAX_RECIPIENTS
223
+ const showsResults = term.length >= 1 && !isAtLimit && unselectedCandidates.length > 0
228
224
 
229
- return (
230
- <View style={styles.emptyState}>
231
- <Icon name="churchCenter.people" size={40} style={styles.emptyStateIcon} />
232
- <Text style={styles.emptyStateTitle}>Search for people to direct message</Text>
233
- <Text variant="secondary" style={styles.emptyStateSubtitle}>
234
- Start a conversation with people in your groups and teams.
235
- </Text>
236
- </View>
237
- )
238
- }
225
+ const emptyState = (() => {
226
+ if (showsResults) return null
239
227
 
240
- const isAtLimit = selectedPeople.size >= MAX_RECIPIENTS
228
+ if (term.length < 1) {
229
+ if (selectedPeople.size > 0) return null
241
230
 
242
- if (isAtLimit) {
243
- return (
244
- <View style={styles.emptyState}>
245
- <Text variant="secondary" style={styles.emptyStateSubtitle}>
246
- You can add up to {MAX_RECIPIENTS} people to a direct message.
247
- </Text>
248
- </View>
249
- )
250
- }
231
+ return (
232
+ <View style={styles.emptyState}>
233
+ <Icon name="churchCenter.people" size={40} style={styles.emptyStateIcon} />
234
+ <Text style={styles.emptyStateTitle}>Search for people to direct message</Text>
235
+ <Text variant="secondary" style={styles.emptyStateSubtitle}>
236
+ Start a conversation with people in your groups and teams.
237
+ </Text>
238
+ </View>
239
+ )
240
+ }
251
241
 
252
- const unselectedCandidates = (data?.data ?? []).filter(c => !selectedPeople.has(c.id))
253
- const hasTruncated = (data?.meta.totalCount ?? 0) > (data?.data.length ?? 0)
242
+ if (isAtLimit) {
243
+ return (
244
+ <View style={styles.emptyState}>
245
+ <Text variant="secondary" style={styles.emptyStateSubtitle}>
246
+ You can add up to {MAX_RECIPIENTS} people to a direct message.
247
+ </Text>
248
+ </View>
249
+ )
250
+ }
254
251
 
255
- if (isFetching && unselectedCandidates.length === 0) {
256
- return (
257
- <View style={styles.emptyState}>
258
- <Spinner />
259
- </View>
260
- )
261
- }
252
+ if (isFetching) {
253
+ return (
254
+ <View style={styles.emptyState}>
255
+ <Spinner />
256
+ </View>
257
+ )
258
+ }
262
259
 
263
- if (!isFetching && unselectedCandidates.length === 0) {
264
260
  return (
265
261
  <View style={styles.emptyState}>
266
262
  <Icon name="general.search" size={32} style={styles.emptyStateIcon} />
@@ -270,13 +266,15 @@ function CandidateResults({
270
266
  </Text>
271
267
  </View>
272
268
  )
273
- }
269
+ })()
274
270
 
275
271
  return (
276
272
  <CandidateList
277
- candidates={unselectedCandidates}
273
+ header={header}
274
+ candidates={showsResults ? unselectedCandidates : []}
278
275
  hasTruncated={hasTruncated}
279
276
  description={resultsDescription}
277
+ emptyState={emptyState}
280
278
  groups={groups}
281
279
  teams={teams}
282
280
  onSelect={onSelect}
@@ -309,27 +307,33 @@ function candidateAffiliationNames(
309
307
  }
310
308
 
311
309
  function CandidateList({
310
+ header,
312
311
  candidates,
313
312
  hasTruncated,
314
313
  description,
314
+ emptyState,
315
315
  groups,
316
316
  teams,
317
317
  onSelect,
318
318
  }: {
319
+ header: ReactElement
319
320
  candidates: DirectMessageCandidateResource[]
320
321
  hasTruncated: boolean
321
322
  description: string | null
323
+ emptyState: ReactElement | null
322
324
  groups: Map<number, string>
323
325
  teams: Map<number, string>
324
326
  onSelect: (candidate: DirectMessageCandidateResource) => void
325
327
  }) {
326
328
  const styles = useStyles()
329
+ const hasCandidates = candidates.length > 0
327
330
  const available = candidates.filter(c => !c.directMessagesDisabled)
328
331
  const dmDisabled = candidates.filter(c => c.directMessagesDisabled)
329
332
 
330
333
  return (
331
334
  <FlatList<DirectMessageCandidateResource>
332
335
  data={available}
336
+ contentInsetAdjustmentBehavior="automatic"
333
337
  keyboardShouldPersistTaps="handled"
334
338
  keyExtractor={item => item.id}
335
339
  renderItem={({ item }) => (
@@ -340,7 +344,13 @@ function CandidateList({
340
344
  onSelect={() => onSelect(item)}
341
345
  />
342
346
  )}
343
- ListHeaderComponent={<ResultsHeading description={description} />}
347
+ ListHeaderComponent={
348
+ <>
349
+ {header}
350
+ {hasCandidates && <ResultsHeading description={description} />}
351
+ </>
352
+ }
353
+ ListEmptyComponent={emptyState}
344
354
  ListFooterComponent={
345
355
  <>
346
356
  {dmDisabled.length > 0 && (
@@ -361,7 +371,7 @@ function CandidateList({
361
371
  ))}
362
372
  </>
363
373
  )}
364
- {hasTruncated && (
374
+ {hasCandidates && hasTruncated && (
365
375
  <View style={styles.truncatedFooter}>
366
376
  <Text variant="secondary" style={styles.truncatedText}>
367
377
  Keep typing to narrow your results.
@@ -23,7 +23,7 @@ const SECTION_CONFIG = {
23
23
  },
24
24
  [SectionKey.more]: {
25
25
  title: 'More groups',
26
- subtitle: 'You can not start a new conversation in these groups',
26
+ subtitle: "You can't start a new conversation in these groups",
27
27
  ListItemComponent: RestrictedGroupRow,
28
28
  },
29
29
  }
@@ -60,6 +60,7 @@ export const ConversationSelectGroupRecipientsScreen = ({
60
60
 
61
61
  return (
62
62
  <SectionList<GroupsGroupResource, GroupsSection>
63
+ contentInsetAdjustmentBehavior="automatic"
63
64
  sections={sections}
64
65
  keyExtractor={item => item.id.toString()}
65
66
  stickySectionHeadersEnabled={false}
@@ -32,6 +32,7 @@ export const ConversationSelectTeamsILeadRecipientsScreen = ({
32
32
 
33
33
  return (
34
34
  <FlatList
35
+ contentInsetAdjustmentBehavior="automatic"
35
36
  data={serviceTypes}
36
37
  keyExtractor={item => item.id.toString()}
37
38
  contentContainerStyle={styles.contentContainer}
@@ -1,12 +1,12 @@
1
1
  import { StaticScreenProps, useNavigation } from '@react-navigation/native'
2
2
  import { useCallback, useMemo } from 'react'
3
- import { Alert, Linking, StyleSheet, View } from 'react-native'
3
+ import { Alert, ScrollView, StyleSheet, View } from 'react-native'
4
4
  import { Heading, PressableRow, Text, TextInlineButton } from '../components'
5
5
  import { useApiGet, useTheme } from '../hooks'
6
6
  import { useAppName } from '../hooks/use_app_name'
7
7
  import { useOrganization } from '../hooks/use_organization'
8
8
  import { ResourceObject } from '../types'
9
- import { Clipboard } from '../utils'
9
+ import { Clipboard, Linking } from '../utils'
10
10
 
11
11
  type GetHelpScreenRouteProps = {
12
12
  type?: 'chat' | 'general'
@@ -56,7 +56,7 @@ export const GetHelpScreen = ({ route }: GetHelpScreenProps) => {
56
56
  }, [navigation])
57
57
 
58
58
  return (
59
- <View style={[styles.container]}>
59
+ <ScrollView contentInsetAdjustmentBehavior="automatic" contentContainerStyle={styles.container}>
60
60
  {appSpecificHelpUrls.length > 0 && (
61
61
  <Heading variant="h2" style={[styles.heading, styles.headingBottomBorder]}>
62
62
  How-to articles
@@ -90,7 +90,7 @@ export const GetHelpScreen = ({ route }: GetHelpScreenProps) => {
90
90
  to the development team.
91
91
  </Text>
92
92
  </View>
93
- </View>
93
+ </ScrollView>
94
94
  )
95
95
  }
96
96
 
@@ -145,7 +145,7 @@ const useStyles = () => {
145
145
 
146
146
  return StyleSheet.create({
147
147
  container: {
148
- flex: 1,
148
+ flexGrow: 1,
149
149
  },
150
150
  text: {
151
151
  paddingVertical: 4,
@@ -2,7 +2,7 @@ import { PlatformPressable } from '@react-navigation/elements'
2
2
  import { StaticScreenProps, useNavigation } from '@react-navigation/native'
3
3
  import type { NativeStackNavigationProp } from '@react-navigation/native-stack'
4
4
  import React, { useEffect } from 'react'
5
- import { Platform, StyleSheet, View } from 'react-native'
5
+ import { Platform, ScrollView, StyleSheet, View } from 'react-native'
6
6
  import { Heading, Icon, Text } from '../components'
7
7
  import { useTheme } from '../hooks'
8
8
  import { platformFontWeightBold } from '../utils/styles'
@@ -38,7 +38,7 @@ export function GroupNotificationSettingsScreen({ route }: GroupNotificationSett
38
38
  }
39
39
 
40
40
  return (
41
- <View style={styles.container}>
41
+ <ScrollView contentInsetAdjustmentBehavior="automatic" style={styles.container}>
42
42
  <View style={styles.sectionOuter}>
43
43
  <View style={styles.sectionInner}>
44
44
  <Heading variant="h2" style={styles.sectionHeading}>
@@ -76,7 +76,7 @@ export function GroupNotificationSettingsScreen({ route }: GroupNotificationSett
76
76
  )}
77
77
  </View>
78
78
  </PlatformPressable>
79
- </View>
79
+ </ScrollView>
80
80
  )
81
81
  }
82
82
 
@@ -123,6 +123,7 @@ export function NotificationSettingsScreen({}: NotificationSettingsScreenProps)
123
123
  return (
124
124
  <View style={styles.listContainer}>
125
125
  <FlatList
126
+ contentInsetAdjustmentBehavior="automatic"
126
127
  data={listData as SectionListData}
127
128
  contentContainerStyle={styles.contentContainer}
128
129
  renderItem={({ item, index }) => {
@@ -2,7 +2,7 @@ import { PlatformPressable } from '@react-navigation/elements'
2
2
  import { StaticScreenProps } from '@react-navigation/native'
3
3
  import { useMutation } from '@tanstack/react-query'
4
4
  import React, { type PropsWithChildren } from 'react'
5
- import { Image, StyleSheet, View, type ViewStyle } from 'react-native'
5
+ import { Image, ScrollView, StyleSheet, View, type ViewStyle } from 'react-native'
6
6
  import { Heading, Icon, Text } from '../components'
7
7
  import { useApiClient, useTheme } from '../hooks'
8
8
  import { useAppName } from '../hooks/use_app_name'
@@ -45,7 +45,7 @@ export function PreferredAppSelectionScreen({ route }: PreferredAppSelectionScre
45
45
  const sectionTitle = chatType ? chatTypeLabel(chatType.title) : undefined
46
46
 
47
47
  return (
48
- <View style={styles.container}>
48
+ <ScrollView contentInsetAdjustmentBehavior="automatic" contentContainerStyle={styles.container}>
49
49
  <View style={styles.section}>
50
50
  <Heading variant="h2" style={styles.sectionHeading}>
51
51
  {sectionTitle}
@@ -64,7 +64,7 @@ export function PreferredAppSelectionScreen({ route }: PreferredAppSelectionScre
64
64
  </PressableRow>
65
65
  ))}
66
66
  </View>
67
- </View>
67
+ </ScrollView>
68
68
  )
69
69
  }
70
70
 
@@ -118,7 +118,7 @@ const PressableRow = ({
118
118
 
119
119
  const styles = StyleSheet.create({
120
120
  container: {
121
- flex: 1,
121
+ flexGrow: 1,
122
122
  },
123
123
  section: {
124
124
  paddingTop: 24,
@@ -1,6 +1,7 @@
1
- import { act, fireEvent, render } from '@testing-library/react-native'
1
+ import { act, fireEvent } from '@testing-library/react-native'
2
2
  import React from 'react'
3
3
  import { Keyboard, ScrollView } from 'react-native'
4
+ import { renderWithQueryClient } from '../../../__utils__/render_with_query_client'
4
5
  import type { useSearchResults } from '../../../hooks/use_search_results'
5
6
  import type {
6
7
  ConversationSearchResultResource,
@@ -71,7 +72,7 @@ const renderWithResults = () => {
71
72
  hasNextPage: false,
72
73
  isFetchingNextPage: false,
73
74
  })
74
- const view = render(<SearchScreen />)
75
+ const view = renderWithQueryClient(<SearchScreen />)
75
76
  const input = view.getByLabelText(inputLabel)
76
77
  fireEvent.changeText(input, 'bud')
77
78
  fireEvent.changeText(input, 'budget')
@@ -99,37 +100,35 @@ afterEach(() => jest.useRealTimers())
99
100
 
100
101
  describe('SearchScreen', () => {
101
102
  it('searches once with the trimmed term after typing settles', () => {
102
- const view = render(<SearchScreen />)
103
+ const view = renderWithQueryClient(<SearchScreen />)
103
104
  const input = view.getByLabelText(inputLabel)
104
105
 
105
106
  fireEvent.changeText(input, 'bud')
106
107
  fireEvent.changeText(input, ' budget ')
107
108
 
108
109
  expect(view.getByText('Search chat')).toBeTruthy()
109
- expect(mockUseSearchResults).not.toHaveBeenCalled()
110
+ const searchedTerms = () =>
111
+ new Set(mockUseSearchResults.mock.calls.map(([term]) => term).filter(term => term.trim()))
112
+ expect([...searchedTerms()]).toEqual([])
110
113
 
111
114
  act(() => jest.advanceTimersByTime(200))
112
115
 
113
- const searchedTerms = new Set(mockUseSearchResults.mock.calls.map(([term]) => term))
114
- expect([...searchedTerms]).toEqual(['budget'])
116
+ expect([...searchedTerms()]).toEqual(['budget'])
115
117
  expect(view.queryByText('Search chat')).toBeNull()
116
118
  expect(view.getByLabelText('Loading results')).toBeTruthy()
117
119
  })
118
120
 
119
121
  it('lets the prompt scroll while taps still reach the field', () => {
120
- const view = render(<SearchScreen />)
122
+ const view = renderWithQueryClient(<SearchScreen />)
121
123
 
122
124
  const scrollView = view.UNSAFE_getByType(ScrollView)
123
125
  expect(scrollView.props.keyboardShouldPersistTaps).toBe('handled')
124
- expect(scrollView.props.contentContainerStyle).toMatchObject({
125
- flexGrow: 1,
126
- justifyContent: 'center',
127
- })
126
+ expect(scrollView.props.contentContainerStyle).toMatchObject({ flexGrow: 1 })
128
127
  expect(view.getByText('Search chat')).toBeTruthy()
129
128
  })
130
129
 
131
130
  it('returns to the prompt as soon as the term is cleared', () => {
132
- const view = render(<SearchScreen />)
131
+ const view = renderWithQueryClient(<SearchScreen />)
133
132
  const input = view.getByLabelText(inputLabel)
134
133
 
135
134
  fireEvent.changeText(input, 'budget')
@@ -1,5 +1,6 @@
1
- import { fireEvent, render } from '@testing-library/react-native'
1
+ import { fireEvent } from '@testing-library/react-native'
2
2
  import React from 'react'
3
+ import { renderWithQueryClient } from '../../../../__utils__/render_with_query_client'
3
4
  import type { ConversationSearchResultResource } from '../../../../types'
4
5
  import { ConversationResults } from '../conversation_results'
5
6
 
@@ -14,7 +15,9 @@ const buildResults = (count: number, prefix = 'Conversation') =>
14
15
 
15
16
  describe('ConversationResults', () => {
16
17
  it('caps at five rows until View more is pressed, then offers View less', () => {
17
- const view = render(<ConversationResults results={buildResults(6)} onSelect={jest.fn()} />)
18
+ const view = renderWithQueryClient(
19
+ <ConversationResults results={buildResults(6)} onSelect={jest.fn()} />
20
+ )
18
21
 
19
22
  expect(view.getByText('Conversation 5')).toBeTruthy()
20
23
  expect(view.queryByText('Conversation 6')).toBeNull()
@@ -27,14 +30,18 @@ describe('ConversationResults', () => {
27
30
  })
28
31
 
29
32
  it('renders no footer for five or fewer results', () => {
30
- const view = render(<ConversationResults results={buildResults(4)} onSelect={jest.fn()} />)
33
+ const view = renderWithQueryClient(
34
+ <ConversationResults results={buildResults(4)} onSelect={jest.fn()} />
35
+ )
31
36
 
32
37
  expect(view.getByText('Conversation 4')).toBeTruthy()
33
38
  expect(view.queryByText('View more')).toBeNull()
34
39
  })
35
40
 
36
41
  it('stays expanded when the parent re-renders with a new results array', () => {
37
- const view = render(<ConversationResults results={buildResults(6)} onSelect={jest.fn()} />)
42
+ const view = renderWithQueryClient(
43
+ <ConversationResults results={buildResults(6)} onSelect={jest.fn()} />
44
+ )
38
45
  fireEvent.press(view.getByText('View more'))
39
46
 
40
47
  view.rerender(<ConversationResults results={buildResults(6)} onSelect={jest.fn()} />)
@@ -46,7 +53,9 @@ describe('ConversationResults', () => {
46
53
  it('passes the pressed result and its position to onSelect', () => {
47
54
  const onSelect = jest.fn()
48
55
  const results = buildResults(2)
49
- const view = render(<ConversationResults results={results} onSelect={onSelect} />)
56
+ const view = renderWithQueryClient(
57
+ <ConversationResults results={results} onSelect={onSelect} />
58
+ )
50
59
 
51
60
  fireEvent.press(view.getByText('Conversation 2'))
52
61
 
@@ -1,5 +1,6 @@
1
- import { fireEvent, render } from '@testing-library/react-native'
1
+ import { fireEvent } from '@testing-library/react-native'
2
2
  import React from 'react'
3
+ import { renderWithQueryClient } from '../../../../__utils__/render_with_query_client'
3
4
  import type { MessageSearchResultResource } from '../../../../types/resources/search_result'
4
5
  import { formatDatePreview } from '../../../../utils/date'
5
6
  import { defaultTheme } from '../../../../utils/theme'
@@ -33,7 +34,7 @@ const interactionColor = defaultTheme('light').colors.interaction
33
34
 
34
35
  describe('MessageResultRow', () => {
35
36
  it('renders the title, author, snippet, and date', () => {
36
- const view = render(<MessageResultRow result={result} onPress={jest.fn()} />)
37
+ const view = renderWithQueryClient(<MessageResultRow result={result} onPress={jest.fn()} />)
37
38
 
38
39
  expect(view.getByText('Worship Team')).toBeTruthy()
39
40
  expect(view.getByText('Ada Lovelace:', { exact: false })).toBeTruthy()
@@ -44,7 +45,7 @@ describe('MessageResultRow', () => {
44
45
  })
45
46
 
46
47
  it('colors matched segments with the interaction color', () => {
47
- const view = render(<MessageResultRow result={result} onPress={jest.fn()} />)
48
+ const view = renderWithQueryClient(<MessageResultRow result={result} onPress={jest.fn()} />)
48
49
 
49
50
  expect(view.getByText('budget')).toHaveStyle({ color: interactionColor })
50
51
  expect(view.getByText('…planning the ')).not.toHaveStyle({ color: interactionColor })
@@ -53,7 +54,7 @@ describe('MessageResultRow', () => {
53
54
  it('exposes the row as a button with a composed label and reports presses', () => {
54
55
  const onPress = jest.fn()
55
56
  const date = formatDatePreview(result.extra.createdAt)
56
- const view = render(<MessageResultRow result={result} onPress={onPress} />)
57
+ const view = renderWithQueryClient(<MessageResultRow result={result} onPress={onPress} />)
57
58
 
58
59
  const row = view.getByRole('button', {
59
60
  name: `Worship Team, Ada Lovelace: …planning the budget meeting for next week, ${date}`,
@@ -1,6 +1,7 @@
1
- import { fireEvent, render } from '@testing-library/react-native'
1
+ import { fireEvent } from '@testing-library/react-native'
2
2
  import React from 'react'
3
3
  import { FlatList } from 'react-native'
4
+ import { renderWithQueryClient } from '../../../../__utils__/render_with_query_client'
4
5
  import type { useSearchResults } from '../../../../hooks/use_search_results'
5
6
  import type {
6
7
  ConversationSearchResultResource,
@@ -49,10 +50,14 @@ const messageResult = (id: string): MessageSearchResultResource => ({
49
50
  },
50
51
  })
51
52
 
53
+ const slots = { header: <></>, prompt: <></> }
54
+
52
55
  const renderList = (state: Partial<SearchState>, onSettled = jest.fn()) => {
53
56
  mockUseSearchResults.mockReturnValue(searchState(state))
54
- const list = () => <SearchResultsList term="potluck" onSelect={jest.fn()} onSettled={onSettled} />
55
- const view = render(list())
57
+ const list = () => (
58
+ <SearchResultsList term="potluck" onSelect={jest.fn()} onSettled={onSettled} {...slots} />
59
+ )
60
+ const view = renderWithQueryClient(list())
56
61
  const rerenderWith = (next: Partial<SearchState>) => {
57
62
  mockUseSearchResults.mockReturnValue(searchState(next))
58
63
  view.rerender(list())
@@ -129,8 +134,8 @@ describe('SearchResultsList', () => {
129
134
  const onSelect = jest.fn()
130
135
  const results = [conversationResult('1'), messageResult('1'), messageResult('2')]
131
136
  mockUseSearchResults.mockReturnValue(searchState({ results }))
132
- const view = render(
133
- <SearchResultsList term="potluck" onSelect={onSelect} onSettled={jest.fn()} />
137
+ const view = renderWithQueryClient(
138
+ <SearchResultsList term="potluck" onSelect={onSelect} onSettled={jest.fn()} {...slots} />
134
139
  )
135
140
 
136
141
  fireEvent.press(view.getByLabelText(/^Message 2/))
@@ -1,4 +1,4 @@
1
- import React, { useEffect, useRef } from 'react'
1
+ import React, { ReactElement, useEffect, useRef } from 'react'
2
2
  import { FlatList, StyleSheet, View } from 'react-native'
3
3
  import { Banner, Spinner, Text, TextButton } from '../../../components'
4
4
  import { useSearchResults } from '../../../hooks/use_search_results'
@@ -23,9 +23,17 @@ interface SearchResultsListProps {
23
23
  term: string
24
24
  onSelect: (result: SearchResultResource, position: number) => void
25
25
  onSettled: (term: string, counts: SearchResultCounts) => void
26
+ header: ReactElement
27
+ prompt: ReactElement
26
28
  }
27
29
 
28
- export function SearchResultsList({ term, onSelect, onSettled }: SearchResultsListProps) {
30
+ export function SearchResultsList({
31
+ term,
32
+ onSelect,
33
+ onSettled,
34
+ header,
35
+ prompt,
36
+ }: SearchResultsListProps) {
29
37
  const {
30
38
  results,
31
39
  failedTypes,
@@ -36,9 +44,10 @@ export function SearchResultsList({ term, onSelect, onSettled }: SearchResultsLi
36
44
  hasNextPage,
37
45
  isFetchingNextPage,
38
46
  } = useSearchResults(term)
39
- const conversationResults = results.filter(isConversationResult)
40
- const messageResults = results.filter(isMessageResult)
41
- const settled = !isPending && !isError
47
+ const searching = term.trim().length > 0
48
+ const conversationResults = searching ? results.filter(isConversationResult) : []
49
+ const messageResults = searching ? results.filter(isMessageResult) : []
50
+ const settled = searching && !isPending && !isError
42
51
 
43
52
  const settledTermRef = useRef<string | undefined>(undefined)
44
53
 
@@ -56,6 +65,7 @@ export function SearchResultsList({ term, onSelect, onSettled }: SearchResultsLi
56
65
  <FlatList
57
66
  data={messageResults}
58
67
  keyExtractor={item => item.id}
68
+ contentInsetAdjustmentBehavior="automatic"
59
69
  keyboardShouldPersistTaps="handled"
60
70
  keyboardDismissMode="on-drag"
61
71
  contentContainerStyle={styles.content}
@@ -64,20 +74,27 @@ export function SearchResultsList({ term, onSelect, onSettled }: SearchResultsLi
64
74
  )}
65
75
  ListHeaderComponent={
66
76
  <>
77
+ {header}
67
78
  {conversationResults.length > 0 && (
68
79
  <ConversationResults results={conversationResults} onSelect={onSelect} />
69
80
  )}
70
- {failedTypes.includes('conversation') && <SectionFailure type="conversation" />}
81
+ {searching && failedTypes.includes('conversation') && (
82
+ <SectionFailure type="conversation" />
83
+ )}
71
84
  {messageResults.length > 0 && <ResultsSection title="Messages" />}
72
85
  </>
73
86
  }
74
87
  ListEmptyComponent={
75
- <ListEmpty
76
- term={term}
77
- isError={isError}
78
- isPending={isPending}
79
- noResults={results.length === 0 && failedTypes.length === 0}
80
- />
88
+ searching ? (
89
+ <ListEmpty
90
+ term={term}
91
+ isError={isError}
92
+ isPending={isPending}
93
+ noResults={results.length === 0 && failedTypes.length === 0}
94
+ />
95
+ ) : (
96
+ <View style={styles.prompt}>{prompt}</View>
97
+ )
81
98
  }
82
99
  ListFooterComponent={
83
100
  <>
@@ -91,7 +108,7 @@ export function SearchResultsList({ term, onSelect, onSettled }: SearchResultsLi
91
108
  Try again
92
109
  </TextButton>
93
110
  )}
94
- {failedTypes.includes('message') && <SectionFailure type="message" />}
111
+ {searching && failedTypes.includes('message') && <SectionFailure type="message" />}
95
112
  </>
96
113
  }
97
114
  onEndReached={() => {
@@ -149,6 +166,10 @@ const styles = StyleSheet.create({
149
166
  content: {
150
167
  flexGrow: 1,
151
168
  },
169
+ prompt: {
170
+ flexGrow: 1,
171
+ justifyContent: 'center',
172
+ },
152
173
  banner: {
153
174
  margin: 16,
154
175
  },