@planningcenter/chat-react-native 4.7.1-qa-staging.3 → 4.7.1-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/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/components/conversations/conversation_actions.d.ts.map +1 -1
- package/build/components/conversations/conversation_actions.js +193 -333
- package/build/components/conversations/conversation_actions.js.map +1 -1
- package/build/components/conversations/conversation_preview.d.ts.map +1 -1
- package/build/components/conversations/conversation_preview.js +91 -106
- package/build/components/conversations/conversation_preview.js.map +1 -1
- package/build/components/conversations/conversations.d.ts.map +1 -1
- package/build/components/conversations/conversations.js +56 -63
- package/build/components/conversations/conversations.js.map +1 -1
- package/build/components/conversations/conversations_blank_state.d.ts +1 -2
- package/build/components/conversations/conversations_blank_state.d.ts.map +1 -1
- package/build/components/conversations/conversations_blank_state.js +39 -71
- package/build/components/conversations/conversations_blank_state.js.map +1 -1
- package/build/components/group_conversation_list.d.ts.map +1 -1
- package/build/components/group_conversation_list.js +0 -1
- package/build/components/group_conversation_list.js.map +1 -1
- package/build/contexts/conversations_context.d.ts +1 -3
- package/build/contexts/conversations_context.d.ts.map +1 -1
- package/build/contexts/conversations_context.js +31 -39
- package/build/contexts/conversations_context.js.map +1 -1
- package/build/hooks/groups/use_group_members_for_new_conversation.d.ts +0 -6
- package/build/hooks/groups/use_group_members_for_new_conversation.d.ts.map +1 -1
- package/build/hooks/use_api.d.ts +0 -6
- package/build/hooks/use_api.d.ts.map +1 -1
- package/build/hooks/use_api.js +5 -8
- package/build/hooks/use_api.js.map +1 -1
- package/build/hooks/use_clear_conversation_filters.d.ts.map +1 -1
- package/build/hooks/use_clear_conversation_filters.js +0 -1
- package/build/hooks/use_clear_conversation_filters.js.map +1 -1
- package/build/hooks/use_conversation.d.ts.map +1 -1
- package/build/hooks/use_conversation.js +1 -1
- package/build/hooks/use_conversation.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.d.ts +0 -6
- package/build/hooks/use_groups.d.ts.map +1 -1
- package/build/hooks/use_groups_groups.d.ts +0 -6
- package/build/hooks/use_groups_groups.d.ts.map +1 -1
- package/build/hooks/use_live_relative_time.js +6 -5
- package/build/hooks/use_live_relative_time.js.map +1 -1
- package/build/hooks/use_teams.d.ts +0 -6
- package/build/hooks/use_teams.d.ts.map +1 -1
- package/build/navigation/index.d.ts +0 -5
- package/build/navigation/index.d.ts.map +1 -1
- package/build/navigation/index.js +0 -5
- package/build/navigation/index.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_details_screen.d.ts.map +1 -1
- package/build/screens/conversation_details_screen.js +394 -460
- package/build/screens/conversation_details_screen.js.map +1 -1
- package/build/screens/conversation_filters/components/conversation_filters.d.ts.map +1 -1
- package/build/screens/conversation_filters/components/conversation_filters.js +12 -53
- package/build/screens/conversation_filters/components/conversation_filters.js.map +1 -1
- package/build/screens/conversation_filters/components/rows.d.ts +3 -6
- package/build/screens/conversation_filters/components/rows.d.ts.map +1 -1
- package/build/screens/conversation_filters/components/rows.js +62 -99
- package/build/screens/conversation_filters/components/rows.js.map +1 -1
- package/build/screens/conversation_filters/context/conversation_filter_context.d.ts.map +1 -1
- package/build/screens/conversation_filters/context/conversation_filter_context.js +0 -4
- package/build/screens/conversation_filters/context/conversation_filter_context.js.map +1 -1
- package/build/screens/conversation_filters/filter_types.d.ts +0 -1
- package/build/screens/conversation_filters/filter_types.d.ts.map +1 -1
- package/build/screens/conversation_filters/filter_types.js +0 -1
- package/build/screens/conversation_filters/filter_types.js.map +1 -1
- package/build/screens/conversation_filters/hooks/filters.d.ts +0 -12
- package/build/screens/conversation_filters/hooks/filters.d.ts.map +1 -1
- package/build/screens/conversation_filters/screen_props.d.ts +0 -1
- package/build/screens/conversation_filters/screen_props.d.ts.map +1 -1
- package/build/screens/conversation_filters/screen_props.js.map +1 -1
- package/build/screens/conversations/components/filter_dropdown_list_header_component.d.ts.map +1 -1
- package/build/screens/conversations/components/filter_dropdown_list_header_component.js +126 -138
- package/build/screens/conversations/components/filter_dropdown_list_header_component.js.map +1 -1
- package/build/screens/conversations/components/list_header_component.d.ts.map +1 -1
- package/build/screens/conversations/components/list_header_component.js +90 -95
- package/build/screens/conversations/components/list_header_component.js.map +1 -1
- package/build/screens/conversations/components/search_list_header_component.d.ts.map +1 -1
- package/build/screens/conversations/components/search_list_header_component.js +95 -100
- package/build/screens/conversations/components/search_list_header_component.js.map +1 -1
- package/build/screens/conversations/conversations_screen.d.ts +0 -1
- package/build/screens/conversations/conversations_screen.d.ts.map +1 -1
- package/build/screens/conversations/conversations_screen.js +10 -18
- package/build/screens/conversations/conversations_screen.js.map +1 -1
- package/build/screens/get_help_screen.d.ts.map +1 -1
- package/build/screens/get_help_screen.js +21 -5
- package/build/screens/get_help_screen.js.map +1 -1
- package/build/screens/index.d.ts +0 -1
- package/build/screens/index.d.ts.map +1 -1
- package/build/screens/index.js +0 -1
- package/build/screens/index.js.map +1 -1
- package/build/types/resources/conversation_membership.d.ts +0 -1
- package/build/types/resources/conversation_membership.d.ts.map +1 -1
- package/build/types/resources/conversation_membership.js.map +1 -1
- package/build/utils/date.d.ts +1 -1
- package/build/utils/date.d.ts.map +1 -1
- package/build/utils/date.js +4 -4
- package/build/utils/date.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/request/conversation.d.ts +1 -3
- package/build/utils/request/conversation.d.ts.map +1 -1
- package/build/utils/request/conversation.js +0 -4
- package/build/utils/request/conversation.js.map +1 -1
- package/build/vendor/font_awesome_pro_solid_icons.d.ts +0 -1
- package/build/vendor/font_awesome_pro_solid_icons.d.ts.map +1 -1
- package/build/vendor/font_awesome_pro_solid_icons.js +0 -5
- package/build/vendor/font_awesome_pro_solid_icons.js.map +1 -1
- package/package.json +3 -3
- package/src/__tests__/components/conversation/attachments/giphy_attachment.test.tsx +1 -1
- package/src/__tests__/screens/conversation_filters/components/conversation_filters.test.tsx +0 -6
- 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/components/conversations/__tests__/conversation_actions.test.tsx +2 -77
- package/src/components/conversations/__tests__/conversation_preview.test.tsx +0 -29
- package/src/components/conversations/__tests__/conversations.test.tsx +0 -26
- package/src/components/conversations/__tests__/conversations_blank_state.test.tsx +0 -17
- package/src/components/conversations/conversation_actions.tsx +4 -73
- package/src/components/conversations/conversation_preview.tsx +1 -12
- package/src/components/conversations/conversations.tsx +0 -9
- package/src/components/conversations/conversations_blank_state.tsx +0 -18
- package/src/components/group_conversation_list.tsx +1 -4
- package/src/contexts/conversations_context.tsx +1 -8
- package/src/hooks/__tests__/use_live_relative_time.test.tsx +22 -0
- package/src/hooks/use_api.ts +1 -2
- package/src/hooks/use_clear_conversation_filters.ts +0 -1
- package/src/hooks/use_conversation.ts +0 -1
- package/src/hooks/use_features.ts +0 -1
- package/src/hooks/use_live_relative_time.ts +1 -1
- package/src/navigation/index.tsx +0 -8
- package/src/screens/__tests__/conversation_details_screen.test.tsx +1 -49
- 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_details_screen.tsx +0 -19
- package/src/screens/conversation_filters/__tests__/conversation_filters.test.tsx +0 -42
- package/src/screens/conversation_filters/components/conversation_filters.tsx +3 -22
- package/src/screens/conversation_filters/components/rows.tsx +10 -44
- package/src/screens/conversation_filters/context/conversation_filter_context.tsx +0 -4
- package/src/screens/conversation_filters/filter_types.ts +0 -1
- package/src/screens/conversation_filters/screen_props.ts +0 -1
- package/src/screens/conversations/__tests__/conversations_screen.test.tsx +0 -1
- package/src/screens/conversations/components/__tests__/filter_dropdown_list_header_component.test.tsx +0 -42
- package/src/screens/conversations/components/__tests__/list_header_component.test.tsx +0 -1
- package/src/screens/conversations/components/filter_dropdown_list_header_component.tsx +5 -21
- package/src/screens/conversations/components/list_header_component.tsx +4 -14
- package/src/screens/conversations/components/search_list_header_component.tsx +4 -14
- package/src/screens/conversations/conversations_screen.tsx +0 -3
- package/src/screens/get_help_screen.tsx +19 -5
- package/src/screens/index.ts +0 -1
- package/src/types/resources/conversation_membership.ts +0 -1
- package/src/utils/__tests__/date.test.ts +10 -1
- package/src/utils/date.ts +4 -4
- package/src/utils/index.ts +0 -1
- package/src/utils/request/conversation.ts +0 -6
- package/src/vendor/font_awesome_pro_solid_icons.ts +0 -12
- package/build/components/conversations/hidden_indicator.d.ts +0 -4
- package/build/components/conversations/hidden_indicator.d.ts.map +0 -1
- package/build/components/conversations/hidden_indicator.js +0 -52
- package/build/components/conversations/hidden_indicator.js.map +0 -1
- package/build/components/conversations/hidden_results_footer.d.ts +0 -2
- package/build/components/conversations/hidden_results_footer.d.ts.map +0 -1
- package/build/components/conversations/hidden_results_footer.js +0 -34
- package/build/components/conversations/hidden_results_footer.js.map +0 -1
- package/build/components/display/toast.d.ts +0 -3
- package/build/components/display/toast.d.ts.map +0 -1
- package/build/components/display/toast.js +0 -224
- package/build/components/display/toast.js.map +0 -1
- package/build/hooks/use_hidden_conversations_count.d.ts +0 -2
- package/build/hooks/use_hidden_conversations_count.d.ts.map +0 -1
- package/build/hooks/use_hidden_conversations_count.js +0 -32
- package/build/hooks/use_hidden_conversations_count.js.map +0 -1
- package/build/hooks/use_hide_conversation.d.ts +0 -108
- package/build/hooks/use_hide_conversation.d.ts.map +0 -1
- package/build/hooks/use_hide_conversation.js +0 -243
- package/build/hooks/use_hide_conversation.js.map +0 -1
- package/build/hooks/use_hide_conversations_enabled.d.ts +0 -2
- package/build/hooks/use_hide_conversations_enabled.d.ts.map +0 -1
- package/build/hooks/use_hide_conversations_enabled.js +0 -18
- package/build/hooks/use_hide_conversations_enabled.js.map +0 -1
- package/build/screens/conversation_actions_screen.d.ts +0 -7
- package/build/screens/conversation_actions_screen.d.ts.map +0 -1
- package/build/screens/conversation_actions_screen.js +0 -89
- package/build/screens/conversation_actions_screen.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/build/utils/toast_store.d.ts +0 -21
- package/build/utils/toast_store.d.ts.map +0 -1
- package/build/utils/toast_store.js +0 -27
- package/build/utils/toast_store.js.map +0 -1
- package/src/components/conversations/hidden_indicator.tsx +0 -30
- package/src/components/conversations/hidden_results_footer.tsx +0 -25
- package/src/components/display/__tests__/toast.test.tsx +0 -55
- package/src/components/display/toast.tsx +0 -115
- package/src/hooks/__tests__/use_hide_conversation.test.tsx +0 -189
- package/src/hooks/use_hidden_conversations_count.ts +0 -14
- package/src/hooks/use_hide_conversation.ts +0 -128
- package/src/hooks/use_hide_conversations_enabled.ts +0 -7
- package/src/screens/__tests__/conversation_actions_screen.test.tsx +0 -79
- package/src/screens/conversation_actions_screen.tsx +0 -53
- package/src/utils/__tests__/open_url.test.ts +0 -67
- package/src/utils/open_url.ts +0 -47
- package/src/utils/toast_store.ts +0 -45
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import { StaticScreenProps, useNavigation } from '@react-navigation/native'
|
|
2
|
-
import React from 'react'
|
|
3
|
-
import { StyleSheet } from 'react-native'
|
|
4
|
-
import FormSheet, { getFormSheetScreenOptions } from '../components/primitive/form_sheet'
|
|
5
|
-
import { useConversation } from '../hooks/use_conversation'
|
|
6
|
-
import { useHideConversation } from '../hooks/use_hide_conversation'
|
|
7
|
-
import { useHideConversationsEnabled } from '../hooks/use_hide_conversations_enabled'
|
|
8
|
-
|
|
9
|
-
export const ConversationActionsScreenOptions = getFormSheetScreenOptions({
|
|
10
|
-
headerTitle: 'Conversation actions',
|
|
11
|
-
})
|
|
12
|
-
|
|
13
|
-
export type ConversationActionsScreenProps = StaticScreenProps<{
|
|
14
|
-
conversation_id: number
|
|
15
|
-
}>
|
|
16
|
-
|
|
17
|
-
export function ConversationActionsScreen({ route }: ConversationActionsScreenProps) {
|
|
18
|
-
const navigation = useNavigation()
|
|
19
|
-
const styles = useStyles()
|
|
20
|
-
const { data: conversation } = useConversation(route.params)
|
|
21
|
-
const { hidden, setHidden, isPending } = useHideConversation({ conversation })
|
|
22
|
-
const hideConversationsEnabled = useHideConversationsEnabled()
|
|
23
|
-
|
|
24
|
-
const handleHidePress = () => {
|
|
25
|
-
setHidden(!hidden)
|
|
26
|
-
navigation.goBack()
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
return (
|
|
30
|
-
<FormSheet.Root style={styles.formSheetContent}>
|
|
31
|
-
{hideConversationsEnabled && (
|
|
32
|
-
<FormSheet.Action
|
|
33
|
-
onPress={handleHidePress}
|
|
34
|
-
title={hidden ? 'Unhide conversation' : 'Hide conversation'}
|
|
35
|
-
iconName={hidden ? 'general.showEye' : 'general.hideEye'}
|
|
36
|
-
disabled={isPending}
|
|
37
|
-
accessibilityHint={
|
|
38
|
-
hidden
|
|
39
|
-
? 'Shows this conversation in your conversation list again.'
|
|
40
|
-
: 'Hides this conversation from your conversation list.'
|
|
41
|
-
}
|
|
42
|
-
/>
|
|
43
|
-
)}
|
|
44
|
-
</FormSheet.Root>
|
|
45
|
-
)
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
const useStyles = () =>
|
|
49
|
-
StyleSheet.create({
|
|
50
|
-
formSheetContent: {
|
|
51
|
-
paddingTop: 16,
|
|
52
|
-
},
|
|
53
|
-
})
|
|
@@ -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
|
-
}
|
package/src/utils/toast_store.ts
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
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
|
-
}
|