@planningcenter/chat-react-native 3.42.3-qa-staging.6 → 3.42.3-qa-856.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/messages_disabled_banners.d.ts +3 -2
- package/build/components/conversation/messages_disabled_banners.d.ts.map +1 -1
- package/build/components/conversation/messages_disabled_banners.js +7 -2
- package/build/components/conversation/messages_disabled_banners.js.map +1 -1
- package/build/components/display/adult_requirement_notice.js +1 -1
- package/build/components/display/adult_requirement_notice.js.map +1 -1
- package/build/components/display/platform_modal_header_buttons.d.ts +7 -29
- package/build/components/display/platform_modal_header_buttons.d.ts.map +1 -1
- package/build/components/display/platform_modal_header_buttons.js +24 -76
- package/build/components/display/platform_modal_header_buttons.js.map +1 -1
- package/build/hooks/index.d.ts +1 -1
- package/build/hooks/index.d.ts.map +1 -1
- package/build/hooks/index.js +1 -1
- package/build/hooks/index.js.map +1 -1
- package/build/hooks/use_conversation.d.ts.map +1 -1
- package/build/hooks/use_conversation.js +0 -1
- package/build/hooks/use_conversation.js.map +1 -1
- package/build/hooks/use_conversation_jolt_events.d.ts.map +1 -1
- package/build/hooks/use_conversation_jolt_events.js +2 -10
- package/build/hooks/use_conversation_jolt_events.js.map +1 -1
- package/build/hooks/use_current_person.d.ts.map +1 -1
- package/build/hooks/use_current_person.js +0 -1
- package/build/hooks/use_current_person.js.map +1 -1
- package/build/hooks/use_direct_messages_enabled.d.ts +2 -0
- package/build/hooks/use_direct_messages_enabled.d.ts.map +1 -0
- package/build/hooks/use_direct_messages_enabled.js +16 -0
- package/build/hooks/use_direct_messages_enabled.js.map +1 -0
- package/build/hooks/use_features.d.ts +1 -0
- package/build/hooks/use_features.d.ts.map +1 -1
- package/build/hooks/use_features.js +1 -0
- package/build/hooks/use_features.js.map +1 -1
- package/build/navigation/index.d.ts +84 -50
- package/build/navigation/index.d.ts.map +1 -1
- package/build/navigation/index.js +36 -27
- package/build/navigation/index.js.map +1 -1
- package/build/screens/bug_report_screen.d.ts.map +1 -1
- package/build/screens/bug_report_screen.js +3 -9
- 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 -2
- package/build/screens/conversation_details_screen.js.map +1 -1
- package/build/screens/conversation_filters/components/conversation_filters.js +3 -3
- package/build/screens/conversation_filters/components/conversation_filters.js.map +1 -1
- package/build/screens/conversation_filters/components/rows.js +1 -1
- package/build/screens/conversation_filters/components/rows.js.map +1 -1
- package/build/screens/conversation_filters_screen.d.ts.map +1 -1
- package/build/screens/conversation_filters_screen.js +14 -1
- package/build/screens/conversation_filters_screen.js.map +1 -1
- package/build/screens/conversation_screen.d.ts.map +1 -1
- package/build/screens/conversation_screen.js +3 -10
- package/build/screens/conversation_screen.js.map +1 -1
- package/build/screens/conversation_select_recipients/components/groups_recipient_row.js +1 -1
- package/build/screens/conversation_select_recipients/components/groups_recipient_row.js.map +1 -1
- package/build/screens/conversation_select_recipients/components/restricted_group_row.js +1 -1
- package/build/screens/conversation_select_recipients/components/restricted_group_row.js.map +1 -1
- package/build/screens/conversation_select_type_screen.d.ts.map +1 -1
- package/build/screens/conversation_select_type_screen.js +7 -4
- package/build/screens/conversation_select_type_screen.js.map +1 -1
- package/build/screens/conversations/components/list_header_component.js +3 -3
- package/build/screens/conversations/components/list_header_component.js.map +1 -1
- package/build/screens/message_report_screen.js +3 -5
- package/build/screens/message_report_screen.js.map +1 -1
- package/build/screens/notification_settings_screen.d.ts.map +1 -1
- package/build/screens/notification_settings_screen.js +2 -0
- package/build/screens/notification_settings_screen.js.map +1 -1
- package/build/screens/settings_screen.js +3 -3
- package/build/screens/settings_screen.js.map +1 -1
- package/build/types/jolt_events/conversation_events.d.ts +2 -2
- package/build/types/jolt_events/conversation_events.d.ts.map +1 -1
- package/build/types/jolt_events/conversation_events.js.map +1 -1
- package/build/types/resources/conversation.d.ts +2 -2
- package/build/types/resources/conversation.d.ts.map +1 -1
- package/build/types/resources/conversation.js.map +1 -1
- package/build/types/resources/person.d.ts +0 -1
- package/build/types/resources/person.d.ts.map +1 -1
- package/build/types/resources/person.js.map +1 -1
- package/build/utils/conversation_safety_constants.d.ts +1 -1
- package/build/utils/conversation_safety_constants.d.ts.map +1 -1
- package/build/utils/conversation_safety_constants.js +1 -1
- package/build/utils/conversation_safety_constants.js.map +1 -1
- package/build/utils/request/conversation.d.ts.map +1 -1
- package/build/utils/request/conversation.js +0 -1
- package/build/utils/request/conversation.js.map +1 -1
- package/package.json +4 -4
- package/src/components/conversation/messages_disabled_banners.tsx +11 -3
- package/src/components/display/adult_requirement_notice.tsx +1 -1
- package/src/components/display/platform_modal_header_buttons.tsx +50 -163
- package/src/hooks/index.ts +1 -1
- package/src/hooks/use_conversation.ts +0 -1
- package/src/hooks/use_conversation_jolt_events.ts +3 -16
- package/src/hooks/use_current_person.ts +0 -1
- package/src/hooks/use_direct_messages_enabled.ts +23 -0
- package/src/hooks/use_features.ts +1 -0
- package/src/navigation/index.tsx +42 -36
- package/src/screens/bug_report_screen.tsx +3 -9
- package/src/screens/conversation_details_screen.tsx +1 -2
- package/src/screens/conversation_filters/components/conversation_filters.tsx +3 -3
- package/src/screens/conversation_filters/components/rows.tsx +2 -2
- package/src/screens/conversation_filters_screen.tsx +21 -1
- package/src/screens/conversation_screen.tsx +3 -11
- package/src/screens/conversation_select_recipients/components/groups_recipient_row.tsx +1 -1
- package/src/screens/conversation_select_recipients/components/restricted_group_row.tsx +2 -2
- package/src/screens/conversation_select_type_screen.tsx +7 -4
- package/src/screens/conversations/components/list_header_component.tsx +3 -3
- package/src/screens/message_report_screen.tsx +3 -5
- package/src/screens/notification_settings_screen.tsx +4 -1
- package/src/screens/settings_screen.tsx +3 -3
- package/src/types/jolt_events/conversation_events.ts +2 -2
- package/src/types/resources/conversation.ts +3 -2
- package/src/types/resources/person.ts +0 -1
- package/src/utils/conversation_safety_constants.ts +1 -1
- package/src/utils/request/conversation.ts +0 -1
- package/build/hooks/use_direct_messages_eligible.d.ts +0 -2
- package/build/hooks/use_direct_messages_eligible.d.ts.map +0 -1
- package/build/hooks/use_direct_messages_eligible.js +0 -9
- package/build/hooks/use_direct_messages_eligible.js.map +0 -1
- package/src/__tests__/hooks/use_direct_messages_eligible.test.tsx +0 -77
- package/src/hooks/use_direct_messages_eligible.ts +0 -11
|
@@ -59,9 +59,9 @@ export const GroupRow = ({ group, isActive }: GroupRowProps) => {
|
|
|
59
59
|
|
|
60
60
|
return (
|
|
61
61
|
<PressableRow onPress={handleFilterByGroup} isActive={isActive}>
|
|
62
|
-
{headerImage?.
|
|
62
|
+
{headerImage?.thumbnail && (
|
|
63
63
|
<Image
|
|
64
|
-
source={{ uri: headerImage?.
|
|
64
|
+
source={{ uri: headerImage?.thumbnail }}
|
|
65
65
|
resizeMode="cover"
|
|
66
66
|
style={styles.rowImage}
|
|
67
67
|
alt=""
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { useHeaderHeight } from '@react-navigation/elements'
|
|
2
|
+
import * as ReactNavigationNative from '@react-navigation/native'
|
|
2
3
|
import { RouteProp, useRoute } from '@react-navigation/native'
|
|
3
4
|
import { createNativeStackNavigator } from '@react-navigation/native-stack'
|
|
4
5
|
import React, { useCallback } from 'react'
|
|
@@ -58,7 +59,26 @@ const FilterNavigator = createNativeStackNavigator<ConversationFilterStackParamL
|
|
|
58
59
|
},
|
|
59
60
|
})
|
|
60
61
|
|
|
61
|
-
|
|
62
|
+
// tree.getComponent() doesn't exist on every host's installed
|
|
63
|
+
// react-navigation/core — hosts on an older version would throw here.
|
|
64
|
+
// Where it does exist, it's the real implementation (the "deprecated"
|
|
65
|
+
// createComponentForStaticNavigation is just a console.warn wrapper around
|
|
66
|
+
// the same call on current versions), so prefer it and only reach for the
|
|
67
|
+
// old function on cores where getComponent() genuinely isn't there yet.
|
|
68
|
+
function createStaticNavigationComponent<P extends object>(
|
|
69
|
+
tree: { getComponent?: () => React.ComponentType<P> },
|
|
70
|
+
name: string
|
|
71
|
+
): React.ComponentType<P> {
|
|
72
|
+
if (typeof tree.getComponent === 'function') return tree.getComponent()
|
|
73
|
+
|
|
74
|
+
const { createComponentForStaticNavigation } = ReactNavigationNative as {
|
|
75
|
+
createComponentForStaticNavigation: (tree: unknown, name: string) => React.ComponentType<P>
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
return createComponentForStaticNavigation(tree, name)
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
const Filters = createStaticNavigationComponent(FilterNavigator, 'Filters')
|
|
62
82
|
|
|
63
83
|
export const ConversationFiltersScreen = (_props: ConversationFiltersScreenProps) => {
|
|
64
84
|
const styles = useStyles()
|
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
useRoute,
|
|
10
10
|
} from '@react-navigation/native'
|
|
11
11
|
import React, { useCallback, useEffect, useRef, useState } from 'react'
|
|
12
|
-
import { FlatList, Platform, StyleSheet,
|
|
12
|
+
import { FlatList, Platform, StyleSheet, View } from 'react-native'
|
|
13
13
|
import { useSafeAreaInsets } from 'react-native-safe-area-context'
|
|
14
14
|
import { Badge, Icon, Text } from '../components'
|
|
15
15
|
import { ConversationStartBanner } from '../components/conversation/conversation_start_banner'
|
|
@@ -25,7 +25,6 @@ import { ReplyShadowMessage } from '../components/conversation/reply_shadow_mess
|
|
|
25
25
|
import { SystemMessage } from '../components/conversation/system_message'
|
|
26
26
|
import { TypingIndicator } from '../components/conversation/typing_indicator'
|
|
27
27
|
import { KeyboardView } from '../components/display/keyboard_view'
|
|
28
|
-
import { useHeaderSlotReserve } from '../components/display/platform_modal_header_buttons'
|
|
29
28
|
import BlankState from '../components/primitive/blank_state_primitive'
|
|
30
29
|
import { ConversationContextProvider } from '../contexts/conversation_context'
|
|
31
30
|
import { useTheme } from '../hooks'
|
|
@@ -46,7 +45,6 @@ import { ConversationBadgeResource } from '../types/resources/conversation_badge
|
|
|
46
45
|
import { MessageResource } from '../types/resources/message'
|
|
47
46
|
import { getRelativeDateStatus } from '../utils/date'
|
|
48
47
|
import { groupMessages, type DateSeparator } from '../utils/group_messages'
|
|
49
|
-
import { isLiquidGlassEnabled } from '../utils/liquid_glass'
|
|
50
48
|
import { CONVERSATION_MESSAGE_LIST_PADDING_HORIZONTAL } from '../utils/styles'
|
|
51
49
|
import { isSystemMessage } from '../utils/system_messages'
|
|
52
50
|
|
|
@@ -259,7 +257,7 @@ function ConversationBottomBar({
|
|
|
259
257
|
if (conversation.disabled)
|
|
260
258
|
return (
|
|
261
259
|
<ConversationDisabledBanner
|
|
262
|
-
|
|
260
|
+
disabledReason={conversation.disabledReason}
|
|
263
261
|
messageLink={messageLink}
|
|
264
262
|
/>
|
|
265
263
|
)
|
|
@@ -376,17 +374,11 @@ export const ConversationScreenTitle = ({
|
|
|
376
374
|
}
|
|
377
375
|
|
|
378
376
|
const usePressableHeaderStyle = () => {
|
|
379
|
-
const { width } = useWindowDimensions()
|
|
380
|
-
const slotReserve = useHeaderSlotReserve()
|
|
381
|
-
const headerContainerStyle = isLiquidGlassEnabled()
|
|
382
|
-
? { maxWidth: width - slotReserve * 2 }
|
|
383
|
-
: { marginRight: Platform.select({ default: 20, android: 16 }) }
|
|
384
|
-
|
|
385
377
|
return StyleSheet.create({
|
|
386
378
|
container: {
|
|
387
379
|
alignItems: Platform.select({ android: 'flex-start', default: 'center' }),
|
|
380
|
+
marginRight: Platform.select({ ios: 20, default: 16 }),
|
|
388
381
|
flex: 1,
|
|
389
|
-
...headerContainerStyle,
|
|
390
382
|
},
|
|
391
383
|
titleWrapper: {
|
|
392
384
|
alignItems: 'center',
|
|
@@ -12,7 +12,7 @@ export const GroupsRecipientRow = ({ group, onPress }: GroupsRecipientRowProps)
|
|
|
12
12
|
|
|
13
13
|
return (
|
|
14
14
|
<RecipientLinkRow
|
|
15
|
-
imageUri={group.headerImage?.
|
|
15
|
+
imageUri={group.headerImage?.thumbnail}
|
|
16
16
|
title={group.name}
|
|
17
17
|
subtitle={`${group.membershipsCount} members`}
|
|
18
18
|
onPress={() => onPress(group)}
|
|
@@ -29,9 +29,9 @@ export const RestrictedGroupRow = ({ group }: RestrictedGroupRowProps) => {
|
|
|
29
29
|
accessibilityLabel={`${group.name} — ${reasonText(group.canCreateConversationReasonCode)}`}
|
|
30
30
|
>
|
|
31
31
|
<View style={styles.innerContainer}>
|
|
32
|
-
{group.headerImage?.
|
|
32
|
+
{group.headerImage?.thumbnail && (
|
|
33
33
|
<Image
|
|
34
|
-
source={{ uri: group.headerImage.
|
|
34
|
+
source={{ uri: group.headerImage.thumbnail }}
|
|
35
35
|
resizeMode="cover"
|
|
36
36
|
style={styles.image}
|
|
37
37
|
alt=""
|
|
@@ -2,6 +2,7 @@ import { StaticScreenProps, useNavigation } from '@react-navigation/native'
|
|
|
2
2
|
import React, { useLayoutEffect } from 'react'
|
|
3
3
|
import FormSheet, { getFormSheetScreenOptions } from '../components/primitive/form_sheet'
|
|
4
4
|
import { useCurrentPerson } from '../hooks/use_current_person'
|
|
5
|
+
import { availableFeatures, useFeatures } from '../hooks/use_features'
|
|
5
6
|
import { useConversationTypeAccess } from '../hooks/use_new_conversation_entry'
|
|
6
7
|
import type { NewConversationFromFilter } from '../hooks/use_new_conversation_from_filter'
|
|
7
8
|
import { AppName } from '../types/resources/app_name'
|
|
@@ -27,15 +28,17 @@ export function ConversationSelectTypeScreen({ route }: ConversationSelectTypeSc
|
|
|
27
28
|
const navigation = useNavigation()
|
|
28
29
|
const { canCreateGroupsConversations, canCreateServicesConversations } =
|
|
29
30
|
useConversationTypeAccess()
|
|
30
|
-
const {
|
|
31
|
+
const { featureEnabled } = useFeatures()
|
|
32
|
+
const { directMessagesDisabled, under_18 } = useCurrentPerson()
|
|
31
33
|
const { newConversationFromFilter, chat_group_graph_id, group_source_app_name } =
|
|
32
34
|
route.params || {}
|
|
33
35
|
|
|
34
36
|
const filterParams = { chat_group_graph_id, group_source_app_name }
|
|
35
|
-
const
|
|
37
|
+
const dmFeatureEnabled = featureEnabled(availableFeatures.direct_messages_eap)
|
|
38
|
+
const showDirectMessageOption = dmFeatureEnabled && !under_18
|
|
36
39
|
|
|
37
|
-
// sheetAllowedDetents depends on DM
|
|
38
|
-
// here instead of in the static ConversationSelectTypeScreenOptions. useLayoutEffect applies
|
|
40
|
+
// sheetAllowedDetents depends on the DM feature flag, which isn't known until render, so it's
|
|
41
|
+
// set here instead of in the static ConversationSelectTypeScreenOptions. useLayoutEffect applies
|
|
39
42
|
// it before paint so the sheet never visibly resizes after opening.
|
|
40
43
|
useLayoutEffect(() => {
|
|
41
44
|
navigation.setOptions({ sheetAllowedDetents: showDirectMessageOption ? [0.3] : [0.25] })
|
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
useAtFontScaleBreakpoint,
|
|
7
7
|
useCanCreateConversations,
|
|
8
8
|
useCurrentPersonCache,
|
|
9
|
-
|
|
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
|
|
38
|
+
const directMessagesEnabled = useDirectMessagesEnabled()
|
|
39
39
|
const hasDirectMessages = useHasDirectMessages()
|
|
40
|
-
const canFilterByDMs =
|
|
40
|
+
const canFilterByDMs = directMessagesEnabled && hasDirectMessages
|
|
41
41
|
const route = useRoute<RouteProp<ConversationsScreenProps['route']>>()
|
|
42
42
|
const {
|
|
43
43
|
chat_group_graph_id,
|
|
@@ -10,7 +10,7 @@ import { Spinner, Text, KeyboardView } from '../components'
|
|
|
10
10
|
import {
|
|
11
11
|
composeOptions,
|
|
12
12
|
useHeaderRight,
|
|
13
|
-
|
|
13
|
+
withLeftText,
|
|
14
14
|
} from '../components/display/platform_modal_header_buttons'
|
|
15
15
|
import BlankState from '../components/primitive/blank_state_primitive'
|
|
16
16
|
import { useTheme } from '../hooks'
|
|
@@ -37,7 +37,7 @@ export const MessageReportScreenOptions = ({
|
|
|
37
37
|
|
|
38
38
|
return composeOptions(
|
|
39
39
|
{ presentation: 'modal', title: 'Report message' },
|
|
40
|
-
|
|
40
|
+
withLeftText({ text: 'Cancel', onPress: handleClose })
|
|
41
41
|
)
|
|
42
42
|
}
|
|
43
43
|
|
|
@@ -106,9 +106,7 @@ function MessageReportScreenContent({
|
|
|
106
106
|
const formVisible = status !== 'pending' && status !== 'success'
|
|
107
107
|
|
|
108
108
|
useHeaderRight({
|
|
109
|
-
|
|
110
|
-
accessibilityLabel: 'Submit',
|
|
111
|
-
variant: 'fill',
|
|
109
|
+
title: 'Submit',
|
|
112
110
|
onPress: handleSubmit,
|
|
113
111
|
disabled: !isFormValid,
|
|
114
112
|
enabled: formVisible,
|
|
@@ -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, { 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 { useHeaderRight } 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,8 @@ export function NotificationSettingsScreen({}: NotificationSettingsScreenProps)
|
|
|
50
51
|
const { data: chatTypes } = useChatTypes()
|
|
51
52
|
const { data: groups } = useGroups()
|
|
52
53
|
|
|
54
|
+
useHeaderRight({ title: 'Done', onPress: navigation.goBack })
|
|
55
|
+
|
|
53
56
|
// Build section data
|
|
54
57
|
const listData = [
|
|
55
58
|
{
|
|
@@ -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 {
|
|
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
|
|
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
|
-
{
|
|
34
|
+
{directMessagesEnabled && (
|
|
35
35
|
<View style={styles.settingRow}>
|
|
36
36
|
<View style={styles.settingRowText}>
|
|
37
37
|
<Text>Allow direct messages</Text>
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { CustomMessage } from '@planningcenter/jolt-client/dist/types/JoltConnection'
|
|
2
|
+
import type { ConversationDisabledReason } from '../resources/conversation'
|
|
2
3
|
|
|
3
4
|
type DateString = string
|
|
4
5
|
interface BaseConversationEventData extends Record<string, unknown> {
|
|
@@ -15,8 +16,7 @@ interface BaseConversationEventData extends Record<string, unknown> {
|
|
|
15
16
|
latest_read_message_sort_key?: string
|
|
16
17
|
organization_id: number
|
|
17
18
|
disabled: boolean
|
|
18
|
-
disabled_reason
|
|
19
|
-
disabled_message: string | null
|
|
19
|
+
disabled_reason?: ConversationDisabledReason
|
|
20
20
|
replies_disabled: boolean
|
|
21
21
|
subtitle?: string
|
|
22
22
|
title: string
|
|
@@ -5,6 +5,8 @@ import { GroupResource } from './group_resource'
|
|
|
5
5
|
import { MemberAbilityResource } from './member_ability'
|
|
6
6
|
import { ReactionCountResource } from './reaction'
|
|
7
7
|
|
|
8
|
+
export type ConversationDisabledReason = 'safety_check' | 'direct_messages_disabled'
|
|
9
|
+
|
|
8
10
|
export interface ConversationPreviewData {
|
|
9
11
|
kind: 'reaction' | 'message'
|
|
10
12
|
authorName: string
|
|
@@ -24,8 +26,7 @@ export interface ConversationResource {
|
|
|
24
26
|
deleted?: boolean
|
|
25
27
|
directMessage?: boolean
|
|
26
28
|
disabled?: boolean
|
|
27
|
-
disabledReason?:
|
|
28
|
-
disabledMessage?: string | null
|
|
29
|
+
disabledReason?: ConversationDisabledReason
|
|
29
30
|
genderOption?: string | null
|
|
30
31
|
groups?: GroupResource[]
|
|
31
32
|
previewAvatarUrls?: string[]
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export const ADULT_REQUIREMENT_BODY =
|
|
2
|
-
'Conversations with
|
|
2
|
+
'Conversations with teens require at least 2 adults. This chat is paused until another adult is added.'
|
|
@@ -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
|
-
}
|