@planningcenter/chat-react-native 4.7.1-qa-staging.5 → 4.8.0-rc.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 (61) hide show
  1. package/build/hooks/groups/use_group_chat_conversation_payload.d.ts +1 -11
  2. package/build/hooks/groups/use_group_chat_conversation_payload.d.ts.map +1 -1
  3. package/build/hooks/groups/use_group_chat_conversation_payload.js +47 -92
  4. package/build/hooks/groups/use_group_chat_conversation_payload.js.map +1 -1
  5. package/build/hooks/groups/use_group_members_for_new_conversation.d.ts +25 -27
  6. package/build/hooks/groups/use_group_members_for_new_conversation.d.ts.map +1 -1
  7. package/build/hooks/groups/use_group_members_for_new_conversation.js +110 -125
  8. package/build/hooks/groups/use_group_members_for_new_conversation.js.map +1 -1
  9. package/build/hooks/groups/use_groups_conversation_create.d.ts.map +1 -1
  10. package/build/hooks/groups/use_groups_conversation_create.js +31 -39
  11. package/build/hooks/groups/use_groups_conversation_create.js.map +1 -1
  12. package/build/hooks/use_features.d.ts +0 -1
  13. package/build/hooks/use_features.d.ts.map +1 -1
  14. package/build/hooks/use_features.js +1 -2
  15. package/build/hooks/use_features.js.map +1 -1
  16. package/build/hooks/use_groups_groups.d.ts.map +1 -1
  17. package/build/hooks/use_groups_groups.js +9 -25
  18. package/build/hooks/use_groups_groups.js.map +1 -1
  19. package/build/hooks/use_new_conversation_from_filter.d.ts.map +1 -1
  20. package/build/hooks/use_new_conversation_from_filter.js +1 -11
  21. package/build/hooks/use_new_conversation_from_filter.js.map +1 -1
  22. package/build/screens/conversation_new/components/groups_form.d.ts.map +1 -1
  23. package/build/screens/conversation_new/components/groups_form.js +93 -96
  24. package/build/screens/conversation_new/components/groups_form.js.map +1 -1
  25. package/build/screens/get_help_screen.d.ts.map +1 -1
  26. package/build/screens/get_help_screen.js +20 -4
  27. package/build/screens/get_help_screen.js.map +1 -1
  28. package/build/types/resources/groups/groups_group_resource.d.ts +1 -1
  29. package/build/types/resources/groups/groups_group_resource.d.ts.map +1 -1
  30. package/build/types/resources/groups/groups_group_resource.js.map +1 -1
  31. package/build/types/resources/groups/index.d.ts +0 -1
  32. package/build/types/resources/groups/index.d.ts.map +1 -1
  33. package/build/types/resources/groups/index.js +0 -1
  34. package/build/types/resources/groups/index.js.map +1 -1
  35. package/build/utils/native_adapters/linking.d.ts.map +1 -1
  36. package/build/utils/native_adapters/linking.js +2 -48
  37. package/build/utils/native_adapters/linking.js.map +1 -1
  38. package/package.json +3 -3
  39. package/src/__tests__/hooks/use_group_chat_conversation_payload.test.tsx +0 -31
  40. package/src/hooks/groups/use_group_chat_conversation_payload.ts +12 -30
  41. package/src/hooks/groups/use_group_members_for_new_conversation.ts +18 -49
  42. package/src/hooks/groups/use_groups_conversation_create.ts +14 -10
  43. package/src/hooks/use_features.ts +0 -1
  44. package/src/hooks/use_groups_groups.ts +16 -21
  45. package/src/hooks/use_new_conversation_from_filter.ts +5 -13
  46. package/src/screens/conversation_new/components/groups_form.tsx +9 -11
  47. package/src/screens/get_help_screen.tsx +18 -4
  48. package/src/types/resources/groups/groups_group_resource.ts +1 -1
  49. package/src/types/resources/groups/index.ts +0 -1
  50. package/src/utils/native_adapters/__tests__/linking.test.ts +4 -60
  51. package/src/utils/native_adapters/linking.ts +2 -50
  52. package/build/hooks/groups/use_groups_proxy.d.ts +0 -2
  53. package/build/hooks/groups/use_groups_proxy.d.ts.map +0 -1
  54. package/build/hooks/groups/use_groups_proxy.js +0 -18
  55. package/build/hooks/groups/use_groups_proxy.js.map +0 -1
  56. package/build/types/resources/groups/groups_membership_resource.d.ts +0 -11
  57. package/build/types/resources/groups/groups_membership_resource.d.ts.map +0 -1
  58. package/build/types/resources/groups/groups_membership_resource.js +0 -2
  59. package/build/types/resources/groups/groups_membership_resource.js.map +0 -1
  60. package/src/hooks/groups/use_groups_proxy.ts +0 -6
  61. package/src/types/resources/groups/groups_membership_resource.ts +0 -10
