@planningcenter/chat-react-native 3.42.3-qa-staging.6 → 3.42.3-qa-staging.7

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 (76) hide show
  1. package/build/components/display/platform_modal_header_buttons.d.ts +7 -47
  2. package/build/components/display/platform_modal_header_buttons.d.ts.map +1 -1
  3. package/build/components/display/platform_modal_header_buttons.js +9 -119
  4. package/build/components/display/platform_modal_header_buttons.js.map +1 -1
  5. package/build/hooks/index.d.ts +1 -1
  6. package/build/hooks/index.d.ts.map +1 -1
  7. package/build/hooks/index.js +1 -1
  8. package/build/hooks/index.js.map +1 -1
  9. package/build/hooks/use_current_person.d.ts.map +1 -1
  10. package/build/hooks/use_current_person.js +0 -1
  11. package/build/hooks/use_current_person.js.map +1 -1
  12. package/build/hooks/use_direct_messages_enabled.d.ts +2 -0
  13. package/build/hooks/use_direct_messages_enabled.d.ts.map +1 -0
  14. package/build/hooks/use_direct_messages_enabled.js +16 -0
  15. package/build/hooks/use_direct_messages_enabled.js.map +1 -0
  16. package/build/hooks/use_features.d.ts +1 -0
  17. package/build/hooks/use_features.d.ts.map +1 -1
  18. package/build/hooks/use_features.js +1 -0
  19. package/build/hooks/use_features.js.map +1 -1
  20. package/build/navigation/index.d.ts +173 -69
  21. package/build/navigation/index.d.ts.map +1 -1
  22. package/build/navigation/index.js +72 -61
  23. package/build/navigation/index.js.map +1 -1
  24. package/build/screens/bug_report_screen.d.ts.map +1 -1
  25. package/build/screens/bug_report_screen.js +13 -10
  26. package/build/screens/bug_report_screen.js.map +1 -1
  27. package/build/screens/conversation_details_screen.d.ts.map +1 -1
  28. package/build/screens/conversation_details_screen.js +12 -11
  29. package/build/screens/conversation_details_screen.js.map +1 -1
  30. package/build/screens/conversation_filters/components/conversation_filters.js +3 -3
  31. package/build/screens/conversation_filters/components/conversation_filters.js.map +1 -1
  32. package/build/screens/conversation_filters_screen.js +2 -2
  33. package/build/screens/conversation_filters_screen.js.map +1 -1
  34. package/build/screens/conversation_screen.d.ts.map +1 -1
  35. package/build/screens/conversation_screen.js +2 -9
  36. package/build/screens/conversation_screen.js.map +1 -1
  37. package/build/screens/conversation_select_type_screen.d.ts.map +1 -1
  38. package/build/screens/conversation_select_type_screen.js +7 -4
  39. package/build/screens/conversation_select_type_screen.js.map +1 -1
  40. package/build/screens/conversations/components/list_header_component.js +3 -3
  41. package/build/screens/conversations/components/list_header_component.js.map +1 -1
  42. package/build/screens/message_report_screen.d.ts.map +1 -1
  43. package/build/screens/message_report_screen.js +18 -14
  44. package/build/screens/message_report_screen.js.map +1 -1
  45. package/build/screens/notification_settings_screen.d.ts.map +1 -1
  46. package/build/screens/notification_settings_screen.js +14 -0
  47. package/build/screens/notification_settings_screen.js.map +1 -1
  48. package/build/screens/settings_screen.js +3 -3
  49. package/build/screens/settings_screen.js.map +1 -1
  50. package/build/types/resources/person.d.ts +0 -1
  51. package/build/types/resources/person.d.ts.map +1 -1
  52. package/build/types/resources/person.js.map +1 -1
  53. package/package.json +4 -4
  54. package/src/components/display/platform_modal_header_buttons.tsx +13 -254
  55. package/src/hooks/index.ts +1 -1
  56. package/src/hooks/use_current_person.ts +0 -1
  57. package/src/hooks/use_direct_messages_enabled.ts +23 -0
  58. package/src/hooks/use_features.ts +1 -0
  59. package/src/navigation/index.tsx +166 -149
  60. package/src/screens/bug_report_screen.tsx +15 -16
  61. package/src/screens/conversation_details_screen.tsx +17 -11
  62. package/src/screens/conversation_filters/components/conversation_filters.tsx +3 -3
  63. package/src/screens/conversation_filters_screen.tsx +2 -2
  64. package/src/screens/conversation_screen.tsx +2 -10
  65. package/src/screens/conversation_select_type_screen.tsx +7 -4
  66. package/src/screens/conversations/components/list_header_component.tsx +3 -3
  67. package/src/screens/message_report_screen.tsx +21 -20
  68. package/src/screens/notification_settings_screen.tsx +21 -1
  69. package/src/screens/settings_screen.tsx +3 -3
  70. package/src/types/resources/person.ts +0 -1
  71. package/build/hooks/use_direct_messages_eligible.d.ts +0 -2
  72. package/build/hooks/use_direct_messages_eligible.d.ts.map +0 -1
  73. package/build/hooks/use_direct_messages_eligible.js +0 -9
  74. package/build/hooks/use_direct_messages_eligible.js.map +0 -1
  75. package/src/__tests__/hooks/use_direct_messages_eligible.test.tsx +0 -77
  76. package/src/hooks/use_direct_messages_eligible.ts +0 -11
