@planningcenter/chat-react-native 4.4.1-qa-staging.3 → 4.4.1-qa-staging.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. package/build/components/conversation/attachments/giphy_attachment.d.ts.map +1 -1
  2. package/build/components/conversation/attachments/giphy_attachment.js +2 -2
  3. package/build/components/conversation/attachments/giphy_attachment.js.map +1 -1
  4. package/build/components/conversation/message_form.d.ts.map +1 -1
  5. package/build/components/conversation/message_form.js +5 -3
  6. package/build/components/conversation/message_form.js.map +1 -1
  7. package/build/components/conversation/system_message.js +3 -3
  8. package/build/components/conversation/system_message.js.map +1 -1
  9. package/build/hooks/use_features.d.ts +2 -0
  10. package/build/hooks/use_features.d.ts.map +1 -1
  11. package/build/hooks/use_features.js +3 -1
  12. package/build/hooks/use_features.js.map +1 -1
  13. package/build/screens/age_check/age_check_underage_screen.d.ts.map +1 -1
  14. package/build/screens/age_check/age_check_underage_screen.js +3 -2
  15. package/build/screens/age_check/age_check_underage_screen.js.map +1 -1
  16. package/build/screens/bug_report_screen.d.ts.map +1 -1
  17. package/build/screens/bug_report_screen.js +2 -2
  18. package/build/screens/bug_report_screen.js.map +1 -1
  19. package/build/screens/get_help_screen.js +4 -4
  20. package/build/screens/get_help_screen.js.map +1 -1
  21. package/build/screens/send_giphy_screen.d.ts +1 -0
  22. package/build/screens/send_giphy_screen.d.ts.map +1 -1
  23. package/build/screens/send_giphy_screen.js +108 -106
  24. package/build/screens/send_giphy_screen.js.map +1 -1
  25. package/package.json +3 -3
  26. package/src/__tests__/components/conversation/attachments/giphy_attachment.test.tsx +76 -0
  27. package/src/__tests__/screens/get_help_screen.test.ts +40 -0
  28. package/src/__tests__/screens/send_giphy_screen.test.tsx +102 -0
  29. package/src/components/conversation/attachments/giphy_attachment.tsx +2 -3
  30. package/src/components/conversation/message_form.tsx +4 -2
  31. package/src/components/conversation/system_message.tsx +3 -3
  32. package/src/hooks/use_features.ts +2 -0
  33. package/src/screens/age_check/age_check_underage_screen.tsx +3 -2
  34. package/src/screens/bug_report_screen.tsx +2 -10
  35. package/src/screens/get_help_screen.tsx +4 -4
  36. package/src/screens/send_giphy_screen.tsx +6 -3
