@planningcenter/chat-react-native 4.7.1-rc.0 → 4.8.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.
Files changed (184) hide show
  1. package/build/components/conversations/conversation_actions.d.ts.map +1 -1
  2. package/build/components/conversations/conversation_actions.js +333 -193
  3. package/build/components/conversations/conversation_actions.js.map +1 -1
  4. package/build/components/conversations/conversation_preview.d.ts.map +1 -1
  5. package/build/components/conversations/conversation_preview.js +106 -91
  6. package/build/components/conversations/conversation_preview.js.map +1 -1
  7. package/build/components/conversations/conversations.d.ts.map +1 -1
  8. package/build/components/conversations/conversations.js +63 -56
  9. package/build/components/conversations/conversations.js.map +1 -1
  10. package/build/components/conversations/conversations_blank_state.d.ts +2 -1
  11. package/build/components/conversations/conversations_blank_state.d.ts.map +1 -1
  12. package/build/components/conversations/conversations_blank_state.js +71 -39
  13. package/build/components/conversations/conversations_blank_state.js.map +1 -1
  14. package/build/components/conversations/hidden_indicator.d.ts +4 -0
  15. package/build/components/conversations/hidden_indicator.d.ts.map +1 -0
  16. package/build/components/conversations/hidden_indicator.js +52 -0
  17. package/build/components/conversations/hidden_indicator.js.map +1 -0
  18. package/build/components/conversations/hidden_results_footer.d.ts +2 -0
  19. package/build/components/conversations/hidden_results_footer.d.ts.map +1 -0
  20. package/build/components/conversations/hidden_results_footer.js +34 -0
  21. package/build/components/conversations/hidden_results_footer.js.map +1 -0
  22. package/build/components/display/toast.d.ts +3 -0
  23. package/build/components/display/toast.d.ts.map +1 -0
  24. package/build/components/display/toast.js +224 -0
  25. package/build/components/display/toast.js.map +1 -0
  26. package/build/components/group_conversation_list.d.ts.map +1 -1
  27. package/build/components/group_conversation_list.js +1 -0
  28. package/build/components/group_conversation_list.js.map +1 -1
  29. package/build/contexts/conversations_context.d.ts +3 -1
  30. package/build/contexts/conversations_context.d.ts.map +1 -1
  31. package/build/contexts/conversations_context.js +39 -31
  32. package/build/contexts/conversations_context.js.map +1 -1
  33. package/build/hooks/groups/use_group_members_for_new_conversation.d.ts +6 -0
  34. package/build/hooks/groups/use_group_members_for_new_conversation.d.ts.map +1 -1
  35. package/build/hooks/use_api.d.ts +6 -0
  36. package/build/hooks/use_api.d.ts.map +1 -1
  37. package/build/hooks/use_api.js +8 -5
  38. package/build/hooks/use_api.js.map +1 -1
  39. package/build/hooks/use_clear_conversation_filters.d.ts.map +1 -1
  40. package/build/hooks/use_clear_conversation_filters.js +1 -0
  41. package/build/hooks/use_clear_conversation_filters.js.map +1 -1
  42. package/build/hooks/use_conversation.d.ts.map +1 -1
  43. package/build/hooks/use_conversation.js +1 -1
  44. package/build/hooks/use_conversation.js.map +1 -1
  45. package/build/hooks/use_features.d.ts +1 -0
  46. package/build/hooks/use_features.d.ts.map +1 -1
  47. package/build/hooks/use_features.js +2 -1
  48. package/build/hooks/use_features.js.map +1 -1
  49. package/build/hooks/use_groups.d.ts +6 -0
  50. package/build/hooks/use_groups.d.ts.map +1 -1
  51. package/build/hooks/use_groups_groups.d.ts +6 -0
  52. package/build/hooks/use_groups_groups.d.ts.map +1 -1
  53. package/build/hooks/use_hidden_conversations_count.d.ts +2 -0
  54. package/build/hooks/use_hidden_conversations_count.d.ts.map +1 -0
  55. package/build/hooks/use_hidden_conversations_count.js +32 -0
  56. package/build/hooks/use_hidden_conversations_count.js.map +1 -0
  57. package/build/hooks/use_hide_conversation.d.ts +108 -0
  58. package/build/hooks/use_hide_conversation.d.ts.map +1 -0
  59. package/build/hooks/use_hide_conversation.js +243 -0
  60. package/build/hooks/use_hide_conversation.js.map +1 -0
  61. package/build/hooks/use_hide_conversations_enabled.d.ts +2 -0
  62. package/build/hooks/use_hide_conversations_enabled.d.ts.map +1 -0
  63. package/build/hooks/use_hide_conversations_enabled.js +18 -0
  64. package/build/hooks/use_hide_conversations_enabled.js.map +1 -0
  65. package/build/hooks/use_teams.d.ts +6 -0
  66. package/build/hooks/use_teams.d.ts.map +1 -1
  67. package/build/navigation/index.d.ts +5 -0
  68. package/build/navigation/index.d.ts.map +1 -1
  69. package/build/navigation/index.js +5 -0
  70. package/build/navigation/index.js.map +1 -1
  71. package/build/screens/conversation_actions_screen.d.ts +7 -0
  72. package/build/screens/conversation_actions_screen.d.ts.map +1 -0
  73. package/build/screens/conversation_actions_screen.js +89 -0
  74. package/build/screens/conversation_actions_screen.js.map +1 -0
  75. package/build/screens/conversation_details_screen.d.ts.map +1 -1
  76. package/build/screens/conversation_details_screen.js +460 -394
  77. package/build/screens/conversation_details_screen.js.map +1 -1
  78. package/build/screens/conversation_filters/components/conversation_filters.d.ts.map +1 -1
  79. package/build/screens/conversation_filters/components/conversation_filters.js +53 -12
  80. package/build/screens/conversation_filters/components/conversation_filters.js.map +1 -1
  81. package/build/screens/conversation_filters/components/rows.d.ts +6 -3
  82. package/build/screens/conversation_filters/components/rows.d.ts.map +1 -1
  83. package/build/screens/conversation_filters/components/rows.js +99 -62
  84. package/build/screens/conversation_filters/components/rows.js.map +1 -1
  85. package/build/screens/conversation_filters/context/conversation_filter_context.d.ts.map +1 -1
  86. package/build/screens/conversation_filters/context/conversation_filter_context.js +4 -0
  87. package/build/screens/conversation_filters/context/conversation_filter_context.js.map +1 -1
  88. package/build/screens/conversation_filters/filter_types.d.ts +1 -0
  89. package/build/screens/conversation_filters/filter_types.d.ts.map +1 -1
  90. package/build/screens/conversation_filters/filter_types.js +1 -0
  91. package/build/screens/conversation_filters/filter_types.js.map +1 -1
  92. package/build/screens/conversation_filters/hooks/filters.d.ts +12 -0
  93. package/build/screens/conversation_filters/hooks/filters.d.ts.map +1 -1
  94. package/build/screens/conversation_filters/screen_props.d.ts +1 -0
  95. package/build/screens/conversation_filters/screen_props.d.ts.map +1 -1
  96. package/build/screens/conversation_filters/screen_props.js.map +1 -1
  97. package/build/screens/conversations/components/filter_dropdown_list_header_component.d.ts.map +1 -1
  98. package/build/screens/conversations/components/filter_dropdown_list_header_component.js +138 -126
  99. package/build/screens/conversations/components/filter_dropdown_list_header_component.js.map +1 -1
  100. package/build/screens/conversations/components/list_header_component.d.ts.map +1 -1
  101. package/build/screens/conversations/components/list_header_component.js +95 -90
  102. package/build/screens/conversations/components/list_header_component.js.map +1 -1
  103. package/build/screens/conversations/components/search_list_header_component.d.ts.map +1 -1
  104. package/build/screens/conversations/components/search_list_header_component.js +100 -95
  105. package/build/screens/conversations/components/search_list_header_component.js.map +1 -1
  106. package/build/screens/conversations/conversations_screen.d.ts +1 -0
  107. package/build/screens/conversations/conversations_screen.d.ts.map +1 -1
  108. package/build/screens/conversations/conversations_screen.js +18 -10
  109. package/build/screens/conversations/conversations_screen.js.map +1 -1
  110. package/build/screens/get_help_screen.d.ts.map +1 -1
  111. package/build/screens/get_help_screen.js +4 -20
  112. package/build/screens/get_help_screen.js.map +1 -1
  113. package/build/screens/index.d.ts +1 -0
  114. package/build/screens/index.d.ts.map +1 -1
  115. package/build/screens/index.js +1 -0
  116. package/build/screens/index.js.map +1 -1
  117. package/build/types/resources/conversation_membership.d.ts +1 -0
  118. package/build/types/resources/conversation_membership.d.ts.map +1 -1
  119. package/build/types/resources/conversation_membership.js.map +1 -1
  120. package/build/utils/native_adapters/linking.d.ts.map +1 -1
  121. package/build/utils/native_adapters/linking.js +48 -2
  122. package/build/utils/native_adapters/linking.js.map +1 -1
  123. package/build/utils/request/conversation.d.ts +3 -1
  124. package/build/utils/request/conversation.d.ts.map +1 -1
  125. package/build/utils/request/conversation.js +4 -0
  126. package/build/utils/request/conversation.js.map +1 -1
  127. package/build/utils/toast_store.d.ts +21 -0
  128. package/build/utils/toast_store.d.ts.map +1 -0
  129. package/build/utils/toast_store.js +27 -0
  130. package/build/utils/toast_store.js.map +1 -0
  131. package/build/vendor/font_awesome_pro_solid_icons.d.ts +1 -0
  132. package/build/vendor/font_awesome_pro_solid_icons.d.ts.map +1 -1
  133. package/build/vendor/font_awesome_pro_solid_icons.js +5 -0
  134. package/build/vendor/font_awesome_pro_solid_icons.js.map +1 -1
  135. package/package.json +2 -2
  136. package/src/__tests__/screens/conversation_filters/components/conversation_filters.test.tsx +6 -0
  137. package/src/components/conversations/__tests__/conversation_actions.test.tsx +77 -2
  138. package/src/components/conversations/__tests__/conversation_preview.test.tsx +29 -0
  139. package/src/components/conversations/__tests__/conversations.test.tsx +26 -0
  140. package/src/components/conversations/__tests__/conversations_blank_state.test.tsx +17 -0
  141. package/src/components/conversations/conversation_actions.tsx +73 -4
  142. package/src/components/conversations/conversation_preview.tsx +12 -1
  143. package/src/components/conversations/conversations.tsx +9 -0
  144. package/src/components/conversations/conversations_blank_state.tsx +18 -0
  145. package/src/components/conversations/hidden_indicator.tsx +30 -0
  146. package/src/components/conversations/hidden_results_footer.tsx +25 -0
  147. package/src/components/display/__tests__/toast.test.tsx +55 -0
  148. package/src/components/display/toast.tsx +115 -0
  149. package/src/components/group_conversation_list.tsx +4 -1
  150. package/src/contexts/conversations_context.tsx +8 -1
  151. package/src/hooks/__tests__/use_hide_conversation.test.tsx +189 -0
  152. package/src/hooks/use_api.ts +2 -1
  153. package/src/hooks/use_clear_conversation_filters.ts +1 -0
  154. package/src/hooks/use_conversation.ts +1 -0
  155. package/src/hooks/use_features.ts +1 -0
  156. package/src/hooks/use_hidden_conversations_count.ts +14 -0
  157. package/src/hooks/use_hide_conversation.ts +128 -0
  158. package/src/hooks/use_hide_conversations_enabled.ts +7 -0
  159. package/src/navigation/index.tsx +8 -0
  160. package/src/screens/__tests__/conversation_actions_screen.test.tsx +79 -0
  161. package/src/screens/__tests__/conversation_details_screen.test.tsx +49 -1
  162. package/src/screens/conversation_actions_screen.tsx +53 -0
  163. package/src/screens/conversation_details_screen.tsx +19 -0
  164. package/src/screens/conversation_filters/__tests__/conversation_filters.test.tsx +42 -0
  165. package/src/screens/conversation_filters/components/conversation_filters.tsx +22 -3
  166. package/src/screens/conversation_filters/components/rows.tsx +44 -10
  167. package/src/screens/conversation_filters/context/conversation_filter_context.tsx +4 -0
  168. package/src/screens/conversation_filters/filter_types.ts +1 -0
  169. package/src/screens/conversation_filters/screen_props.ts +1 -0
  170. package/src/screens/conversations/__tests__/conversations_screen.test.tsx +1 -0
  171. package/src/screens/conversations/components/__tests__/filter_dropdown_list_header_component.test.tsx +42 -0
  172. package/src/screens/conversations/components/__tests__/list_header_component.test.tsx +1 -0
  173. package/src/screens/conversations/components/filter_dropdown_list_header_component.tsx +21 -5
  174. package/src/screens/conversations/components/list_header_component.tsx +14 -4
  175. package/src/screens/conversations/components/search_list_header_component.tsx +14 -4
  176. package/src/screens/conversations/conversations_screen.tsx +3 -0
  177. package/src/screens/get_help_screen.tsx +4 -18
  178. package/src/screens/index.ts +1 -0
  179. package/src/types/resources/conversation_membership.ts +1 -0
  180. package/src/utils/native_adapters/__tests__/linking.test.ts +60 -4
  181. package/src/utils/native_adapters/linking.ts +50 -2
  182. package/src/utils/request/conversation.ts +6 -0
  183. package/src/utils/toast_store.ts +45 -0
  184. package/src/vendor/font_awesome_pro_solid_icons.ts +12 -0
