@planningcenter/chat-react-native 4.7.1-qa-staging.4 → 4.7.1-qa-staging.6
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/components/conversation/attachments/expanded_link.js +8 -8
- package/build/components/conversation/attachments/expanded_link.js.map +1 -1
- package/build/components/conversation/attachments/generic_file_attachment.d.ts.map +1 -1
- package/build/components/conversation/attachments/generic_file_attachment.js +2 -2
- package/build/components/conversation/attachments/generic_file_attachment.js.map +1 -1
- package/build/components/conversation/attachments/giphy_attachment.d.ts.map +1 -1
- package/build/components/conversation/attachments/giphy_attachment.js +2 -2
- package/build/components/conversation/attachments/giphy_attachment.js.map +1 -1
- package/build/components/conversation/attachments/image_attachment.js +2 -2
- package/build/components/conversation/attachments/image_attachment.js.map +1 -1
- package/build/components/conversation/message_form.js +2 -2
- package/build/components/conversation/message_form.js.map +1 -1
- package/build/components/conversation/message_markdown.js +2 -2
- package/build/components/conversation/message_markdown.js.map +1 -1
- 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/age_check/age_check_underage_screen.js +3 -3
- package/build/screens/age_check/age_check_underage_screen.js.map +1 -1
- package/build/screens/attachment_actions/attachment_actions_screen.js +2 -2
- package/build/screens/attachment_actions/attachment_actions_screen.js.map +1 -1
- package/build/screens/bug_report_screen.js +4 -4
- package/build/screens/bug_report_screen.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.js +4 -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/index.d.ts +0 -1
- package/build/utils/index.d.ts.map +1 -1
- package/build/utils/index.js +0 -1
- package/build/utils/index.js.map +1 -1
- package/build/utils/native_adapters/linking.d.ts.map +1 -1
- package/build/utils/native_adapters/linking.js +48 -2
- package/build/utils/native_adapters/linking.js.map +1 -1
- package/package.json +3 -3
- package/src/__tests__/components/conversation/attachments/giphy_attachment.test.tsx +1 -1
- package/src/__tests__/hooks/use_group_chat_conversation_payload.test.tsx +0 -31
- package/src/__tests__/screens/get_help_screen.test.ts +1 -1
- package/src/components/conversation/attachments/expanded_link.tsx +4 -4
- package/src/components/conversation/attachments/generic_file_attachment.tsx +5 -2
- package/src/components/conversation/attachments/giphy_attachment.tsx +4 -2
- package/src/components/conversation/attachments/image_attachment.tsx +2 -2
- package/src/components/conversation/message_form.tsx +2 -2
- package/src/components/conversation/message_markdown.tsx +2 -2
- 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/age_check/age_check_underage_screen.tsx +3 -3
- package/src/screens/attachment_actions/attachment_actions_screen.tsx +2 -2
- package/src/screens/bug_report_screen.tsx +4 -4
- package/src/screens/conversation_new/components/groups_form.tsx +9 -11
- package/src/screens/get_help_screen.tsx +4 -4
- package/src/types/resources/groups/groups_group_resource.ts +1 -1
- package/src/types/resources/groups/index.ts +0 -1
- package/src/utils/index.ts +0 -1
- package/src/utils/native_adapters/__tests__/linking.test.ts +60 -4
- package/src/utils/native_adapters/linking.ts +50 -2
- 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/build/utils/open_url.d.ts +0 -11
- package/build/utils/open_url.d.ts.map +0 -1
- package/build/utils/open_url.js +0 -46
- package/build/utils/open_url.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
- package/src/utils/__tests__/open_url.test.ts +0 -67
- package/src/utils/open_url.ts +0 -47
|
@@ -4,7 +4,7 @@ import { StyleSheet, View, ScrollView } from 'react-native'
|
|
|
4
4
|
import { Heading } from '../../components'
|
|
5
5
|
import { Icon, Text, TextInlineButton } from '../../components/display'
|
|
6
6
|
import { useTheme } from '../../hooks'
|
|
7
|
-
import {
|
|
7
|
+
import { Linking } from '../../utils'
|
|
8
8
|
import type { AgeCheckParams } from './screen_props'
|
|
9
9
|
|
|
10
10
|
export interface AgeCheckUnderageScreenProps {
|
|
@@ -19,11 +19,11 @@ export function AgeCheckUnderageScreen({ contactEmail }: AgeCheckUnderageScreenP
|
|
|
19
19
|
|
|
20
20
|
const openChurchAdminHelp = () => {
|
|
21
21
|
if (!email) return
|
|
22
|
-
|
|
22
|
+
Linking.openURL(`mailto:${email}`)
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
const openTerms = () => {
|
|
26
|
-
|
|
26
|
+
Linking.openURL('https://www.planningcenter.com/terms')
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
return (
|
|
@@ -3,7 +3,7 @@ import React, { useCallback } from 'react'
|
|
|
3
3
|
import { Alert, StyleSheet } from 'react-native'
|
|
4
4
|
import FormSheet, { getFormSheetScreenOptions } from '../../components/primitive/form_sheet'
|
|
5
5
|
import { useConversation } from '../../hooks/use_conversation'
|
|
6
|
-
import {
|
|
6
|
+
import { Linking } from '../../utils'
|
|
7
7
|
import { useDeleteAttachment } from './hooks/useDeleteAttachment'
|
|
8
8
|
|
|
9
9
|
export const AttachmentActionsScreenOptions = getFormSheetScreenOptions({
|
|
@@ -60,7 +60,7 @@ export function AttachmentActionsScreen({ route }: AttachmentActionsScreenProps)
|
|
|
60
60
|
}, [attachmentName, handleDeleteAttachment, navigation])
|
|
61
61
|
|
|
62
62
|
const handleOpenInBrowser = () => {
|
|
63
|
-
|
|
63
|
+
Linking.openURL(attachmentUrl, { forceOpenInBrowser: true })
|
|
64
64
|
navigation.goBack()
|
|
65
65
|
}
|
|
66
66
|
|
|
@@ -30,7 +30,7 @@ import { useTheme } from '../hooks'
|
|
|
30
30
|
import { useAppName } from '../hooks/use_app_name'
|
|
31
31
|
import { useReportBugAction } from '../hooks/use_report_bug_action'
|
|
32
32
|
import { useUploadClient } from '../hooks/use_upload_client'
|
|
33
|
-
import { ImagePicker, ImagePickerResult,
|
|
33
|
+
import { ImagePicker, ImagePickerResult, Linking, platformFontWeightBold } from '../utils'
|
|
34
34
|
|
|
35
35
|
const MAX_DESCRIPTION_LENGTH = 2000
|
|
36
36
|
|
|
@@ -196,7 +196,7 @@ export function BugReportScreen() {
|
|
|
196
196
|
<TextInlineButton
|
|
197
197
|
accessibilityRole="link"
|
|
198
198
|
onPress={() =>
|
|
199
|
-
|
|
199
|
+
Linking.openURL('https://support.planningcenteronline.com/hc/en-us/requests/new')
|
|
200
200
|
}
|
|
201
201
|
>
|
|
202
202
|
contact our help center
|
|
@@ -342,7 +342,7 @@ export function BugReportScreen() {
|
|
|
342
342
|
<TextInlineButton
|
|
343
343
|
accessibilityRole="link"
|
|
344
344
|
variant="footnote"
|
|
345
|
-
onPress={() =>
|
|
345
|
+
onPress={() => Linking.openURL(VIDEO_RECORDING_HELP_URL)}
|
|
346
346
|
>
|
|
347
347
|
How to record your screen
|
|
348
348
|
</TextInlineButton>
|
|
@@ -355,7 +355,7 @@ export function BugReportScreen() {
|
|
|
355
355
|
<TextInlineButton
|
|
356
356
|
accessibilityRole="link"
|
|
357
357
|
variant="footnote"
|
|
358
|
-
onPress={() =>
|
|
358
|
+
onPress={() => Linking.openURL('https://www.planningcenter.com/privacy')}
|
|
359
359
|
>
|
|
360
360
|
Privacy Policy
|
|
361
361
|
</TextInlineButton>
|
|
@@ -12,7 +12,6 @@ import {
|
|
|
12
12
|
useGroupMembersForNewConversation,
|
|
13
13
|
} from '../../../hooks/groups/use_group_members_for_new_conversation'
|
|
14
14
|
import { useGroupsConversationCreate } from '../../../hooks/groups/use_groups_conversation_create'
|
|
15
|
-
import { useGroupsProxy } from '../../../hooks/groups/use_groups_proxy'
|
|
16
15
|
import {
|
|
17
16
|
type AvatarUpdatePayload,
|
|
18
17
|
patchConversationAvatar,
|
|
@@ -51,16 +50,15 @@ export const GroupsForm = ({ groupId, chat_group_graph_id, avatarSelection }: Gr
|
|
|
51
50
|
genderValue,
|
|
52
51
|
isFetching: genderFetching,
|
|
53
52
|
} = useMyGender()
|
|
54
|
-
const
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
)
|
|
53
|
+
const { data: group } = useSuspenseGet<GroupsGroupResource>({
|
|
54
|
+
url: `/me/groups/${groupId}`,
|
|
55
|
+
data: {
|
|
56
|
+
fields: {
|
|
57
|
+
Group: [],
|
|
58
|
+
},
|
|
59
|
+
},
|
|
60
|
+
app: 'groups',
|
|
61
|
+
})
|
|
64
62
|
|
|
65
63
|
const activeGenderId = genderFilterEnabled ? genderId : null
|
|
66
64
|
const activeGenderValue = genderFilterEnabled ? genderValue : null
|
|
@@ -6,7 +6,7 @@ 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 {
|
|
9
|
+
import { Linking } from '../utils'
|
|
10
10
|
|
|
11
11
|
type GetHelpScreenRouteProps = {
|
|
12
12
|
type?: 'chat' | 'general'
|
|
@@ -65,7 +65,7 @@ export const GetHelpScreen = ({ route }: GetHelpScreenProps) => {
|
|
|
65
65
|
{appSpecificHelpUrls.map(helpUrl => (
|
|
66
66
|
<PressableRow
|
|
67
67
|
key={helpUrl.id}
|
|
68
|
-
onPress={() =>
|
|
68
|
+
onPress={() => Linking.openURL(helpUrl.link)}
|
|
69
69
|
text={helpUrl.title}
|
|
70
70
|
isActive={true}
|
|
71
71
|
iconPath="general.newWindow"
|
|
@@ -117,13 +117,13 @@ const ContactRow = ({ email, phone }: { email?: string; phone?: string }) => {
|
|
|
117
117
|
export function sendEmail(email: string) {
|
|
118
118
|
if (!email) return
|
|
119
119
|
|
|
120
|
-
|
|
120
|
+
Linking.openURL(encodeURI(`mailto:${email}`))
|
|
121
121
|
}
|
|
122
122
|
|
|
123
123
|
export function placePhoneCall(phoneNumber: string) {
|
|
124
124
|
if (!phoneNumber) return
|
|
125
125
|
|
|
126
|
-
|
|
126
|
+
Linking.openURL(encodeURI(`tel:${phoneNumber}`))
|
|
127
127
|
}
|
|
128
128
|
|
|
129
129
|
const useStyles = () => {
|
package/src/utils/index.ts
CHANGED
|
@@ -10,7 +10,6 @@ export * from './host_bridge'
|
|
|
10
10
|
export * from './liquid_glass'
|
|
11
11
|
export * from './membership_sync_info_text'
|
|
12
12
|
export * from './native_adapters'
|
|
13
|
-
export * from './open_url'
|
|
14
13
|
export * from './pluralize'
|
|
15
14
|
export * from './conversation_safety_constants'
|
|
16
15
|
export * from './reaction_constants'
|
|
@@ -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
|
-
|
|
5
|
-
|
|
6
|
-
const adapter = new LinkingAdapter({ openURL, canOpenURL: async () => true })
|
|
16
|
+
let setStringAsync: jest.SpyInstance
|
|
17
|
+
let reportError: jest.SpyInstance
|
|
7
18
|
|
|
8
|
-
|
|
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
|
-
|
|
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
|
+
}
|
|
@@ -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":[]}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import type { LinkingOpenURLOptions } from './native_adapters/linking';
|
|
2
|
-
/**
|
|
3
|
-
* Opens a URL through the host's Linking adapter and never leaves the
|
|
4
|
-
* rejection unhandled.
|
|
5
|
-
*
|
|
6
|
-
* mailto: and tel: links fail for ordinary reasons (no mail app, no phone),
|
|
7
|
-
* so the user gets an alert offering to copy the address. Any other failure
|
|
8
|
-
* is reported through the Log adapter so it stays visible as a handled error.
|
|
9
|
-
*/
|
|
10
|
-
export declare function openUrl(url: string, options?: LinkingOpenURLOptions): Promise<unknown>;
|
|
11
|
-
//# sourceMappingURL=open_url.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"open_url.d.ts","sourceRoot":"","sources":["../../src/utils/open_url.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,2BAA2B,CAAA;AAItE;;;;;;;GAOG;AACH,wBAAgB,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,qBAAqB,oBASnE"}
|
package/build/utils/open_url.js
DELETED
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import { Alert } from 'react-native';
|
|
2
|
-
import { Clipboard, Linking, Log } from './native_adapters';
|
|
3
|
-
const CONTACT_SCHEME = /^(mailto|tel):/i;
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Opens a URL through the host's Linking adapter and never leaves the
|
|
7
|
-
* rejection unhandled.
|
|
8
|
-
*
|
|
9
|
-
* mailto: and tel: links fail for ordinary reasons (no mail app, no phone),
|
|
10
|
-
* so the user gets an alert offering to copy the address. Any other failure
|
|
11
|
-
* is reported through the Log adapter so it stays visible as a handled error.
|
|
12
|
-
*/
|
|
13
|
-
export function openUrl(url, options) {
|
|
14
|
-
return Linking.openURL(url, options).catch(error => {
|
|
15
|
-
if (CONTACT_SCHEME.test(url)) {
|
|
16
|
-
alertUnableToOpen(url);
|
|
17
|
-
return;
|
|
18
|
-
}
|
|
19
|
-
Log.reportError(toError(error, url), {
|
|
20
|
-
extra: {
|
|
21
|
-
url
|
|
22
|
-
}
|
|
23
|
-
});
|
|
24
|
-
});
|
|
25
|
-
}
|
|
26
|
-
function alertUnableToOpen(url) {
|
|
27
|
-
const address = readableAddress(url);
|
|
28
|
-
Alert.alert('Oops', `Unable to open: ${address}`, [{
|
|
29
|
-
text: 'Copy to clipboard',
|
|
30
|
-
onPress: () => Clipboard.setStringAsync(address)
|
|
31
|
-
}, {
|
|
32
|
-
text: 'OK'
|
|
33
|
-
}]);
|
|
34
|
-
}
|
|
35
|
-
function readableAddress(url) {
|
|
36
|
-
const address = url.replace(CONTACT_SCHEME, '');
|
|
37
|
-
try {
|
|
38
|
-
return decodeURIComponent(address);
|
|
39
|
-
} catch {
|
|
40
|
-
return address;
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
function toError(error, url) {
|
|
44
|
-
return error instanceof Error ? error : new Error(`Unable to open URL: ${url}`);
|
|
45
|
-
}
|
|
46
|
-
//# sourceMappingURL=open_url.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"open_url.js","names":["Alert","Clipboard","Linking","Log","CONTACT_SCHEME","openUrl","url","options","openURL","catch","error","test","alertUnableToOpen","reportError","toError","extra","address","readableAddress","alert","text","onPress","setStringAsync","replace","decodeURIComponent","Error"],"sources":["../../src/utils/open_url.ts"],"sourcesContent":["import { Alert } from 'react-native'\nimport { Clipboard, Linking, Log } from './native_adapters'\nimport type { LinkingOpenURLOptions } from './native_adapters/linking'\n\nconst CONTACT_SCHEME = /^(mailto|tel):/i\n\n/**\n * Opens a URL through the host's Linking adapter and never leaves the\n * rejection unhandled.\n *\n * mailto: and tel: links fail for ordinary reasons (no mail app, no phone),\n * so the user gets an alert offering to copy the address. Any other failure\n * is reported through the Log adapter so it stays visible as a handled error.\n */\nexport function openUrl(url: string, options?: LinkingOpenURLOptions) {\n return Linking.openURL(url, options).catch((error: unknown) => {\n if (CONTACT_SCHEME.test(url)) {\n alertUnableToOpen(url)\n return\n }\n\n Log.reportError(toError(error, url), { extra: { url } })\n })\n}\n\nfunction alertUnableToOpen(url: string) {\n const address = readableAddress(url)\n\n Alert.alert('Oops', `Unable to open: ${address}`, [\n { text: 'Copy to clipboard', onPress: () => Clipboard.setStringAsync(address) },\n { text: 'OK' },\n ])\n}\n\nfunction readableAddress(url: string) {\n const address = url.replace(CONTACT_SCHEME, '')\n\n try {\n return decodeURIComponent(address)\n } catch {\n return address\n }\n}\n\nfunction toError(error: unknown, url: string) {\n return error instanceof Error ? error : new Error(`Unable to open URL: ${url}`)\n}\n"],"mappings":"AAAA,SAASA,KAAK,QAAQ,cAAc;AACpC,SAASC,SAAS,EAAEC,OAAO,EAAEC,GAAG,QAAQ,mBAAmB;AAG3D,MAAMC,cAAc,GAAG,iBAAiB;;AAExC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,OAAOA,CAACC,GAAW,EAAEC,OAA+B,EAAE;EACpE,OAAOL,OAAO,CAACM,OAAO,CAACF,GAAG,EAAEC,OAAO,CAAC,CAACE,KAAK,CAAEC,KAAc,IAAK;IAC7D,IAAIN,cAAc,CAACO,IAAI,CAACL,GAAG,CAAC,EAAE;MAC5BM,iBAAiB,CAACN,GAAG,CAAC;MACtB;IACF;IAEAH,GAAG,CAACU,WAAW,CAACC,OAAO,CAACJ,KAAK,EAAEJ,GAAG,CAAC,EAAE;MAAES,KAAK,EAAE;QAAET;MAAI;IAAE,CAAC,CAAC;EAC1D,CAAC,CAAC;AACJ;AAEA,SAASM,iBAAiBA,CAACN,GAAW,EAAE;EACtC,MAAMU,OAAO,GAAGC,eAAe,CAACX,GAAG,CAAC;EAEpCN,KAAK,CAACkB,KAAK,CAAC,MAAM,EAAE,mBAAmBF,OAAO,EAAE,EAAE,CAChD;IAAEG,IAAI,EAAE,mBAAmB;IAAEC,OAAO,EAAEA,CAAA,KAAMnB,SAAS,CAACoB,cAAc,CAACL,OAAO;EAAE,CAAC,EAC/E;IAAEG,IAAI,EAAE;EAAK,CAAC,CACf,CAAC;AACJ;AAEA,SAASF,eAAeA,CAACX,GAAW,EAAE;EACpC,MAAMU,OAAO,GAAGV,GAAG,CAACgB,OAAO,CAAClB,cAAc,EAAE,EAAE,CAAC;EAE/C,IAAI;IACF,OAAOmB,kBAAkB,CAACP,OAAO,CAAC;EACpC,CAAC,CAAC,MAAM;IACN,OAAOA,OAAO;EAChB;AACF;AAEA,SAASF,OAAOA,CAACJ,KAAc,EAAEJ,GAAW,EAAE;EAC5C,OAAOI,KAAK,YAAYc,KAAK,GAAGd,KAAK,GAAG,IAAIc,KAAK,CAAC,uBAAuBlB,GAAG,EAAE,CAAC;AACjF","ignoreList":[]}
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
import { Alert } from 'react-native'
|
|
2
|
-
import { Clipboard, Linking, Log } from '../native_adapters'
|
|
3
|
-
import { openUrl } from '../open_url'
|
|
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
|
-
describe('openUrl', () => {
|
|
13
|
-
let openURL: jest.SpyInstance
|
|
14
|
-
let setStringAsync: jest.SpyInstance
|
|
15
|
-
let reportError: jest.SpyInstance
|
|
16
|
-
|
|
17
|
-
beforeEach(() => {
|
|
18
|
-
jest.spyOn(Alert, 'alert').mockImplementation(() => {})
|
|
19
|
-
openURL = jest.spyOn(Linking, 'openURL')
|
|
20
|
-
setStringAsync = jest.spyOn(Clipboard, 'setStringAsync').mockResolvedValue()
|
|
21
|
-
reportError = jest.spyOn(Log, 'reportError').mockImplementation(() => {})
|
|
22
|
-
})
|
|
23
|
-
|
|
24
|
-
afterEach(() => {
|
|
25
|
-
jest.restoreAllMocks()
|
|
26
|
-
})
|
|
27
|
-
|
|
28
|
-
it('passes the url and options through to the Linking adapter', async () => {
|
|
29
|
-
openURL.mockResolvedValue(true)
|
|
30
|
-
|
|
31
|
-
await openUrl('https://youtu.be/abc', { forceOpenInBrowser: true })
|
|
32
|
-
|
|
33
|
-
expect(openURL).toHaveBeenCalledWith('https://youtu.be/abc', { forceOpenInBrowser: true })
|
|
34
|
-
expect(Alert.alert).not.toHaveBeenCalled()
|
|
35
|
-
expect(reportError).not.toHaveBeenCalled()
|
|
36
|
-
})
|
|
37
|
-
|
|
38
|
-
it('reports a failed web link instead of alerting', async () => {
|
|
39
|
-
const error = new Error('Unable to open URL')
|
|
40
|
-
openURL.mockRejectedValue(error)
|
|
41
|
-
|
|
42
|
-
await openUrl('https://youtu.be/abc')
|
|
43
|
-
|
|
44
|
-
expect(reportError).toHaveBeenCalledWith(error, { extra: { url: 'https://youtu.be/abc' } })
|
|
45
|
-
expect(Alert.alert).not.toHaveBeenCalled()
|
|
46
|
-
})
|
|
47
|
-
|
|
48
|
-
it.each([
|
|
49
|
-
['mailto', 'mailto:admin@example.com', 'admin@example.com'],
|
|
50
|
-
['encoded mailto', encodeURI('mailto:first last@example.com'), 'first last@example.com'],
|
|
51
|
-
['tel', 'tel:+1 (555) 555-0100', '+1 (555) 555-0100'],
|
|
52
|
-
])('alerts and offers to copy the bare address for a %s link', async (_name, url, address) => {
|
|
53
|
-
openURL.mockRejectedValue(new Error('No Activity found'))
|
|
54
|
-
|
|
55
|
-
await openUrl(url)
|
|
56
|
-
|
|
57
|
-
expect(Alert.alert).toHaveBeenCalledWith(
|
|
58
|
-
'Oops',
|
|
59
|
-
`Unable to open: ${address}`,
|
|
60
|
-
expect.arrayContaining([expect.objectContaining({ text: 'Copy to clipboard' })])
|
|
61
|
-
)
|
|
62
|
-
expect(reportError).not.toHaveBeenCalled()
|
|
63
|
-
|
|
64
|
-
pressButton('Copy to clipboard')
|
|
65
|
-
expect(setStringAsync).toHaveBeenCalledWith(address)
|
|
66
|
-
})
|
|
67
|
-
})
|
package/src/utils/open_url.ts
DELETED
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import { Alert } from 'react-native'
|
|
2
|
-
import { Clipboard, Linking, Log } from './native_adapters'
|
|
3
|
-
import type { LinkingOpenURLOptions } from './native_adapters/linking'
|
|
4
|
-
|
|
5
|
-
const CONTACT_SCHEME = /^(mailto|tel):/i
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Opens a URL through the host's Linking adapter and never leaves the
|
|
9
|
-
* rejection unhandled.
|
|
10
|
-
*
|
|
11
|
-
* mailto: and tel: links fail for ordinary reasons (no mail app, no phone),
|
|
12
|
-
* so the user gets an alert offering to copy the address. Any other failure
|
|
13
|
-
* is reported through the Log adapter so it stays visible as a handled error.
|
|
14
|
-
*/
|
|
15
|
-
export function openUrl(url: string, options?: LinkingOpenURLOptions) {
|
|
16
|
-
return Linking.openURL(url, options).catch((error: unknown) => {
|
|
17
|
-
if (CONTACT_SCHEME.test(url)) {
|
|
18
|
-
alertUnableToOpen(url)
|
|
19
|
-
return
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
Log.reportError(toError(error, url), { extra: { url } })
|
|
23
|
-
})
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
function alertUnableToOpen(url: string) {
|
|
27
|
-
const address = readableAddress(url)
|
|
28
|
-
|
|
29
|
-
Alert.alert('Oops', `Unable to open: ${address}`, [
|
|
30
|
-
{ text: 'Copy to clipboard', onPress: () => Clipboard.setStringAsync(address) },
|
|
31
|
-
{ text: 'OK' },
|
|
32
|
-
])
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
function readableAddress(url: string) {
|
|
36
|
-
const address = url.replace(CONTACT_SCHEME, '')
|
|
37
|
-
|
|
38
|
-
try {
|
|
39
|
-
return decodeURIComponent(address)
|
|
40
|
-
} catch {
|
|
41
|
-
return address
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
function toError(error: unknown, url: string) {
|
|
46
|
-
return error instanceof Error ? error : new Error(`Unable to open URL: ${url}`)
|
|
47
|
-
}
|