@@ -0,0 +1,102 @@
1
+ import { HeaderHeightContext } from '@react-navigation/elements'
2
+ import { DefaultTheme, ThemeProvider } from '@react-navigation/native'
3
+ import { QueryClientProvider, notifyManager } from '@tanstack/react-query'
4
+ import { act, fireEvent, render, screen } from '@testing-library/react-native'
5
+ import React from 'react'
6
+ import { SafeAreaProvider } from 'react-native-safe-area-context'
7
+ import { chatQueryClient } from '../../contexts/api_provider'
8
+ import { SendGiphyScreen, SendGiphyScreenProps } from '../../screens/send_giphy_screen'
9
+
10
+ jest.mock('../../contexts/api_provider', () => {
11
+ const { buildTestQueryClient } = require('../../__utils__/query_client')
12
+ return { chatQueryClient: buildTestQueryClient() }
13
+ })
14
+
15
+ const mockPost = jest.fn()
16
+ jest.mock('../../hooks/use_api_client', () => ({
17
+ useApiClient: () => ({ chat: { post: mockPost, patch: jest.fn() } }),
18
+ }))
19
+
20
+ jest.mock('../../hooks/use_current_person', () => ({
21
+ useCurrentPerson: () => ({ type: 'Person', id: 1, name: 'Me', avatar: null }),
22
+ }))
23
+
24
+ jest.mock('../../hooks/use_giphy', () => ({
25
+ useGiphy: () => ({
26
+ isSearching: false,
27
+ result: { type: 'giphy', title: 'cat', giphy: { fixed_width: { url: 'https://gif' } } },
28
+ nextResult: jest.fn(),
29
+ prevResult: jest.fn(),
30
+ }),
31
+ }))
32
+
33
+ const mockDispatch = jest.fn()
34
+ jest.mock('@react-navigation/native', () => ({
35
+ ...jest.requireActual('@react-navigation/native'),
36
+ useNavigation: () => ({
37
+ dispatch: mockDispatch,
38
+ goBack: jest.fn(),
39
+ getState: () => ({
40
+ routes: [
41
+ { name: 'Conversation', params: { conversation_id: 7 } },
42
+ { name: 'ConversationReply', params: { conversation_id: 7, reply_root_id: '42' } },
43
+ { name: 'SendGiphy' },
44
+ ],
45
+ }),
46
+ }),
47
+ }))
48
+
49
+ notifyManager.setNotifyFunction(fn => act(fn))
50
+
51
+ const safeAreaMetrics = {
52
+ frame: { x: 0, y: 0, width: 390, height: 844 },
53
+ insets: { top: 0, right: 0, bottom: 0, left: 0 },
54
+ }
55
+
56
+ describe('SendGiphyScreen', () => {
57
+ let finishSend: (value: unknown) => void
58
+
59
+ beforeEach(() => {
60
+ chatQueryClient.clear()
61
+ mockDispatch.mockReset()
62
+ mockPost.mockReset().mockReturnValue(new Promise(resolve => (finishSend = resolve)))
63
+ })
64
+
65
+ afterEach(async () => {
66
+ await act(async () => finishSend({ data: { type: 'Message', id: 'sent', mine: true } }))
67
+ })
68
+
69
+ it('sends from a reply thread as a reply and returns to the thread', async () => {
70
+ const route = {
71
+ params: { conversation_id: 7, reply_root_id: '42', search_term: 'cat' },
72
+ } as unknown as SendGiphyScreenProps['route']
73
+
74
+ render(
75
+ <QueryClientProvider client={chatQueryClient}>
76
+ <SafeAreaProvider initialMetrics={safeAreaMetrics}>
77
+ <ThemeProvider value={DefaultTheme}>
78
+ <HeaderHeightContext.Provider value={0}>
79
+ <SendGiphyScreen route={route} />
80
+ </HeaderHeightContext.Provider>
81
+ </ThemeProvider>
82
+ </SafeAreaProvider>
83
+ </QueryClientProvider>
84
+ )
85
+
86
+ await act(async () => {
87
+ fireEvent.press(screen.getByLabelText('Send Giphy'))
88
+ })
89
+
90
+ const [{ data }] = mockPost.mock.calls[0]
91
+ expect(data.data.attributes.reply_root).toEqual({ id: '42' })
92
+ expect(mockDispatch).toHaveBeenCalledWith(
93
+ expect.objectContaining({
94
+ type: 'POP_TO',
95
+ payload: expect.objectContaining({
96
+ name: 'ConversationReply',
97
+ params: expect.objectContaining({ reply_root_id: '42', clear_input: true }),
98
+ }),
99
+ })
100
+ )
101
+ })
102
+ })
@@ -1,9 +1,9 @@
1
1
  import { PlatformPressable } from '@react-navigation/elements'
2
2
  import React from 'react'
3
- import { Text, StyleSheet, Linking } from 'react-native'
3
+ import { Text, StyleSheet } from 'react-native'
4
4
  import { useTheme } from '../../../hooks'
5
5
  import { DenormalizedGiphyAttachmentResource } from '../../../types/resources/denormalized_attachment_resource'
6
- import { assertKeysAreNumbers } from '../../../utils'
6
+ import { assertKeysAreNumbers, Linking } from '../../../utils'
7
7
  import { tokens } from '../../../vendor/tapestry/tokens'
8
8
  import { Image } from '../../display'
9
9
 