@@ -1,12 +1,68 @@
1
+ import { Alert } from 'react-native'
2
+ import { Clipboard, Log } from '../configuration'
1
3
  import { LinkingAdapter } from '../linking'
2
4
 
5
+ type AlertButton = { text?: string; onPress?: () => void }
6
+
7
+ const pressButton = (text: string) => {
8
+ const buttons = (Alert.alert as jest.Mock).mock.calls[0][2] as AlertButton[]
9
+ buttons.find(button => button.text === text)?.onPress?.()
10
+ }
11
+
12
+ const buildAdapter = (openURL: jest.Mock) =>
13
+ new LinkingAdapter({ openURL, canOpenURL: async () => true })
14
+
3
15
  describe('LinkingAdapter', () => {
4
- it('forwards open options to the host', async () => {
5
- const openURL = jest.fn(async () => {})
6
- const adapter = new LinkingAdapter({ openURL, canOpenURL: async () => true })
16
+ let setStringAsync: jest.SpyInstance
17
+ let reportError: jest.SpyInstance
7
18
 
8
- await adapter.openURL('https://example.com', { forceOpenInBrowser: true })
19
+ beforeEach(() => {
20
+ jest.spyOn(Alert, 'alert').mockImplementation(() => {})
21
+ setStringAsync = jest.spyOn(Clipboard, 'setStringAsync').mockResolvedValue()
22
+ reportError = jest.spyOn(Log, 'reportError').mockImplementation(() => {})
23
+ })
24
+
25
+ afterEach(() => {
26
+ jest.restoreAllMocks()
27
+ })
28
+
29
+ it('forwards the url and options to the host', async () => {
30
+ const openURL = jest.fn().mockResolvedValue(true)
31
+
32
+ await buildAdapter(openURL).openURL('https://example.com', { forceOpenInBrowser: true })
9
33
 
10
34
  expect(openURL).toHaveBeenCalledWith('https://example.com', { forceOpenInBrowser: true })
35
+ expect(Alert.alert).not.toHaveBeenCalled()
36
+ expect(reportError).not.toHaveBeenCalled()
37
+ })
38
+
39
+ it('reports a failed web link instead of alerting', async () => {
40
+ const error = new Error('Unable to open URL')
41
+ const openURL = jest.fn().mockRejectedValue(error)
42
+
43
+ await buildAdapter(openURL).openURL('https://youtu.be/abc')
44
+
45
+ expect(reportError).toHaveBeenCalledWith(error, { extra: { url: 'https://youtu.be/abc' } })
46
+ expect(Alert.alert).not.toHaveBeenCalled()
47
+ })
48
+
49
+ it.each([
50
+ ['mailto', 'mailto:admin@example.com', 'admin@example.com'],
51
+ ['encoded mailto', encodeURI('mailto:first last@example.com'), 'first last@example.com'],
52
+ ['tel', 'tel:+1 (555) 555-0100', '+1 (555) 555-0100'],
53
+ ])('alerts and offers to copy the bare address for a %s link', async (_name, url, address) => {
54
+ const openURL = jest.fn().mockRejectedValue(new Error('No Activity found'))
55
+
56
+ await buildAdapter(openURL).openURL(url)
57
+
58
+ expect(Alert.alert).toHaveBeenCalledWith(
59
+ 'Oops',
60
+ `Unable to open: ${address}`,
61
+ expect.arrayContaining([expect.objectContaining({ text: 'Copy to clipboard' })])
62
+ )
63
+ expect(reportError).not.toHaveBeenCalled()
64
+
65
+ pressButton('Copy to clipboard')
66
+ expect(setStringAsync).toHaveBeenCalledWith(address)
11
67
  })
12
68
  })
@@ -1,4 +1,5 @@
1
- import { Linking } from 'react-native'
1
+ import { Alert, Linking } from 'react-native'
2
+ import { Clipboard, Log } from './configuration'
2
3
 
3
4
  export type LinkingOpenURLOptions = {
4
5
  forceOpenInBrowser?: boolean
@@ -9,12 +10,59 @@ type LinkingMethods = {
9
10
  canOpenURL: Linking['canOpenURL']
10
11
  }
11
12
 
13
+ const CONTACT_SCHEME = /^(mailto|tel):/i
14
+
12
15
  export class LinkingAdapter {
13
16
  openURL: LinkingMethods['openURL']
14
17
  canOpenURL: LinkingMethods['canOpenURL']
15
18
 
16
19
  constructor(methods: LinkingMethods) {
17
- this.openURL = methods.openURL.bind(Linking)
20
+ const openURL = methods.openURL.bind(Linking)
21
+
22
+ this.openURL = async (...args) => {
23
+ try {
24
+ await openURL(...args)
25
+ } catch (error) {
26
+ handleOpenFailure(args[0], error)
27
+ }
28
+ }
18
29
  this.canOpenURL = methods.canOpenURL.bind(Linking)
19
30
  }
20
31
  }
32
+
33
+ /**
34
+ * mailto: and tel: links fail for ordinary reasons (no mail app, no phone),
35
+ * so the user gets an alert offering to copy the address. Any other failure
36
+ * is reported through the Log adapter so it stays visible as a handled error.
37
+ */
38
+ function handleOpenFailure(url: string, error: unknown) {
39
+ if (CONTACT_SCHEME.test(url)) {
40
+ alertUnableToOpen(url)
41
+ return
42
+ }
43
+
44
+ Log.reportError(toError(error, url), { extra: { url } })
45
+ }
46
+
47
+ function alertUnableToOpen(url: string) {
48
+ const address = readableAddress(url)
49
+
50
+ Alert.alert('Oops', `Unable to open: ${address}`, [
51
+ { text: 'Copy to clipboard', onPress: () => Clipboard.setStringAsync(address) },
52
+ { text: 'OK' },
53
+ ])
54
+ }
55
+
56
+ function readableAddress(url: string) {
57
+ const address = url.replace(CONTACT_SCHEME, '')
58
+
59
+ try {
60
+ return decodeURIComponent(address)
61
+ } catch {
62
+ return address
63
+ }
64
+ }
65
+
66
+ function toError(error: unknown, url: string) {
67
+ return error instanceof Error ? error : new Error(`Unable to open URL: ${url}`)
68
+ }
@@ -7,15 +7,19 @@ export interface ConversationRequestArgs {
7
7
  group_source_app_name?: string
8
8
  show_direct_messages?: boolean
9
9
  show_archived?: boolean
10
+ show_hidden?: boolean
10
11
  show_unread?: boolean
11
12
  }
12
13
 
14
+ export const HIDDEN_CONVERSATIONS_FILTER = 'mine_or_not_empty,hidden'
15
+
13
16
  export const getConversationsRequestArgs = ({
14
17
  gids,
15
18
  chat_group_graph_id,
16
19
  group_source_app_name,
17
20
  show_direct_messages,
18
21
  show_archived,
22
+ show_hidden,
19
23
  show_unread,
20
24
  }: Partial<ConversationRequestArgs> = {}): GetRequest => {
21
25
  let filter: string
@@ -23,6 +27,8 @@ export const getConversationsRequestArgs = ({
23
27
  filter = 'mine_or_not_empty,group'
24
28
  } else if (show_archived) {
25
29
  filter = 'mine_or_not_empty,archived'
30
+ } else if (show_hidden) {
31
+ filter = HIDDEN_CONVERSATIONS_FILTER
26
32
  } else if (show_unread) {
27
33
  filter = 'mine_or_not_empty,unread'
28
34
  } else if (show_direct_messages) {
@@ -0,0 +1,45 @@
1
+ export interface ToastAction {
2
+ label: string
3
+ onPress: () => void
4
+ }
5
+
6
+ export interface ToastOptions {
7
+ title: string
8
+ subtitle?: string
9
+ action?: ToastAction
10
+ }
11
+
12
+ export interface ToastState extends ToastOptions {
13
+ id: number
14
+ }
15
+
16
+ type Listener = () => void
17
+
18
+ let currentToast: ToastState | null = null
19
+ let nextId = 1
20
+ const listeners = new Set<Listener>()
21
+
22
+ const emit = () => listeners.forEach(listener => listener())
23
+
24
+ export const toastStore = {
25
+ getSnapshot: () => currentToast,
26
+ subscribe: (listener: Listener) => {
27
+ listeners.add(listener)
28
+ return () => {
29
+ listeners.delete(listener)
30
+ }
31
+ },
32
+ }
33
+
34
+ export function showToast(options: ToastOptions) {
35
+ currentToast = { ...options, id: nextId++ }
36
+ emit()
37
+ }
38
+
39
+ export function dismissToast(id?: number) {
40
+ if (!currentToast) return
41
+ if (id !== undefined && currentToast.id !== id) return
42
+
43
+ currentToast = null
44
+ emit()
45
+ }
@@ -620,3 +620,15 @@ export const faBoxArchive: IconDefinition = {
620
620
  'M0 64C0 46.3 14.3 32 32 32l448 0c17.7 0 32 14.3 32 32l0 32c0 17.7-14.3 32-32 32L32 128C14.3 128 0 113.7 0 96L0 64zM32 176l448 0 0 240c0 35.3-28.7 64-64 64L96 480c-35.3 0-64-28.7-64-64l0-240zm152 64c-13.3 0-24 10.7-24 24s10.7 24 24 24l144 0c13.3 0 24-10.7 24-24s-10.7-24-24-24l-144 0z',
621
621
  ],
622
622
  }
623
+
624
+ export const faEyeSlash: IconDefinition = {
625
+ prefix: 'fas',
626
+ iconName: 'eye-slash',
627
+ icon: [
628
+ 576,
629
+ 512,
630
+ [],
631
+ 'f070',
632
+ 'M41-24.9c-9.4-9.4-24.6-9.4-33.9 0S-2.3-.3 7 9.1l528 528c9.4 9.4 24.6 9.4 33.9 0s9.4-24.6 0-33.9l-96.4-96.4c2.7-2.4 5.4-4.8 8-7.2 46.8-43.5 78.1-95.4 93-131.1 3.3-7.9 3.3-16.7 0-24.6-14.9-35.7-46.2-87.7-93-131.1-47.1-43.7-111.8-80.6-192.6-80.6-56.8 0-105.6 18.2-146 44.2L41-24.9zM204.5 138.7c23.5-16.8 52.4-26.7 83.5-26.7 79.5 0 144 64.5 144 144 0 31.1-9.9 59.9-26.7 83.5l-34.7-34.7c12.7-21.4 17-47.7 10.1-73.7-13.7-51.2-66.4-81.6-117.6-67.9-8.6 2.3-16.7 5.7-24 10l-34.7-34.7zM325.3 395.1c-11.9 3.2-24.4 4.9-37.3 4.9-79.5 0-144-64.5-144-144 0-12.9 1.7-25.4 4.9-37.3L69.4 139.2c-32.6 36.8-55 75.8-66.9 104.5-3.3 7.9-3.3 16.7 0 24.6 14.9 35.7 46.2 87.7 93 131.1 47.1 43.7 111.8 80.6 192.6 80.6 37.3 0 71.2-7.9 101.5-20.6l-64.2-64.2z',
633
+ ],
634
+ }