@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.
- package/build/hooks/groups/use_group_chat_conversation_payload.d.ts +1 -11
- package/build/hooks/groups/use_group_chat_conversation_payload.d.ts.map +1 -1
- package/build/hooks/groups/use_group_chat_conversation_payload.js +47 -92
- package/build/hooks/groups/use_group_chat_conversation_payload.js.map +1 -1
- package/build/hooks/groups/use_group_members_for_new_conversation.d.ts +25 -27
- package/build/hooks/groups/use_group_members_for_new_conversation.d.ts.map +1 -1
- package/build/hooks/groups/use_group_members_for_new_conversation.js +110 -125
- package/build/hooks/groups/use_group_members_for_new_conversation.js.map +1 -1
- package/build/hooks/groups/use_groups_conversation_create.d.ts.map +1 -1
- package/build/hooks/groups/use_groups_conversation_create.js +31 -39
- package/build/hooks/groups/use_groups_conversation_create.js.map +1 -1
- package/build/hooks/use_features.d.ts +0 -1
- package/build/hooks/use_features.d.ts.map +1 -1
- package/build/hooks/use_features.js +1 -2
- package/build/hooks/use_features.js.map +1 -1
- package/build/hooks/use_groups_groups.d.ts.map +1 -1
- package/build/hooks/use_groups_groups.js +9 -25
- package/build/hooks/use_groups_groups.js.map +1 -1
- package/build/hooks/use_new_conversation_from_filter.d.ts.map +1 -1
- package/build/hooks/use_new_conversation_from_filter.js +1 -11
- package/build/hooks/use_new_conversation_from_filter.js.map +1 -1
- package/build/screens/conversation_new/components/groups_form.d.ts.map +1 -1
- package/build/screens/conversation_new/components/groups_form.js +93 -96
- package/build/screens/conversation_new/components/groups_form.js.map +1 -1
- package/build/screens/get_help_screen.d.ts.map +1 -1
- package/build/screens/get_help_screen.js +20 -4
- package/build/screens/get_help_screen.js.map +1 -1
- package/build/types/resources/groups/groups_group_resource.d.ts +1 -1
- package/build/types/resources/groups/groups_group_resource.d.ts.map +1 -1
- package/build/types/resources/groups/groups_group_resource.js.map +1 -1
- package/build/types/resources/groups/index.d.ts +0 -1
- package/build/types/resources/groups/index.d.ts.map +1 -1
- package/build/types/resources/groups/index.js +0 -1
- package/build/types/resources/groups/index.js.map +1 -1
- package/build/utils/native_adapters/linking.d.ts.map +1 -1
- package/build/utils/native_adapters/linking.js +2 -48
- package/build/utils/native_adapters/linking.js.map +1 -1
- package/package.json +3 -3
- package/src/__tests__/hooks/use_group_chat_conversation_payload.test.tsx +0 -31
- package/src/hooks/groups/use_group_chat_conversation_payload.ts +12 -30
- package/src/hooks/groups/use_group_members_for_new_conversation.ts +18 -49
- package/src/hooks/groups/use_groups_conversation_create.ts +14 -10
- package/src/hooks/use_features.ts +0 -1
- package/src/hooks/use_groups_groups.ts +16 -21
- package/src/hooks/use_new_conversation_from_filter.ts +5 -13
- package/src/screens/conversation_new/components/groups_form.tsx +9 -11
- package/src/screens/get_help_screen.tsx +18 -4
- package/src/types/resources/groups/groups_group_resource.ts +1 -1
- package/src/types/resources/groups/index.ts +0 -1
- package/src/utils/native_adapters/__tests__/linking.test.ts +4 -60
- package/src/utils/native_adapters/linking.ts +2 -50
- package/build/hooks/groups/use_groups_proxy.d.ts +0 -2
- package/build/hooks/groups/use_groups_proxy.d.ts.map +0 -1
- package/build/hooks/groups/use_groups_proxy.js +0 -18
- package/build/hooks/groups/use_groups_proxy.js.map +0 -1
- package/build/types/resources/groups/groups_membership_resource.d.ts +0 -11
- package/build/types/resources/groups/groups_membership_resource.d.ts.map +0 -1
- package/build/types/resources/groups/groups_membership_resource.js +0 -2
- package/build/types/resources/groups/groups_membership_resource.js.map +0 -1
- package/src/hooks/groups/use_groups_proxy.ts +0 -6
- 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
|
-
|
|
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
|
-
|
|
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 = () => {
|
|
@@ -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
|
-
|
|
17
|
-
|
|
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
|
-
|
|
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 {
|
|
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
|
-
|
|
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 +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 +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":[]}
|