@@ -6,7 +6,7 @@ import {
6
6
  useAtFontScaleBreakpoint,
7
7
  useCanCreateConversations,
8
8
  useCurrentPersonCache,
9
- useDirectMessagesEligible,
9
+ useDirectMessagesEnabled,
10
10
  useHasDirectMessages,
11
11
  useNewConversationEntry,
12
12
  useTheme,
@@ -35,9 +35,9 @@ export const ListHeaderComponent = () => {
35
35
  const navigation = useNavigation()
36
36
  const canFilterByTeams = useCanDisplayGroups({ source_app_name: 'Services', source_type: 'Team' })
37
37
  const canFilterByGroups = useCanDisplayGroups({ source_app_name: 'Groups', source_type: 'Group' })
38
- const directMessagesEligible = useDirectMessagesEligible()
38
+ const directMessagesEnabled = useDirectMessagesEnabled()
39
39
  const hasDirectMessages = useHasDirectMessages()
40
- const canFilterByDMs = directMessagesEligible && hasDirectMessages
40
+ const canFilterByDMs = directMessagesEnabled && hasDirectMessages
41
41
  const route = useRoute<RouteProp<ConversationsScreenProps['route']>>()
42
42
  const {
43
43
  chat_group_graph_id,
@@ -8,9 +8,8 @@ import { View, StyleSheet, TextInput, ScrollView } from 'react-native'
8
8
  import { useSafeAreaInsets } from 'react-native-safe-area-context'
9
9
  import { Spinner, Text, KeyboardView } from '../components'
10
10
  import {
11
- composeOptions,
12
- useHeaderRight,
13
- withLeftClose,
11
+ HeaderDismissButton,
12
+ HeaderTextButton,
14
13
  } from '../components/display/platform_modal_header_buttons'
15
14
  import BlankState from '../components/primitive/blank_state_primitive'
16
15
  import { useTheme } from '../hooks'
@@ -35,10 +34,11 @@ export const MessageReportScreenOptions = ({
35
34
  })
36
35
  )
37
36
 
38
- return composeOptions(
39
- { presentation: 'modal', title: 'Report message' },
40
- withLeftClose({ onPress: handleClose })
41
- )
37
+ return {
38
+ presentation: 'modal',
39
+ title: 'Report message',
40
+ headerLeft: () => <HeaderDismissButton title="Cancel" onPress={handleClose} />,
41
+ }
42
42
  }
43
43
 
44
44
  export type MessageReportScreenProps = StaticScreenProps<{
@@ -103,22 +103,23 @@ function MessageReportScreenContent({
103
103
  navigation.dispatch(StackActions.popTo('Conversation', { conversation_id }))
104
104
  }, [navigation, conversation_id])
105
105
 
106
- const formVisible = status !== 'pending' && status !== 'success'
107
-
108
- useHeaderRight({
109
- icon: 'general.message',
110
- accessibilityLabel: 'Submit',
111
- variant: 'fill',
112
- onPress: handleSubmit,
113
- disabled: !isFormValid,
114
- enabled: formVisible,
115
- })
106
+ const HeaderRight = useCallback(
107
+ () => <HeaderTextButton title="Submit" onPress={handleSubmit} disabled={!isFormValid} />,
108
+ [handleSubmit, isFormValid]
109
+ )
116
110
 
117
111
  useLayoutEffect(() => {
118
- if (formVisible) {
119
- navigation.setOptions({ headerTitle: 'Report message' })
112
+ if (status === 'pending' || status === 'success') {
113
+ navigation.setOptions({
114
+ headerRight: () => null,
115
+ })
116
+ } else {
117
+ navigation.setOptions({
118
+ headerTitle: 'Report message',
119
+ headerRight: HeaderRight,
120
+ })
120
121
  }
121
- }, [formVisible, navigation])
122
+ }, [HeaderRight, navigation, status])
122
123
 
123
124
  if (status === 'pending') {
124
125
  return (
@@ -1,9 +1,10 @@
1
1
  import { PlatformPressable } from '@react-navigation/elements'
2
2
  import { StaticScreenProps, useNavigation } from '@react-navigation/native'
3
- import { type ReactNode } from 'react'
3
+ import React, { useCallback, useEffect, type ReactNode } from 'react'
4
4
  import { FlatList, Platform, StyleSheet, View, type ViewProps, type ViewStyle } from 'react-native'
5
5
  import { useSafeAreaInsets } from 'react-native-safe-area-context'
6
6
  import { Badge, Heading, Icon, Text } from '../components'
7
+ import { HeaderTextButton } from '../components/display/platform_modal_header_buttons'
7
8
  import { useTheme } from '../hooks'
8
9
  import { isDefined } from '../types'
9
10
  import { chatTypeLabel } from '../utils'
@@ -50,6 +51,25 @@ export function NotificationSettingsScreen({}: NotificationSettingsScreenProps)
50
51
  const { data: chatTypes } = useChatTypes()
51
52
  const { data: groups } = useGroups()
52
53
 
54
+ // Header configuration
55
+ const HeaderRight = useCallback(() => {
56
+ return (
57
+ <HeaderTextButton
58
+ onPress={() => {
59
+ // Save settings logic would go here
60
+ navigation.goBack()
61
+ }}
62
+ title="Done"
63
+ />
64
+ )
65
+ }, [navigation])
66
+
67
+ useEffect(() => {
68
+ navigation.setOptions({
69
+ headerRight: HeaderRight,
70
+ })
71
+ }, [HeaderRight, navigation])
72
+
53
73
  // Build section data
54
74
  const listData = [
55
75
  {
@@ -4,7 +4,7 @@ import React, { useCallback } from 'react'
4
4
  import { Platform, StyleSheet, View } from 'react-native'
5
5
  import { Heading, Icon, Text } from '../components'
6
6
  import { Switch } from '../components/display/switch'
7
- import { useDirectMessagesEligible, useTheme } from '../hooks'
7
+ import { useDirectMessagesEnabled, useTheme } from '../hooks'
8
8
  import { useAppName } from '../hooks/use_app_name'
9
9
  import { usePersonSettings } from '../hooks/use_person_settings'
10
10
 
@@ -13,7 +13,7 @@ export type SettingsScreenProps = StaticScreenProps<{}>
13
13
  export function SettingsScreen({}: SettingsScreenProps) {
14
14
  const styles = useStyles()
15
15
  const { directMessagesDisabled, setDirectMessagesDisabled, isMutating } = usePersonSettings()
16
- const directMessagesEligible = useDirectMessagesEligible()
16
+ const directMessagesEnabled = useDirectMessagesEnabled()
17
17
  const appName = useAppName()
18
18
  const navigation = useNavigation()
19
19
 
@@ -31,7 +31,7 @@ export function SettingsScreen({}: SettingsScreenProps) {
31
31
  <View style={styles.sectionHeader}>
32
32
  <Heading variant="h2">Messages</Heading>
33
33
  </View>
34
- {directMessagesEligible && (
34
+ {directMessagesEnabled && (
35
35
  <View style={styles.settingRow}>
36
36
  <View style={styles.settingRowText}>
37
37
  <Text>Allow direct messages</Text>
@@ -22,6 +22,5 @@ export interface CurrentPersonResource extends PersonResource {
22
22
  pcoChatEnabled: boolean
23
23
  ageQualificationStatus?: AgeQualificationStatus
24
24
  directMessagesDisabled: boolean
25
- directMessagesEligible: boolean
26
25
  under_18: boolean
27
26
  }
@@ -1,2 +0,0 @@
1
- export declare const useDirectMessagesEligible: () => boolean;
2
- //# sourceMappingURL=use_direct_messages_eligible.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"use_direct_messages_eligible.d.ts","sourceRoot":"","sources":["../../src/hooks/use_direct_messages_eligible.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,yBAAyB,QAAO,OAM5C,CAAA"}
@@ -1,9 +0,0 @@
1
- import { useApiGet } from './use_api';
2
- import { currentPersonRequestArgs } from './use_current_person';
3
- export const useDirectMessagesEligible = () => {
4
- const { data: person, isFetched } = useApiGet(currentPersonRequestArgs);
5
- if (!isFetched)
6
- return false;
7
- return person?.directMessagesEligible ?? false;
8
- };
9
- //# sourceMappingURL=use_direct_messages_eligible.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"use_direct_messages_eligible.js","sourceRoot":"","sources":["../../src/hooks/use_direct_messages_eligible.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAA;AACrC,OAAO,EAAE,wBAAwB,EAAE,MAAM,sBAAsB,CAAA;AAE/D,MAAM,CAAC,MAAM,yBAAyB,GAAG,GAAY,EAAE;IACrD,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,GAAG,SAAS,CAAwB,wBAAwB,CAAC,CAAA;IAE9F,IAAI,CAAC,SAAS;QAAE,OAAO,KAAK,CAAA;IAE5B,OAAO,MAAM,EAAE,sBAAsB,IAAI,KAAK,CAAA;AAChD,CAAC,CAAA","sourcesContent":["import { CurrentPersonResource } from '../types'\nimport { useApiGet } from './use_api'\nimport { currentPersonRequestArgs } from './use_current_person'\n\nexport const useDirectMessagesEligible = (): boolean => {\n const { data: person, isFetched } = useApiGet<CurrentPersonResource>(currentPersonRequestArgs)\n\n if (!isFetched) return false\n\n return person?.directMessagesEligible ?? false\n}\n"]}
@@ -1,77 +0,0 @@
1
- import { QueryClientProvider } from '@tanstack/react-query'
2
- import { act, renderHook, waitFor } from '@testing-library/react-native'
3
- import React from 'react'
4
- import { buildTestQueryClient } from '../../__utils__/query_client'
5
- import { ChatContext, ChatContextValue } from '../../contexts/chat_context'
6
- import { ApiClient, useApiClient } from '../../hooks/use_api_client'
7
- import { currentPersonQueryKey } from '../../hooks/use_current_person'
8
- import { useDirectMessagesEligible } from '../../hooks/use_direct_messages_eligible'
9
- import { Session } from '../../utils'
10
-
11
- jest.mock('../../hooks/use_api_client')
12
-
13
- const mockedUseApiClient = useApiClient as jest.MockedFunction<typeof useApiClient>
14
-
15
- let get: jest.Mock
16
-
17
- const session = new Session({ token: { access_token: 'a-real-token' } })
18
-
19
- const renderUseDirectMessagesEligible = (queryClient = buildTestQueryClient()) => {
20
- const wrapper = ({ children }: { children: React.ReactNode }) => (
21
- <QueryClientProvider client={queryClient}>
22
- <ChatContext.Provider value={{ session } as unknown as ChatContextValue}>
23
- {children}
24
- </ChatContext.Provider>
25
- </QueryClientProvider>
26
- )
27
-
28
- return { ...renderHook(() => useDirectMessagesEligible(), { wrapper }), queryClient }
29
- }
30
-
31
- const flushMicrotasks = () =>
32
- act(async () => {
33
- await new Promise(resolve => setTimeout(resolve, 0))
34
- })
35
-
36
- beforeEach(() => {
37
- get = jest.fn().mockResolvedValue({ data: { id: 1, directMessagesEligible: true } })
38
- mockedUseApiClient.mockReturnValue({ chat: { get } } as unknown as ApiClient)
39
- })
40
-
41
- afterEach(() => {
42
- jest.clearAllMocks()
43
- })
44
-
45
- describe('useDirectMessagesEligible', () => {
46
- it('returns true once the person is fetched as eligible', async () => {
47
- get.mockResolvedValue({
48
- data: { id: 1, directMessagesEligible: true, directMessagesDisabled: true },
49
- })
50
-
51
- const { result } = renderUseDirectMessagesEligible()
52
-
53
- await waitFor(() => expect(result.current).toBe(true))
54
- })
55
-
56
- it('returns false when the attribute is absent from the response', async () => {
57
- get.mockResolvedValue({ data: { id: 1 } })
58
-
59
- const { result } = renderUseDirectMessagesEligible()
60
-
61
- await waitFor(() => expect(get).toHaveBeenCalled())
62
- await flushMicrotasks()
63
-
64
- expect(result.current).toBe(false)
65
- })
66
-
67
- it('reads the same /me cache entry as useCurrentPerson', () => {
68
- const queryClient = buildTestQueryClient()
69
- queryClient.setQueryData(currentPersonQueryKey, {
70
- data: { id: 1, directMessagesEligible: true },
71
- })
72
-
73
- const { result } = renderUseDirectMessagesEligible(queryClient)
74
-
75
- expect(result.current).toBe(true)
76
- })
77
- })
@@ -1,11 +0,0 @@
1
- import { CurrentPersonResource } from '../types'
2
- import { useApiGet } from './use_api'
3
- import { currentPersonRequestArgs } from './use_current_person'
4
-
5
- export const useDirectMessagesEligible = (): boolean => {
6
- const { data: person, isFetched } = useApiGet<CurrentPersonResource>(currentPersonRequestArgs)
7
-
8
- if (!isFetched) return false
9
-
10
- return person?.directMessagesEligible ?? false
11
- }