@@ -1,12 +1,12 @@
1
1
  import { StaticScreenProps, useNavigation } from '@react-navigation/native'
2
2
  import { useCallback, useMemo } from 'react'
3
- import { ScrollView, 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 { Linking } from '../utils'
9
+ import { Clipboard, Linking } from '../utils'
10
10
 
11
11
  type GetHelpScreenRouteProps = {
12
12
  type?: 'chat' | 'general'
@@ -117,13 +117,27 @@ const ContactRow = ({ email, phone }: { email?: string; phone?: string }) => {
117
117
  export function sendEmail(email: string) {
118
118
  if (!email) return
119
119
 
120
- Linking.openURL(encodeURI(`mailto:${email}`))
120
+ const url = encodeURI(`mailto:${email}`)
121
+
122
+ Linking.openURL(url).catch(() => {
123
+ Alert.alert('Oops', `Unable to open: ${email}`, [
124
+ { text: 'Copy to clipboard', onPress: () => Clipboard.setStringAsync(email) },
125
+ { text: 'OK' },
126
+ ])
127
+ })
121
128
  }
122
129
 
123
130
  export function placePhoneCall(phoneNumber: string) {
124
131
  if (!phoneNumber) return
125
132
 
126
- Linking.openURL(encodeURI(`tel:${phoneNumber}`))
133
+ const url = encodeURI(`tel:${phoneNumber}`)
134
+
135
+ Linking.openURL(url).catch(() => {
136
+ Alert.alert('Oops', `Unable to open: ${phoneNumber}`, [
137
+ { text: 'Copy to clipboard', onPress: () => Clipboard.setStringAsync(phoneNumber) },
138
+ { text: 'OK' },
139
+ ])
140
+ })
127
141
  }
128
142
 
129
143
  const useStyles = () => {
@@ -2,7 +2,7 @@ import { ResourceObject } from '../../api_primitives'
2
2
 
3
3
  export interface GroupsGroupResource extends ResourceObject {
4
4
  id: number
5
- type: 'Group' | 'GroupsGroup'
5
+ type: 'Group'
6
6
  headerImage: {
7
7
  thumbnail: string
8
8
  medium: string
@@ -1,2 +1 @@
1
1
  export * from './groups_group_resource'
2
- export * from './groups_membership_resource'
@@ -1,68 +1,12 @@
1
- import { Alert } from 'react-native'
2
- import { Clipboard, Log } from '../configuration'
3
1
  import { LinkingAdapter } from '../linking'
4
2
 
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
-
15
3
  describe('LinkingAdapter', () => {
16
- let setStringAsync: jest.SpyInstance
17
- let reportError: jest.SpyInstance
4
+ it('forwards open options to the host', async () => {
5
+ const openURL = jest.fn(async () => {})
6
+ const adapter = new LinkingAdapter({ openURL, canOpenURL: async () => true })
18
7
 
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 })
8
+ await adapter.openURL('https://example.com', { forceOpenInBrowser: true })
33
9
 
34
10
  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)
67
11
  })
68
12
  })
@@ -1,5 +1,4 @@
1
- import { Alert, Linking } from 'react-native'
2
- import { Clipboard, Log } from './configuration'
1
+ import { Linking } from 'react-native'
3
2
 
4
3
  export type LinkingOpenURLOptions = {
5
4
  forceOpenInBrowser?: boolean
@@ -10,59 +9,12 @@ type LinkingMethods = {
10
9
  canOpenURL: Linking['canOpenURL']
11
10
  }
12
11
 
13
- const CONTACT_SCHEME = /^(mailto|tel):/i
14
-
15
12
  export class LinkingAdapter {
16
13
  openURL: LinkingMethods['openURL']
17
14
  canOpenURL: LinkingMethods['canOpenURL']
18
15
 
19
16
  constructor(methods: LinkingMethods) {
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
- }
17
+ this.openURL = methods.openURL.bind(Linking)
29
18
  this.canOpenURL = methods.canOpenURL.bind(Linking)
30
19
  }
31
20
  }
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
- }
@@ -1,2 +0,0 @@
1
- export declare function useGroupsProxy(): boolean;
2
- //# sourceMappingURL=use_groups_proxy.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"use_groups_proxy.d.ts","sourceRoot":"","sources":["../../../src/hooks/groups/use_groups_proxy.ts"],"names":[],"mappings":"AAEA,wBAAgB,cAAc,YAG7B"}
@@ -1,18 +0,0 @@
1
- import { c as _c } from "react/compiler-runtime";
2
- import { availableFeatures, useFeatures } from '../use_features';
3
- export function useGroupsProxy() {
4
- const $ = _c(2);
5
- const {
6
- featureEnabled
7
- } = useFeatures();
8
- let t0;
9
- if ($[0] !== featureEnabled) {
10
- t0 = featureEnabled(availableFeatures.groups_proxy);
11
- $[0] = featureEnabled;
12
- $[1] = t0;
13
- } else {
14
- t0 = $[1];
15
- }
16
- return t0;
17
- }
18
- //# sourceMappingURL=use_groups_proxy.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"use_groups_proxy.js","names":["availableFeatures","useFeatures","useGroupsProxy","$","_c","featureEnabled","t0","groups_proxy"],"sources":["../../../src/hooks/groups/use_groups_proxy.ts"],"sourcesContent":["import { availableFeatures, useFeatures } from '../use_features'\n\nexport function useGroupsProxy() {\n const { featureEnabled } = useFeatures()\n return featureEnabled(availableFeatures.groups_proxy)\n}\n"],"mappings":";AAAA,SAASA,iBAAiB,EAAEC,WAAW,QAAQ,iBAAiB;AAEhE,OAAO,SAAAC,eAAA;EAAA,MAAAC,CAAA,GAAAC,EAAA;EACL;IAAAC;EAAA,IAA2BJ,WAAW,CAAC,CAAC;EAAA,IAAAK,EAAA;EAAA,IAAAH,CAAA,QAAAE,cAAA;IACjCC,EAAA,GAAAD,cAAc,CAACL,iBAAiB,CAAAO,YAAa,CAAC;IAAAJ,CAAA,MAAAE,cAAA;IAAAF,CAAA,MAAAG,EAAA;EAAA;IAAAA,EAAA,GAAAH,CAAA;EAAA;EAAA,OAA9CG,EAA8C;AAAA","ignoreList":[]}
@@ -1,11 +0,0 @@
1
- export interface GroupsMembershipResource {
2
- type: 'GroupsMembership';
3
- id: number;
4
- role?: string;
5
- firstName: string;
6
- lastName: string;
7
- avatarUrl: string;
8
- child: boolean;
9
- gender: string | null;
10
- }
11
- //# sourceMappingURL=groups_membership_resource.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"groups_membership_resource.d.ts","sourceRoot":"","sources":["../../../../src/types/resources/groups/groups_membership_resource.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,wBAAwB;IACvC,IAAI,EAAE,kBAAkB,CAAA;IACxB,EAAE,EAAE,MAAM,CAAA;IACV,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,SAAS,EAAE,MAAM,CAAA;IACjB,QAAQ,EAAE,MAAM,CAAA;IAChB,SAAS,EAAE,MAAM,CAAA;IACjB,KAAK,EAAE,OAAO,CAAA;IACd,MAAM,EAAE,MAAM,GAAG,IAAI,CAAA;CACtB"}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=groups_membership_resource.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"groups_membership_resource.js","names":[],"sources":["../../../../src/types/resources/groups/groups_membership_resource.ts"],"sourcesContent":["export interface GroupsMembershipResource {\n type: 'GroupsMembership'\n id: number\n role?: string\n firstName: string\n lastName: string\n avatarUrl: string\n child: boolean\n gender: string | null\n}\n"],"mappings":"","ignoreList":[]}
@@ -1,6 +0,0 @@
1
- import { availableFeatures, useFeatures } from '../use_features'
2
-
3
- export function useGroupsProxy() {
4
- const { featureEnabled } = useFeatures()
5
- return featureEnabled(availableFeatures.groups_proxy)
6
- }
@@ -1,10 +0,0 @@
1
- export interface GroupsMembershipResource {
2
- type: 'GroupsMembership'
3
- id: number
4
- role?: string
5
- firstName: string
6
- lastName: string
7
- avatarUrl: string
8
- child: boolean
9
- gender: string | null
10
- }