@planningcenter/chat-react-native 4.5.1-rc.0 → 4.6.0-qa-1063.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/assets/powered_by_giphy.png +0 -0
- package/assets/powered_by_giphy_dark.png +0 -0
- 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.d.ts.map +1 -1
- package/build/components/conversation/attachments/image_attachment.js +5 -3
- package/build/components/conversation/attachments/image_attachment.js.map +1 -1
- package/build/components/conversation/message_form.d.ts.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_list.d.ts.map +1 -1
- package/build/components/conversation/message_list.js +155 -123
- package/build/components/conversation/message_list.js.map +1 -1
- package/build/components/conversations/conversations.d.ts.map +1 -1
- package/build/components/conversations/conversations.js +1 -0
- package/build/components/conversations/conversations.js.map +1 -1
- package/build/components/display/conversation_avatar.d.ts +3 -1
- package/build/components/display/conversation_avatar.d.ts.map +1 -1
- package/build/components/display/conversation_avatar.js +77 -66
- package/build/components/display/conversation_avatar.js.map +1 -1
- package/build/components/display/keyboard_scroll_view.d.ts.map +1 -1
- package/build/components/display/keyboard_scroll_view.js +1 -0
- package/build/components/display/keyboard_scroll_view.js.map +1 -1
- package/build/components/page/page_error_boundary.d.ts +9 -1
- package/build/components/page/page_error_boundary.d.ts.map +1 -1
- package/build/components/page/page_error_boundary.js +56 -31
- package/build/components/page/page_error_boundary.js.map +1 -1
- package/build/hooks/use_conversation_avatar_update.d.ts +4 -3
- package/build/hooks/use_conversation_avatar_update.d.ts.map +1 -1
- package/build/hooks/use_conversation_avatar_update.js +146 -48
- package/build/hooks/use_conversation_avatar_update.js.map +1 -1
- package/build/navigation/index.d.ts.map +1 -1
- package/build/navigation/index.js +3 -1
- package/build/navigation/index.js.map +1 -1
- package/build/navigation/page_error_fallbacks.d.ts +7 -0
- package/build/navigation/page_error_fallbacks.d.ts.map +1 -0
- package/build/navigation/page_error_fallbacks.js +7 -0
- package/build/navigation/page_error_fallbacks.js.map +1 -0
- package/build/navigation/screenLayout.d.ts.map +1 -1
- package/build/navigation/screenLayout.js +10 -6
- package/build/navigation/screenLayout.js.map +1 -1
- package/build/screens/age_check/age_check_required_screen.d.ts.map +1 -1
- package/build/screens/age_check/age_check_required_screen.js +1 -0
- package/build/screens/age_check/age_check_required_screen.js.map +1 -1
- package/build/screens/age_check/age_check_underage_screen.d.ts.map +1 -1
- package/build/screens/age_check/age_check_underage_screen.js +2 -1
- package/build/screens/age_check/age_check_underage_screen.js.map +1 -1
- package/build/screens/attachment_actions/attachment_actions_screen.d.ts.map +1 -1
- package/build/screens/attachment_actions/attachment_actions_screen.js +5 -2
- package/build/screens/attachment_actions/attachment_actions_screen.js.map +1 -1
- package/build/screens/avatar_picker/avatar_picker_screen.d.ts.map +1 -1
- package/build/screens/avatar_picker/avatar_picker_screen.js +76 -66
- package/build/screens/avatar_picker/avatar_picker_screen.js.map +1 -1
- package/build/screens/bug_report_screen.d.ts.map +1 -1
- package/build/screens/bug_report_screen.js +3 -3
- 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 +1 -0
- package/build/screens/conversation_details_screen.js.map +1 -1
- package/build/screens/conversation_new/components/form_list.d.ts.map +1 -1
- package/build/screens/conversation_new/components/form_list.js +1 -0
- package/build/screens/conversation_new/components/form_list.js.map +1 -1
- package/build/screens/conversation_new/components/groups_form.js +25 -18
- package/build/screens/conversation_new/components/groups_form.js.map +1 -1
- package/build/screens/conversation_new/components/services_form.js +51 -40
- package/build/screens/conversation_new/components/services_form.js.map +1 -1
- package/build/screens/conversation_select_recipients/conversation_new_entry_screen.d.ts.map +1 -1
- package/build/screens/conversation_select_recipients/conversation_new_entry_screen.js +1 -0
- package/build/screens/conversation_select_recipients/conversation_new_entry_screen.js.map +1 -1
- package/build/screens/conversation_select_recipients/conversation_select_direct_message_recipients_screen.d.ts.map +1 -1
- package/build/screens/conversation_select_recipients/conversation_select_direct_message_recipients_screen.js +332 -291
- package/build/screens/conversation_select_recipients/conversation_select_direct_message_recipients_screen.js.map +1 -1
- package/build/screens/conversation_select_recipients/conversation_select_group_recipients_screen.d.ts.map +1 -1
- package/build/screens/conversation_select_recipients/conversation_select_group_recipients_screen.js +2 -1
- package/build/screens/conversation_select_recipients/conversation_select_group_recipients_screen.js.map +1 -1
- package/build/screens/conversation_select_recipients/conversation_select_teams_i_lead_recipients_screen.d.ts.map +1 -1
- package/build/screens/conversation_select_recipients/conversation_select_teams_i_lead_recipients_screen.js +1 -0
- package/build/screens/conversation_select_recipients/conversation_select_teams_i_lead_recipients_screen.js.map +1 -1
- package/build/screens/get_help_screen.js +57 -63
- package/build/screens/get_help_screen.js.map +1 -1
- package/build/screens/group_notification_settings_screen.js +3 -2
- package/build/screens/group_notification_settings_screen.js.map +1 -1
- package/build/screens/notification_settings_screen.d.ts.map +1 -1
- package/build/screens/notification_settings_screen.js +1 -0
- package/build/screens/notification_settings_screen.js.map +1 -1
- package/build/screens/preferred_app_selection_screen.js +45 -39
- package/build/screens/preferred_app_selection_screen.js.map +1 -1
- package/build/screens/search/components/search_results_list.d.ts +4 -1
- package/build/screens/search/components/search_results_list.d.ts.map +1 -1
- package/build/screens/search/components/search_results_list.js +136 -110
- package/build/screens/search/components/search_results_list.js.map +1 -1
- package/build/screens/search/search_screen.d.ts.map +1 -1
- package/build/screens/search/search_screen.js +21 -28
- package/build/screens/search/search_screen.js.map +1 -1
- package/build/screens/send_giphy_screen.d.ts.map +1 -1
- package/build/screens/send_giphy_screen.js +93 -136
- package/build/screens/send_giphy_screen.js.map +1 -1
- package/build/screens/settings_screen.d.ts.map +1 -1
- package/build/screens/settings_screen.js +7 -6
- package/build/screens/settings_screen.js.map +1 -1
- package/build/utils/index.d.ts +1 -0
- package/build/utils/index.d.ts.map +1 -1
- package/build/utils/index.js +1 -0
- package/build/utils/index.js.map +1 -1
- package/build/utils/membership_sync_info_text.d.ts +2 -0
- package/build/utils/membership_sync_info_text.d.ts.map +1 -0
- package/build/utils/membership_sync_info_text.js +4 -0
- package/build/utils/membership_sync_info_text.js.map +1 -0
- package/build/utils/native_adapters/linking.d.ts +11 -3
- package/build/utils/native_adapters/linking.d.ts.map +1 -1
- 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 +76 -0
- package/src/__tests__/screens/get_help_screen.test.ts +36 -0
- package/src/__utils__/render_with_query_client.tsx +13 -0
- package/src/components/conversation/__tests__/message_list.test.tsx +4 -0
- package/src/components/conversation/attachments/giphy_attachment.tsx +2 -3
- package/src/components/conversation/attachments/image_attachment.tsx +2 -3
- package/src/components/conversation/message_form.tsx +1 -1
- package/src/components/conversation/message_list.tsx +6 -0
- package/src/components/conversations/__tests__/conversation_preview.test.tsx +2 -2
- package/src/components/conversations/conversations.tsx +1 -0
- package/src/components/display/__tests__/conversation_avatar.test.tsx +94 -0
- package/src/components/display/conversation_avatar.tsx +9 -2
- package/src/components/display/keyboard_scroll_view.tsx +1 -0
- package/src/components/page/__tests__/page_error_boundary.test.tsx +33 -0
- package/src/components/page/page_error_boundary.tsx +43 -12
- package/src/hooks/__tests__/use_conversation_avatar_update.test.tsx +40 -0
- package/src/hooks/use_conversation_avatar_update.ts +67 -11
- package/src/navigation/index.tsx +6 -2
- package/src/navigation/page_error_fallbacks.ts +14 -0
- package/src/navigation/screenLayout.tsx +3 -1
- package/src/screens/age_check/age_check_required_screen.tsx +5 -1
- package/src/screens/age_check/age_check_underage_screen.tsx +2 -1
- package/src/screens/attachment_actions/__tests__/attachment_actions_screen.test.tsx +37 -1
- package/src/screens/attachment_actions/attachment_actions_screen.tsx +3 -2
- package/src/screens/avatar_picker/__tests__/avatar_picker_screen.test.tsx +67 -0
- package/src/screens/avatar_picker/avatar_picker_screen.tsx +7 -1
- package/src/screens/bug_report_screen.tsx +3 -11
- package/src/screens/conversation_details_screen.tsx +1 -0
- package/src/screens/conversation_new/components/form_list.tsx +1 -0
- package/src/screens/conversation_new/components/groups_form.tsx +2 -2
- package/src/screens/conversation_new/components/services_form.tsx +2 -2
- package/src/screens/conversation_select_recipients/__tests__/conversation_select_direct_message_recipients_screen.test.tsx +100 -0
- package/src/screens/conversation_select_recipients/conversation_new_entry_screen.tsx +4 -1
- package/src/screens/conversation_select_recipients/conversation_select_direct_message_recipients_screen.tsx +78 -68
- package/src/screens/conversation_select_recipients/conversation_select_group_recipients_screen.tsx +2 -1
- package/src/screens/conversation_select_recipients/conversation_select_teams_i_lead_recipients_screen.tsx +1 -0
- package/src/screens/get_help_screen.tsx +5 -5
- package/src/screens/group_notification_settings_screen.tsx +3 -3
- package/src/screens/notification_settings_screen.tsx +1 -0
- package/src/screens/preferred_app_selection_screen.tsx +4 -4
- package/src/screens/search/__tests__/search_screen.test.tsx +11 -12
- package/src/screens/search/components/__tests__/conversation_results.test.tsx +14 -5
- package/src/screens/search/components/__tests__/message_result_row.test.tsx +5 -4
- package/src/screens/search/components/__tests__/search_results_list.test.tsx +10 -5
- package/src/screens/search/components/search_results_list.tsx +34 -13
- package/src/screens/search/search_screen.tsx +8 -18
- package/src/screens/send_giphy_screen.tsx +13 -44
- package/src/screens/settings_screen.tsx +25 -25
- package/src/utils/__tests__/membership_sync_info_text.test.ts +15 -0
- package/src/utils/index.ts +1 -0
- package/src/utils/membership_sync_info_text.ts +3 -0
- package/src/utils/native_adapters/__tests__/linking.test.ts +12 -0
- package/src/utils/native_adapters/linking.ts +12 -3
|
@@ -1,7 +1,12 @@
|
|
|
1
|
-
import { useMutation, useQueryClient } from '@tanstack/react-query'
|
|
2
|
-
import { Alert } from 'react-native'
|
|
3
|
-
import type {
|
|
4
|
-
|
|
1
|
+
import { InfiniteData, useMutation, useMutationState, useQueryClient } from '@tanstack/react-query'
|
|
2
|
+
import { Alert, Image } from 'react-native'
|
|
3
|
+
import type {
|
|
4
|
+
ApiCollection,
|
|
5
|
+
ApiResource,
|
|
6
|
+
ConversationAvatarData,
|
|
7
|
+
ConversationResource,
|
|
8
|
+
} from '../types'
|
|
9
|
+
import { updateAllRecordsInPagesData } from '../utils/cache/page_mutations'
|
|
5
10
|
import { transformGetToPost } from '../utils/client/request_helpers'
|
|
6
11
|
import type { ImagePickerAsset } from '../utils/native_adapters/image_picker'
|
|
7
12
|
import { ApiClient, useApiClient } from './use_api_client'
|
|
@@ -16,6 +21,18 @@ export type AvatarUpdatePayload =
|
|
|
16
21
|
| { kind: Extract<AvatarType, 'image'>; imageAsset: ImagePickerAsset; color: string }
|
|
17
22
|
| { kind: 'clear' }
|
|
18
23
|
|
|
24
|
+
const MUTATION_KEY = 'updateConversationAvatar'
|
|
25
|
+
|
|
26
|
+
export const usePendingConversationAvatarUpdate = (conversationId: number | undefined) => {
|
|
27
|
+
const newest = useMutationState({
|
|
28
|
+
filters: { mutationKey: [MUTATION_KEY, conversationId], exact: true },
|
|
29
|
+
select: mutation => mutation.state,
|
|
30
|
+
}).at(-1)
|
|
31
|
+
|
|
32
|
+
if (conversationId === undefined || newest?.status !== 'pending') return undefined
|
|
33
|
+
return newest.variables as AvatarUpdatePayload
|
|
34
|
+
}
|
|
35
|
+
|
|
19
36
|
export const useConversationAvatarUpdate = ({ conversationId }: { conversationId: number }) => {
|
|
20
37
|
const apiClient = useApiClient()
|
|
21
38
|
const uploadClient = useUploadClient()
|
|
@@ -23,11 +40,18 @@ export const useConversationAvatarUpdate = ({ conversationId }: { conversationId
|
|
|
23
40
|
const requestArgs = getConversationRequestArgs({ conversation_id: conversationId })
|
|
24
41
|
const queryKey = getRequestQueryKey(requestArgs)
|
|
25
42
|
|
|
43
|
+
const isSuperseded = (payload: AvatarUpdatePayload) =>
|
|
44
|
+
queryClient
|
|
45
|
+
.getMutationCache()
|
|
46
|
+
.findAll({ mutationKey: [MUTATION_KEY, conversationId], exact: true })
|
|
47
|
+
.at(-1)?.state.variables !== payload
|
|
48
|
+
|
|
26
49
|
return useMutation({
|
|
27
|
-
mutationKey: [
|
|
50
|
+
mutationKey: [MUTATION_KEY, conversationId],
|
|
28
51
|
mutationFn: async (payload: AvatarUpdatePayload) => {
|
|
29
52
|
const postArgs = transformGetToPost(requestArgs).data
|
|
30
53
|
const attributes = await buildAttributes(payload, uploadClient)
|
|
54
|
+
if (isSuperseded(payload)) return null
|
|
31
55
|
|
|
32
56
|
return apiClient.chat.patch<ApiResource<ConversationResource>>({
|
|
33
57
|
url: `/me/conversations/${conversationId}/`,
|
|
@@ -41,16 +65,35 @@ export const useConversationAvatarUpdate = ({ conversationId }: { conversationId
|
|
|
41
65
|
|
|
42
66
|
queryClient.setQueryData<ApiResource<ConversationResource>>(queryKey, prev => {
|
|
43
67
|
if (!prev?.data) return prev
|
|
44
|
-
return { ...prev, data:
|
|
68
|
+
return { ...prev, data: applyAvatarUpdate(prev.data, payload) }
|
|
45
69
|
})
|
|
46
70
|
|
|
47
71
|
return { previous }
|
|
48
72
|
},
|
|
49
|
-
onSuccess: (response, _payload, _context) => {
|
|
73
|
+
onSuccess: async (response, _payload, _context) => {
|
|
74
|
+
if (!response) return
|
|
75
|
+
|
|
50
76
|
queryClient.setQueryData<ApiResource<ConversationResource>>(queryKey, () => response)
|
|
77
|
+
queryClient.setQueriesData<InfiniteData<ApiCollection<ConversationResource>>>(
|
|
78
|
+
{ queryKey: ['/me/conversations'] },
|
|
79
|
+
prev => {
|
|
80
|
+
if (!prev?.pages) return prev
|
|
81
|
+
|
|
82
|
+
return updateAllRecordsInPagesData({
|
|
83
|
+
data: prev,
|
|
84
|
+
processRecord: record =>
|
|
85
|
+
record.id === conversationId ? applySavedAvatar(record, response.data) : record,
|
|
86
|
+
})
|
|
87
|
+
}
|
|
88
|
+
)
|
|
51
89
|
queryClient.invalidateQueries({ queryKey: ['/me/conversations'] })
|
|
90
|
+
|
|
91
|
+
const imageUrl = response.data.customAvatarImageUrl
|
|
92
|
+
if (imageUrl) await Image.prefetch(imageUrl).catch(() => false)
|
|
52
93
|
},
|
|
53
|
-
onError: (_error,
|
|
94
|
+
onError: (_error, payload, context) => {
|
|
95
|
+
if (isSuperseded(payload)) return
|
|
96
|
+
|
|
54
97
|
if (context?.previous) {
|
|
55
98
|
queryClient.setQueryData(queryKey, context.previous)
|
|
56
99
|
}
|
|
@@ -83,10 +126,23 @@ export async function patchConversationAvatar(
|
|
|
83
126
|
}
|
|
84
127
|
}
|
|
85
128
|
|
|
86
|
-
function
|
|
87
|
-
data:
|
|
129
|
+
function applySavedAvatar<T extends ConversationAvatarData>(
|
|
130
|
+
data: T,
|
|
131
|
+
saved: ConversationAvatarData
|
|
132
|
+
): T {
|
|
133
|
+
return {
|
|
134
|
+
...data,
|
|
135
|
+
customAvatarType: saved.customAvatarType,
|
|
136
|
+
customAvatarKey: saved.customAvatarKey,
|
|
137
|
+
customAvatarColor: saved.customAvatarColor,
|
|
138
|
+
customAvatarImageUrl: saved.customAvatarImageUrl,
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
export function applyAvatarUpdate<T extends ConversationAvatarData>(
|
|
143
|
+
data: T,
|
|
88
144
|
payload: AvatarUpdatePayload
|
|
89
|
-
):
|
|
145
|
+
): T {
|
|
90
146
|
switch (payload.kind) {
|
|
91
147
|
case 'icon':
|
|
92
148
|
return {
|
package/src/navigation/index.tsx
CHANGED
|
@@ -85,7 +85,9 @@ import { ScreenLayoutWithChatAccessGate } from './screenLayout'
|
|
|
85
85
|
|
|
86
86
|
const globalScreenOptions: () => NativeStackNavigationOptions = () => ({
|
|
87
87
|
headerBackButtonDisplayMode: 'minimal',
|
|
88
|
-
...(isLiquidGlassEnabled()
|
|
88
|
+
...(isLiquidGlassEnabled()
|
|
89
|
+
? { headerShadowVisible: false, headerTransparent: true, headerBlurEffect: 'regular' }
|
|
90
|
+
: {}),
|
|
89
91
|
})
|
|
90
92
|
|
|
91
93
|
export const NewConversationStack = createNativeStackNavigator({
|
|
@@ -232,7 +234,9 @@ export const ChatStack = createNativeStackNavigator({
|
|
|
232
234
|
screen: ConversationScreen,
|
|
233
235
|
options: ({ route, navigation }) =>
|
|
234
236
|
composeOptions(
|
|
235
|
-
{
|
|
237
|
+
{
|
|
238
|
+
title: (route.params as ConversationRouteProps)?.title ?? 'Reply',
|
|
239
|
+
},
|
|
236
240
|
withMinimalBack({ onPress: navigation.goBack })
|
|
237
241
|
),
|
|
238
242
|
},
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { StaticParamList } from '@react-navigation/native'
|
|
2
|
+
import type { PageErrorFallback } from '../components/page/page_error_boundary'
|
|
3
|
+
import type { NewConversationStack } from './index'
|
|
4
|
+
|
|
5
|
+
type RouteName =
|
|
6
|
+
| keyof ReactNavigation.RootParamList
|
|
7
|
+
| keyof StaticParamList<typeof NewConversationStack>
|
|
8
|
+
|
|
9
|
+
export const PAGE_ERROR_FALLBACKS: Partial<Record<RouteName, PageErrorFallback>> = {
|
|
10
|
+
ConversationSelectDirectMessageRecipients: {
|
|
11
|
+
heading: "Couldn't load people right now",
|
|
12
|
+
body: 'Try again.',
|
|
13
|
+
},
|
|
14
|
+
}
|
|
@@ -6,14 +6,16 @@ import { useSafeAreaInsets } from 'react-native-safe-area-context'
|
|
|
6
6
|
import { DefaultLoading } from '../components/page/loading'
|
|
7
7
|
import { PageErrorBoundary } from '../components/page/page_error_boundary'
|
|
8
8
|
import { ChatAccessGate } from './chat_access_gate'
|
|
9
|
+
import { PAGE_ERROR_FALLBACKS } from './page_error_fallbacks'
|
|
9
10
|
|
|
10
11
|
export function ScreenLayout({ children }: { children: React.ReactElement }) {
|
|
11
12
|
const route = useRoute()
|
|
12
13
|
const styles = useStyles()
|
|
13
14
|
const { fontScale } = useWindowDimensions()
|
|
15
|
+
const genericFallback = PAGE_ERROR_FALLBACKS[route.name as keyof typeof PAGE_ERROR_FALLBACKS]
|
|
14
16
|
|
|
15
17
|
return (
|
|
16
|
-
<PageErrorBoundary screenName={route.name}>
|
|
18
|
+
<PageErrorBoundary screenName={route.name} genericFallback={genericFallback}>
|
|
17
19
|
<View key={fontScale} style={styles.screen}>
|
|
18
20
|
<Suspense fallback={<DefaultLoading />}>{children}</Suspense>
|
|
19
21
|
</View>
|
|
@@ -58,7 +58,11 @@ export function AgeCheckRequiredScreen() {
|
|
|
58
58
|
|
|
59
59
|
return (
|
|
60
60
|
<>
|
|
61
|
-
<ScrollView
|
|
61
|
+
<ScrollView
|
|
62
|
+
contentInsetAdjustmentBehavior="automatic"
|
|
63
|
+
style={styles.scrollView}
|
|
64
|
+
contentContainerStyle={styles.container}
|
|
65
|
+
>
|
|
62
66
|
<View style={styles.header}>
|
|
63
67
|
<View style={styles.heading}>
|
|
64
68
|
<Icon name="general.exclamationTriangle" size={20} style={styles.warningIcon} />
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { useRoute, RouteProp } from '@react-navigation/native'
|
|
2
2
|
import React from 'react'
|
|
3
|
-
import {
|
|
3
|
+
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 { Linking } from '../../utils'
|
|
7
8
|
import type { AgeCheckParams } from './screen_props'
|
|
8
9
|
|
|
9
10
|
export interface AgeCheckUnderageScreenProps {
|
|
@@ -1,9 +1,17 @@
|
|
|
1
1
|
import { HeaderHeightContext } from '@react-navigation/elements'
|
|
2
2
|
import { DefaultTheme, ThemeProvider } from '@react-navigation/native'
|
|
3
|
-
import { render } from '@testing-library/react-native'
|
|
3
|
+
import { fireEvent, render } from '@testing-library/react-native'
|
|
4
4
|
import React from 'react'
|
|
5
5
|
import { SafeAreaProvider } from 'react-native-safe-area-context'
|
|
6
6
|
import type { ConversationResource } from '../../../types'
|
|
7
|
+
import {
|
|
8
|
+
AudioAdapter,
|
|
9
|
+
ChatAdapters,
|
|
10
|
+
ClipboardAdapter,
|
|
11
|
+
ImagePickerAdapter,
|
|
12
|
+
LinkingAdapter,
|
|
13
|
+
VideoAdapter,
|
|
14
|
+
} from '../../../utils/native_adapters'
|
|
7
15
|
import { AttachmentActionsScreen, AttachmentActionsScreenProps } from '../attachment_actions_screen'
|
|
8
16
|
|
|
9
17
|
let mockConversation = { id: 1, disabled: false } as ConversationResource
|
|
@@ -19,6 +27,8 @@ jest.mock('../hooks/useDeleteAttachment', () => ({
|
|
|
19
27
|
useDeleteAttachment: () => ({ handleDeleteAttachment: jest.fn() }),
|
|
20
28
|
}))
|
|
21
29
|
|
|
30
|
+
const hostOpenURL = jest.fn(async (_url: string, _options?: object) => {})
|
|
31
|
+
|
|
22
32
|
const safeAreaMetrics = {
|
|
23
33
|
frame: { x: 0, y: 0, width: 390, height: 844 },
|
|
24
34
|
insets: { top: 0, right: 0, bottom: 0, left: 0 },
|
|
@@ -51,6 +61,22 @@ const renderScreen = (params: Partial<AttachmentActionsScreenProps['route']['par
|
|
|
51
61
|
}
|
|
52
62
|
|
|
53
63
|
describe('AttachmentActionsScreen', () => {
|
|
64
|
+
beforeAll(() => {
|
|
65
|
+
ChatAdapters.configure({
|
|
66
|
+
clipboard: new ClipboardAdapter({
|
|
67
|
+
getStringAsync: async () => '',
|
|
68
|
+
setStringAsync: async () => {},
|
|
69
|
+
}),
|
|
70
|
+
audio: new AudioAdapter({ useAudio: () => ({}) as any }),
|
|
71
|
+
video: new VideoAdapter({ Player: React.forwardRef(() => null) }),
|
|
72
|
+
imagePicker: new ImagePickerAdapter({
|
|
73
|
+
openCameraAsync: async () => ({ canceled: true, assets: null }),
|
|
74
|
+
openImageLibraryAsync: async () => ({ canceled: true, assets: null }),
|
|
75
|
+
}),
|
|
76
|
+
linking: new LinkingAdapter({ openURL: hostOpenURL, canOpenURL: async () => true }),
|
|
77
|
+
})
|
|
78
|
+
})
|
|
79
|
+
|
|
54
80
|
beforeEach(() => {
|
|
55
81
|
mockConversation = { id: 1, disabled: false } as ConversationResource
|
|
56
82
|
})
|
|
@@ -69,4 +95,14 @@ describe('AttachmentActionsScreen', () => {
|
|
|
69
95
|
expect(queryByText('Delete image')).toBeNull()
|
|
70
96
|
expect(getByText('Open in browser')).toBeTruthy()
|
|
71
97
|
})
|
|
98
|
+
|
|
99
|
+
it('asks the host app to open the attachment in the browser', () => {
|
|
100
|
+
const { getByText } = renderScreen()
|
|
101
|
+
|
|
102
|
+
fireEvent.press(getByText('Open in browser'))
|
|
103
|
+
|
|
104
|
+
expect(hostOpenURL).toHaveBeenCalledWith('https://example.com/a1.png', {
|
|
105
|
+
forceOpenInBrowser: true,
|
|
106
|
+
})
|
|
107
|
+
})
|
|
72
108
|
})
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { StaticScreenProps, useNavigation } from '@react-navigation/native'
|
|
2
2
|
import React, { useCallback } from 'react'
|
|
3
|
-
import { Alert,
|
|
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 { Linking } from '../../utils'
|
|
6
7
|
import { useDeleteAttachment } from './hooks/useDeleteAttachment'
|
|
7
8
|
|
|
8
9
|
export const AttachmentActionsScreenOptions = getFormSheetScreenOptions({
|
|
@@ -59,7 +60,7 @@ export function AttachmentActionsScreen({ route }: AttachmentActionsScreenProps)
|
|
|
59
60
|
}, [attachmentName, handleDeleteAttachment, navigation])
|
|
60
61
|
|
|
61
62
|
const handleOpenInBrowser = () => {
|
|
62
|
-
Linking.openURL(attachmentUrl)
|
|
63
|
+
Linking.openURL(attachmentUrl, { forceOpenInBrowser: true })
|
|
63
64
|
navigation.goBack()
|
|
64
65
|
}
|
|
65
66
|
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { HeaderHeightContext } from '@react-navigation/elements'
|
|
2
|
+
import { DefaultTheme, ThemeProvider } from '@react-navigation/native'
|
|
3
|
+
import { QueryClientProvider } from '@tanstack/react-query'
|
|
4
|
+
import { render } from '@testing-library/react-native'
|
|
5
|
+
import React from 'react'
|
|
6
|
+
import { Image } from 'react-native'
|
|
7
|
+
import { SafeAreaProvider } from 'react-native-safe-area-context'
|
|
8
|
+
import { buildTestQueryClient } from '../../../__utils__/query_client'
|
|
9
|
+
import type { AvatarUpdatePayload } from '../../../hooks/use_conversation_avatar_update'
|
|
10
|
+
import { AvatarPickerScreen } from '../avatar_picker_screen'
|
|
11
|
+
|
|
12
|
+
jest.mock('@react-navigation/native', () => ({
|
|
13
|
+
...jest.requireActual('@react-navigation/native'),
|
|
14
|
+
useNavigation: () => ({ goBack: jest.fn(), dispatch: jest.fn() }),
|
|
15
|
+
}))
|
|
16
|
+
jest.mock('../../../hooks/use_api_client', () => ({ useApiClient: () => ({}) }))
|
|
17
|
+
jest.mock('../../../hooks/use_upload_client', () => ({ useUploadClient: () => ({}) }))
|
|
18
|
+
jest.mock('../../../hooks/use_conversation', () => ({
|
|
19
|
+
...jest.requireActual('../../../hooks/use_conversation'),
|
|
20
|
+
useConversation: () => ({
|
|
21
|
+
data: { id: 7, customAvatarType: 'icon', customAvatarKey: 'star', customAvatarColor: 'cosmic' },
|
|
22
|
+
}),
|
|
23
|
+
}))
|
|
24
|
+
|
|
25
|
+
const safeAreaMetrics = {
|
|
26
|
+
frame: { x: 0, y: 0, width: 390, height: 844 },
|
|
27
|
+
insets: { top: 0, right: 0, bottom: 0, left: 0 },
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
describe('AvatarPickerScreen', () => {
|
|
31
|
+
it('opens on a photo that is still uploading instead of the cached avatar', async () => {
|
|
32
|
+
const queryClient = buildTestQueryClient()
|
|
33
|
+
const photo: AvatarUpdatePayload = {
|
|
34
|
+
kind: 'image',
|
|
35
|
+
color: 'cosmic',
|
|
36
|
+
imageAsset: { uri: 'file:///photo.jpg', width: 100, height: 100 },
|
|
37
|
+
}
|
|
38
|
+
let finishUpload = () => {}
|
|
39
|
+
const uploading = new Promise<void>(resolve => (finishUpload = resolve))
|
|
40
|
+
const upload = queryClient
|
|
41
|
+
.getMutationCache()
|
|
42
|
+
.build(queryClient, {
|
|
43
|
+
mutationKey: ['updateConversationAvatar', 7],
|
|
44
|
+
mutationFn: () => uploading,
|
|
45
|
+
networkMode: 'always',
|
|
46
|
+
})
|
|
47
|
+
.execute(photo)
|
|
48
|
+
|
|
49
|
+
const view = render(
|
|
50
|
+
<SafeAreaProvider initialMetrics={safeAreaMetrics}>
|
|
51
|
+
<ThemeProvider value={DefaultTheme}>
|
|
52
|
+
<HeaderHeightContext.Provider value={0}>
|
|
53
|
+
<QueryClientProvider client={queryClient}>
|
|
54
|
+
<AvatarPickerScreen route={{ params: { conversation_id: 7 } } as never} />
|
|
55
|
+
</QueryClientProvider>
|
|
56
|
+
</HeaderHeightContext.Provider>
|
|
57
|
+
</ThemeProvider>
|
|
58
|
+
</SafeAreaProvider>
|
|
59
|
+
)
|
|
60
|
+
|
|
61
|
+
const sources = view.UNSAFE_getAllByType(Image).map(image => image.props.source)
|
|
62
|
+
expect(sources).toContainEqual({ uri: 'file:///photo.jpg' })
|
|
63
|
+
|
|
64
|
+
finishUpload()
|
|
65
|
+
await upload
|
|
66
|
+
})
|
|
67
|
+
})
|
|
@@ -11,6 +11,7 @@ import { useTheme } from '../../hooks'
|
|
|
11
11
|
import { useConversation } from '../../hooks/use_conversation'
|
|
12
12
|
import {
|
|
13
13
|
useConversationAvatarUpdate,
|
|
14
|
+
usePendingConversationAvatarUpdate,
|
|
14
15
|
type AvatarUpdatePayload,
|
|
15
16
|
} from '../../hooks/use_conversation_avatar_update'
|
|
16
17
|
import { useFontScale } from '../../hooks/use_font_scale'
|
|
@@ -79,9 +80,14 @@ function EditModeContent({ conversationId }: { conversationId: number }) {
|
|
|
79
80
|
const navigation = useNavigation()
|
|
80
81
|
const { data: conversation } = useConversation({ conversation_id: conversationId })
|
|
81
82
|
const mutation = useConversationAvatarUpdate({ conversationId })
|
|
83
|
+
const pendingUpdate = usePendingConversationAvatarUpdate(conversationId)
|
|
82
84
|
const previewDiameter = usePreviewAvatarDiameter()
|
|
83
85
|
|
|
84
|
-
const [state, dispatch] = useReducer(avatarPickerReducer,
|
|
86
|
+
const [state, dispatch] = useReducer(avatarPickerReducer, undefined, () =>
|
|
87
|
+
pendingUpdate
|
|
88
|
+
? initAvatarPickerStateFromPayload(pendingUpdate)
|
|
89
|
+
: initAvatarPickerState(conversation)
|
|
90
|
+
)
|
|
85
91
|
|
|
86
92
|
const hasAvatar = state.selectedType !== null
|
|
87
93
|
|
|
@@ -5,15 +5,7 @@ import type {
|
|
|
5
5
|
} from '@react-navigation/native-stack'
|
|
6
6
|
import { startsWith } from 'lodash'
|
|
7
7
|
import React, { useCallback, useState } from 'react'
|
|
8
|
-
import {
|
|
9
|
-
View,
|
|
10
|
-
StyleSheet,
|
|
11
|
-
TextInput,
|
|
12
|
-
Linking,
|
|
13
|
-
ScrollView,
|
|
14
|
-
TouchableOpacity,
|
|
15
|
-
Platform,
|
|
16
|
-
} from 'react-native'
|
|
8
|
+
import { View, StyleSheet, TextInput, ScrollView, TouchableOpacity, Platform } from 'react-native'
|
|
17
9
|
import { useSafeAreaInsets } from 'react-native-safe-area-context'
|
|
18
10
|
import {
|
|
19
11
|
Button,
|
|
@@ -38,7 +30,7 @@ import { useTheme } from '../hooks'
|
|
|
38
30
|
import { useAppName } from '../hooks/use_app_name'
|
|
39
31
|
import { useReportBugAction } from '../hooks/use_report_bug_action'
|
|
40
32
|
import { useUploadClient } from '../hooks/use_upload_client'
|
|
41
|
-
import { ImagePicker, ImagePickerResult, platformFontWeightBold } from '../utils'
|
|
33
|
+
import { ImagePicker, ImagePickerResult, Linking, platformFontWeightBold } from '../utils'
|
|
42
34
|
|
|
43
35
|
const MAX_DESCRIPTION_LENGTH = 2000
|
|
44
36
|
|
|
@@ -292,7 +284,7 @@ export function BugReportScreen() {
|
|
|
292
284
|
|
|
293
285
|
<View style={styles.textInputContainer}>
|
|
294
286
|
<Text style={styles.fieldLabel}>
|
|
295
|
-
What did you expect to happen? Please describe what actually happened.{' '}
|
|
287
|
+
What did you expect to happen? Please also describe what actually happened.{' '}
|
|
296
288
|
<Text style={styles.required}>*</Text>
|
|
297
289
|
</Text>
|
|
298
290
|
<TextInput
|
|
@@ -427,6 +427,7 @@ export function ConversationDetailsScreen({ route }: ConversationDetailsScreenPr
|
|
|
427
427
|
return (
|
|
428
428
|
<View style={styles.listContainer}>
|
|
429
429
|
<FlatList
|
|
430
|
+
contentInsetAdjustmentBehavior="automatic"
|
|
430
431
|
data={listData as SectionListData}
|
|
431
432
|
contentContainerStyle={styles.contentContainer}
|
|
432
433
|
renderItem={({ item, index }) => {
|
|
@@ -22,7 +22,7 @@ import { useMyGender } from '../../../hooks/use_my_gender'
|
|
|
22
22
|
import { useUploadClient } from '../../../hooks/use_upload_client'
|
|
23
23
|
import { GroupsGroupResource } from '../../../types'
|
|
24
24
|
import { GraphId } from '../../../types/resources/group_resource'
|
|
25
|
-
import { pluralize } from '../../../utils'
|
|
25
|
+
import { membershipSyncInfoText, pluralize } from '../../../utils'
|
|
26
26
|
import { genderDisplayLabel } from '../../../utils/gender_display_label'
|
|
27
27
|
import { Haptic } from '../../../utils/native_adapters'
|
|
28
28
|
import { AvatarSelectionRow } from './avatar_selection_row'
|
|
@@ -147,7 +147,7 @@ export const GroupsForm = ({ groupId, chat_group_graph_id, avatarSelection }: Gr
|
|
|
147
147
|
disabled={!title || isPending || validationPending || warnings.length > 0}
|
|
148
148
|
title="Start Conversation"
|
|
149
149
|
onPress={() => handleSave()}
|
|
150
|
-
infoText=
|
|
150
|
+
infoText={membershipSyncInfoText('the group')}
|
|
151
151
|
warnings={warnings}
|
|
152
152
|
/>
|
|
153
153
|
</KeyboardView>
|
|
@@ -17,7 +17,7 @@ import { useConversationValidate } from '../../../hooks/use_conversation_validat
|
|
|
17
17
|
import { availableFeatures, useFeatures } from '../../../hooks/use_features'
|
|
18
18
|
import { useUploadClient } from '../../../hooks/use_upload_client'
|
|
19
19
|
import { MemberResource } from '../../../types'
|
|
20
|
-
import { pluralize } from '../../../utils'
|
|
20
|
+
import { membershipSyncInfoText, pluralize } from '../../../utils'
|
|
21
21
|
import { Haptic } from '../../../utils/native_adapters'
|
|
22
22
|
import { tokens } from '../../../vendor/tapestry/tokens'
|
|
23
23
|
import { TeamFilterTypes } from '../../conversation_filter_recipients/types'
|
|
@@ -139,7 +139,7 @@ export const ServicesForm = ({
|
|
|
139
139
|
}
|
|
140
140
|
title={selectionHasConversation ? 'Open conversation' : 'Start conversation'}
|
|
141
141
|
onPress={createConversation}
|
|
142
|
-
infoText=
|
|
142
|
+
infoText={membershipSyncInfoText(selectedTeamIds.length === 1 ? 'the team' : 'the teams')}
|
|
143
143
|
loading={isLoadingConversationCheck}
|
|
144
144
|
warnings={warnings}
|
|
145
145
|
/>
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { fireEvent, render } from '@testing-library/react-native'
|
|
2
|
+
import React from 'react'
|
|
3
|
+
import { SafeAreaProvider } from 'react-native-safe-area-context'
|
|
4
|
+
import { ScreenLayout } from '../../../navigation/screenLayout'
|
|
5
|
+
import { Log } from '../../../utils/native_adapters/configuration'
|
|
6
|
+
import { ResponseError } from '../../../utils/response_error'
|
|
7
|
+
import { ConversationSelectDirectMessageRecipientsScreen } from '../conversation_select_direct_message_recipients_screen'
|
|
8
|
+
|
|
9
|
+
jest.mock('@react-navigation/native', () => ({
|
|
10
|
+
...jest.requireActual('@react-navigation/native'),
|
|
11
|
+
useNavigation: () => ({ getParent: jest.fn(), goBack: jest.fn(), navigate: jest.fn() }),
|
|
12
|
+
useRoute: () => ({ name: 'ConversationSelectDirectMessageRecipients' }),
|
|
13
|
+
}))
|
|
14
|
+
jest.mock('../../../hooks/use_features', () => ({
|
|
15
|
+
...jest.requireActual('../../../hooks/use_features'),
|
|
16
|
+
useFeatures: () => ({ featureEnabled: () => false }),
|
|
17
|
+
}))
|
|
18
|
+
jest.mock('../../../hooks/use_debounced_search_term', () => ({
|
|
19
|
+
useDebouncedSearchTerm: (term: string) => term,
|
|
20
|
+
}))
|
|
21
|
+
jest.mock('../../../hooks/direct_messages/use_direct_message_conversation_validate', () => ({
|
|
22
|
+
useDirectMessageConversationValidate: () => ({ warnings: [], validationPending: false }),
|
|
23
|
+
}))
|
|
24
|
+
jest.mock('../../../hooks/direct_messages/use_find_or_create_direct_message_conversation', () => ({
|
|
25
|
+
useFindOrCreateDirectMessageConversation: () => ({
|
|
26
|
+
findOrCreateConversation: jest.fn(),
|
|
27
|
+
directMessageExists: false,
|
|
28
|
+
isFinding: false,
|
|
29
|
+
isError: false,
|
|
30
|
+
}),
|
|
31
|
+
}))
|
|
32
|
+
jest.mock('../../../hooks/direct_messages/use_direct_message_affiliations', () => ({
|
|
33
|
+
useDirectMessageAffiliations: () => ({
|
|
34
|
+
groups: new Map(),
|
|
35
|
+
teams: new Map(),
|
|
36
|
+
resultsDescription: null,
|
|
37
|
+
}),
|
|
38
|
+
}))
|
|
39
|
+
let mockSearchFailure: Error = new TypeError('Network request failed')
|
|
40
|
+
jest.mock('../../../hooks/direct_messages/use_direct_message_candidates', () => ({
|
|
41
|
+
useDirectMessageCandidates: (term: string) => {
|
|
42
|
+
if (term) throw mockSearchFailure
|
|
43
|
+
return { data: undefined, isFetching: false }
|
|
44
|
+
},
|
|
45
|
+
}))
|
|
46
|
+
jest.mock('../../../components/display/action_button', () => ({ ActionButton: () => null }))
|
|
47
|
+
jest.mock('../../../components/display/keyboard_view', () => ({
|
|
48
|
+
...jest.requireActual('../../../components/display/keyboard_view'),
|
|
49
|
+
KeyboardView: ({ children }: { children: React.ReactNode }) => children,
|
|
50
|
+
}))
|
|
51
|
+
|
|
52
|
+
const renderScreen = () =>
|
|
53
|
+
render(
|
|
54
|
+
<SafeAreaProvider
|
|
55
|
+
initialMetrics={{
|
|
56
|
+
frame: { x: 0, y: 0, width: 390, height: 844 },
|
|
57
|
+
insets: { top: 0, left: 0, right: 0, bottom: 0 },
|
|
58
|
+
}}
|
|
59
|
+
>
|
|
60
|
+
<ScreenLayout>
|
|
61
|
+
<ConversationSelectDirectMessageRecipientsScreen route={{ params: {} } as never} />
|
|
62
|
+
</ScreenLayout>
|
|
63
|
+
</SafeAreaProvider>
|
|
64
|
+
)
|
|
65
|
+
|
|
66
|
+
describe('ConversationSelectDirectMessageRecipientsScreen', () => {
|
|
67
|
+
let reportError: jest.SpyInstance
|
|
68
|
+
let consoleError: jest.SpyInstance
|
|
69
|
+
|
|
70
|
+
beforeEach(() => {
|
|
71
|
+
reportError = jest.spyOn(Log, 'reportError').mockImplementation(() => {})
|
|
72
|
+
consoleError = jest.spyOn(console, 'error').mockImplementation(() => {})
|
|
73
|
+
})
|
|
74
|
+
|
|
75
|
+
afterEach(() => {
|
|
76
|
+
reportError.mockRestore()
|
|
77
|
+
consoleError.mockRestore()
|
|
78
|
+
})
|
|
79
|
+
|
|
80
|
+
it('hands a failed search to the page error view', () => {
|
|
81
|
+
mockSearchFailure = new TypeError('Network request failed')
|
|
82
|
+
const view = renderScreen()
|
|
83
|
+
|
|
84
|
+
fireEvent.changeText(view.getByPlaceholderText('Search'), 'pi')
|
|
85
|
+
|
|
86
|
+
expect(view.getByText('Problem connecting!')).toBeTruthy()
|
|
87
|
+
expect(view.queryByPlaceholderText('Search')).toBeNull()
|
|
88
|
+
expect(reportError).toHaveBeenCalledTimes(1)
|
|
89
|
+
})
|
|
90
|
+
|
|
91
|
+
it("uses the screen's own wording when the search fails for no known reason", () => {
|
|
92
|
+
mockSearchFailure = new ResponseError({ status: 500, statusText: 'x', errors: [] } as never)
|
|
93
|
+
const view = renderScreen()
|
|
94
|
+
|
|
95
|
+
fireEvent.changeText(view.getByPlaceholderText('Search'), 'pi')
|
|
96
|
+
|
|
97
|
+
expect(view.getByText("Couldn't load people right now")).toBeTruthy()
|
|
98
|
+
expect(view.queryByText('Oops!')).toBeNull()
|
|
99
|
+
})
|
|
100
|
+
})
|
|
@@ -59,7 +59,10 @@ export const ConversationNewEntryScreen = ({ route }: ConversationSelectRecipien
|
|
|
59
59
|
}
|
|
60
60
|
|
|
61
61
|
return (
|
|
62
|
-
<ScrollView
|
|
62
|
+
<ScrollView
|
|
63
|
+
contentInsetAdjustmentBehavior="automatic"
|
|
64
|
+
contentContainerStyle={styles.contentContainer}
|
|
65
|
+
>
|
|
63
66
|
<View style={styles.header}>
|
|
64
67
|
<Heading variant="h2">Start a conversation by</Heading>
|
|
65
68
|
</View>
|