@@ -22,7 +22,6 @@ export function GiphyAttachment({
22
22
 
23
23
  function handlePress() {
24
24
  if (titleLink) {
25
- // Open Giphy link in the default web browser
26
25
  Linking.openURL(titleLink)
27
26
  }
28
27
  }
@@ -1,7 +1,6 @@
1
1
  import { useNavigation, useTheme as useNavigationTheme, useRoute } from '@react-navigation/native'
2
2
  import React, { useCallback, useContext, useEffect, useRef, useState } from 'react'
3
3
  import {
4
- Linking,
5
4
  Platform,
6
5
  Pressable,
7
6
  ScrollView,
@@ -34,6 +33,7 @@ import {
34
33
  FileAttachment,
35
34
  } from '../../types/resources/denormalized_attachment_resource_for_create'
36
35
  import {
36
+ Linking,
37
37
  Log,
38
38
  MAX_FONT_SIZE_MULTIPLIER_LANDMARK,
39
39
  platformFontWeightMedium,
@@ -214,18 +214,20 @@ function MessageFormRoot({
214
214
  if (!Keyboard.isVisible() || Platform.OS === 'ios') {
215
215
  navigation.navigate('SendGiphy', {
216
216
  conversation_id: conversation.id,
217
+ reply_root_id: replyRootId,
217
218
  search_term: text,
218
219
  })
219
220
  } else {
220
221
  const keyboardListener = Keyboard.addListener('keyboardDidHide', () => {
221
222
  navigation.navigate('SendGiphy', {
222
223
  conversation_id: conversation.id,
224
+ reply_root_id: replyRootId,
223
225
  search_term: text,
224
226
  })
225
227
  keyboardListener?.remove()
226
228
  })
227
229
  }
228
- }, [conversation.id, navigation, text])
230
+ }, [conversation.id, navigation, replyRootId, text])
229
231
 
230
232
  const catchingUp = useRef(false)
231
233
 
@@ -21,7 +21,7 @@ export function SystemMessage({ message, conversationId }: SystemMessageProps) {
21
21
  const navigation = useNavigation()
22
22
  const { colors } = useTheme()
23
23
  const text = systemMessageText(names, overflowCount, action)
24
- const hasPeople = personIdsForSystemEvent.length > 0
24
+ const isTruncated = overflowCount > 0
25
25
  const hasReactions = reactionCounts.length > 0
26
26
  const { animatedBackgroundColor, handleMessagePressIn, handleMessagePressOut } =
27
27
  useAnimatedMessageBackgroundColor()
@@ -53,14 +53,14 @@ export function SystemMessage({ message, conversationId }: SystemMessageProps) {
53
53
 
54
54
  return (
55
55
  <Pressable
56
- onPress={hasPeople ? handlePress : undefined}
56
+ onPress={isTruncated ? handlePress : undefined}
57
57
  onLongPress={handleLongPress}
58
58
  onPressIn={handleMessagePressIn}
59
59
  onPressOut={handleMessagePressOut}
60
60
  android_ripple={{ color: colors.androidRippleNeutral, borderless: false, foreground: true }}
61
61
  accessibilityRole="button"
62
62
  accessibilityHint={
63
- hasPeople
63
+ isTruncated
64
64
  ? 'Tap to see people. Long press for message actions.'
65
65
  : 'Long press for message actions.'
66
66
  }
@@ -57,6 +57,8 @@ export const availableFeatures = {
57
57
  dm_search_clear_fix: 'ROLLOUT_MOBILE_dm_search_clear_fix',
58
58
  search: 'QA_MOBILE_search',
59
59
  search_rollout: 'ROLLOUT_MOBILE_search',
60
+ manual_archiving: 'QA_MOBILE_manual_archiving',
61
+ manual_archiving_rollout: 'ROLLOUT_MOBILE_manual_archiving',
60
62
  } as const satisfies Record<string, `${'QA' | 'ROLLOUT'}_${string}`>
61
63
 
62
64
  const stableEmptyFeatures: ApiCollection<FeatureResource> = {
@@ -1,9 +1,10 @@
1
1
  import { useRoute, RouteProp } from '@react-navigation/native'
2
2
  import React from 'react'
3
- import { Linking, StyleSheet, View, ScrollView } from 'react-native'
3
+ import { Linking as RNLinking, 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 {
@@ -18,7 +19,7 @@ export function AgeCheckUnderageScreen({ contactEmail }: AgeCheckUnderageScreenP
18
19
 
19
20
  const openChurchAdminHelp = () => {
20
21
  if (!email) return
21
- Linking.openURL(`mailto:${email}`)
22
+ RNLinking.openURL(`mailto:${email}`)
22
23
  }
23
24
 
24
25
  const openTerms = () => {
@@ -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
 
@@ -1,12 +1,12 @@
1
1
  import { StaticScreenProps, useNavigation } from '@react-navigation/native'
2
2
  import { useCallback, useMemo } from 'react'
3
- import { Alert, Linking, StyleSheet, View } from 'react-native'
3
+ import { Alert, Linking as RNLinking, StyleSheet, View } from 'react-native'
4
4
  import { Heading, PressableRow, Text, TextInlineButton } from '../components'
5
5
  import { useApiGet, useTheme } from '../hooks'
6
6
  import { useAppName } from '../hooks/use_app_name'
7
7
  import { useOrganization } from '../hooks/use_organization'
8
8
  import { ResourceObject } from '../types'
9
- import { Clipboard } from '../utils'
9
+ import { Clipboard, Linking } from '../utils'
10
10
 
11
11
  type GetHelpScreenRouteProps = {
12
12
  type?: 'chat' | 'general'
@@ -119,7 +119,7 @@ export function sendEmail(email: string) {
119
119
 
120
120
  const url = encodeURI(`mailto:${email}`)
121
121
 
122
- Linking.openURL(url).catch(() => {
122
+ RNLinking.openURL(url).catch(() => {
123
123
  Alert.alert('Oops', `Unable to open: ${email}`, [
124
124
  { text: 'Copy to clipboard', onPress: () => Clipboard.setStringAsync(email) },
125
125
  { text: 'OK' },
@@ -132,7 +132,7 @@ export function placePhoneCall(phoneNumber: string) {
132
132
 
133
133
  const url = encodeURI(`tel:${phoneNumber}`)
134
134
 
135
- Linking.openURL(url).catch(() => {
135
+ RNLinking.openURL(url).catch(() => {
136
136
  Alert.alert('Oops', `Unable to open: ${phoneNumber}`, [
137
137
  { text: 'Copy to clipboard', onPress: () => Clipboard.setStringAsync(phoneNumber) },
138
138
  { text: 'OK' },
@@ -17,16 +17,18 @@ export const SendGiphyScreenOptions = getFormSheetScreenOptions({
17
17
 
18
18
  export type SendGiphyScreenProps = StaticScreenProps<{
19
19
  conversation_id: number
20
+ reply_root_id?: string | null
20
21
  search_term: string
21
22
  }>
22
23
 
23
24
  export function SendGiphyScreen({ route }: SendGiphyScreenProps) {
24
- const { conversation_id, search_term } = route.params
25
+ const { conversation_id, reply_root_id, search_term } = route.params
25
26
  const styles = useStyles()
26
27
  const navigation = useNavigation()
27
28
 
28
29
  const { isPending, mutate } = useMessageCreateOrUpdate({
29
30
  conversationId: conversation_id,
31
+ replyRootId: reply_root_id,
30
32
  })
31
33
  const { isSearching, result, nextResult, prevResult } = useGiphy(search_term)
32
34
  const disabled = isPending || isSearching
@@ -53,11 +55,12 @@ export function SendGiphyScreen({ route }: SendGiphyScreenProps) {
53
55
 
54
56
  function goBack({ clearInput = false }) {
55
57
  if (clearInput) {
58
+ const routeName = reply_root_id ? 'ConversationReply' : 'Conversation'
56
59
  const routes = navigation.getState()?.routes || []
57
- const conversationParams = routes.find(r => r.name === 'Conversation')?.params || {}
60
+ const conversationParams = routes.findLast(r => r.name === routeName)?.params || {}
58
61
 
59
62
  navigation.dispatch(
60
- StackActions.popTo('Conversation', {
63
+ StackActions.popTo(routeName, {
61
64
  ...conversationParams,
62
65
  conversation_id,
63
66
  clear_input: true,