@planningcenter/chat-react-native 4.7.1-qa-1092.0 → 4.7.1-qa-staging.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/components/conversation/attachments/expanded_link.js +8 -8
- package/build/components/conversation/attachments/expanded_link.js.map +1 -1
- package/build/components/conversation/attachments/generic_file_attachment.d.ts.map +1 -1
- package/build/components/conversation/attachments/generic_file_attachment.js +2 -2
- package/build/components/conversation/attachments/generic_file_attachment.js.map +1 -1
- package/build/components/conversation/attachments/giphy_attachment.d.ts.map +1 -1
- package/build/components/conversation/attachments/giphy_attachment.js +2 -2
- package/build/components/conversation/attachments/giphy_attachment.js.map +1 -1
- package/build/components/conversation/attachments/image_attachment.js +2 -2
- package/build/components/conversation/attachments/image_attachment.js.map +1 -1
- package/build/components/conversation/message_form.js +2 -2
- package/build/components/conversation/message_form.js.map +1 -1
- package/build/components/conversation/message_markdown.js +2 -2
- package/build/components/conversation/message_markdown.js.map +1 -1
- package/build/components/conversations/conversation_actions.d.ts.map +1 -1
- package/build/components/conversations/conversation_actions.js +333 -193
- package/build/components/conversations/conversation_actions.js.map +1 -1
- package/build/components/conversations/conversation_preview.d.ts.map +1 -1
- package/build/components/conversations/conversation_preview.js +106 -91
- package/build/components/conversations/conversation_preview.js.map +1 -1
- package/build/components/conversations/conversations.d.ts.map +1 -1
- package/build/components/conversations/conversations.js +63 -56
- package/build/components/conversations/conversations.js.map +1 -1
- package/build/components/conversations/conversations_blank_state.d.ts +2 -1
- package/build/components/conversations/conversations_blank_state.d.ts.map +1 -1
- package/build/components/conversations/conversations_blank_state.js +71 -39
- package/build/components/conversations/conversations_blank_state.js.map +1 -1
- package/build/components/conversations/hidden_indicator.d.ts +4 -0
- package/build/components/conversations/hidden_indicator.d.ts.map +1 -0
- package/build/components/conversations/hidden_indicator.js +52 -0
- package/build/components/conversations/hidden_indicator.js.map +1 -0
- package/build/components/conversations/hidden_results_footer.d.ts +2 -0
- package/build/components/conversations/hidden_results_footer.d.ts.map +1 -0
- package/build/components/conversations/hidden_results_footer.js +34 -0
- package/build/components/conversations/hidden_results_footer.js.map +1 -0
- package/build/components/display/toast.d.ts +3 -0
- package/build/components/display/toast.d.ts.map +1 -0
- package/build/components/display/toast.js +224 -0
- package/build/components/display/toast.js.map +1 -0
- package/build/components/group_conversation_list.d.ts.map +1 -1
- package/build/components/group_conversation_list.js +1 -0
- package/build/components/group_conversation_list.js.map +1 -1
- package/build/contexts/conversations_context.d.ts +3 -1
- package/build/contexts/conversations_context.d.ts.map +1 -1
- package/build/contexts/conversations_context.js +39 -31
- package/build/contexts/conversations_context.js.map +1 -1
- package/build/hooks/groups/use_group_members_for_new_conversation.d.ts +6 -0
- package/build/hooks/groups/use_group_members_for_new_conversation.d.ts.map +1 -1
- package/build/hooks/use_api.d.ts +6 -0
- package/build/hooks/use_api.d.ts.map +1 -1
- package/build/hooks/use_api.js +8 -5
- package/build/hooks/use_api.js.map +1 -1
- package/build/hooks/use_clear_conversation_filters.d.ts.map +1 -1
- package/build/hooks/use_clear_conversation_filters.js +1 -0
- package/build/hooks/use_clear_conversation_filters.js.map +1 -1
- package/build/hooks/use_conversation.d.ts.map +1 -1
- package/build/hooks/use_conversation.js +1 -1
- package/build/hooks/use_conversation.js.map +1 -1
- package/build/hooks/use_features.d.ts +1 -0
- package/build/hooks/use_features.d.ts.map +1 -1
- package/build/hooks/use_features.js +2 -1
- package/build/hooks/use_features.js.map +1 -1
- package/build/hooks/use_groups.d.ts +6 -0
- package/build/hooks/use_groups.d.ts.map +1 -1
- package/build/hooks/use_groups_groups.d.ts +6 -0
- package/build/hooks/use_groups_groups.d.ts.map +1 -1
- package/build/hooks/use_hidden_conversations_count.d.ts +2 -0
- package/build/hooks/use_hidden_conversations_count.d.ts.map +1 -0
- package/build/hooks/use_hidden_conversations_count.js +32 -0
- package/build/hooks/use_hidden_conversations_count.js.map +1 -0
- package/build/hooks/use_hide_conversation.d.ts +108 -0
- package/build/hooks/use_hide_conversation.d.ts.map +1 -0
- package/build/hooks/use_hide_conversation.js +243 -0
- package/build/hooks/use_hide_conversation.js.map +1 -0
- package/build/hooks/use_hide_conversations_enabled.d.ts +2 -0
- package/build/hooks/use_hide_conversations_enabled.d.ts.map +1 -0
- package/build/hooks/use_hide_conversations_enabled.js +18 -0
- package/build/hooks/use_hide_conversations_enabled.js.map +1 -0
- package/build/hooks/use_teams.d.ts +6 -0
- package/build/hooks/use_teams.d.ts.map +1 -1
- package/build/navigation/index.d.ts +5 -0
- package/build/navigation/index.d.ts.map +1 -1
- package/build/navigation/index.js +5 -0
- package/build/navigation/index.js.map +1 -1
- package/build/screens/age_check/age_check_underage_screen.js +3 -3
- package/build/screens/age_check/age_check_underage_screen.js.map +1 -1
- package/build/screens/attachment_actions/attachment_actions_screen.js +2 -2
- package/build/screens/attachment_actions/attachment_actions_screen.js.map +1 -1
- package/build/screens/bug_report_screen.js +4 -4
- package/build/screens/bug_report_screen.js.map +1 -1
- package/build/screens/conversation_actions_screen.d.ts +7 -0
- package/build/screens/conversation_actions_screen.d.ts.map +1 -0
- package/build/screens/conversation_actions_screen.js +89 -0
- package/build/screens/conversation_actions_screen.js.map +1 -0
- package/build/screens/conversation_details_screen.d.ts.map +1 -1
- package/build/screens/conversation_details_screen.js +460 -394
- package/build/screens/conversation_details_screen.js.map +1 -1
- package/build/screens/conversation_filters/components/conversation_filters.d.ts.map +1 -1
- package/build/screens/conversation_filters/components/conversation_filters.js +53 -12
- package/build/screens/conversation_filters/components/conversation_filters.js.map +1 -1
- package/build/screens/conversation_filters/components/rows.d.ts +6 -3
- package/build/screens/conversation_filters/components/rows.d.ts.map +1 -1
- package/build/screens/conversation_filters/components/rows.js +99 -62
- package/build/screens/conversation_filters/components/rows.js.map +1 -1
- package/build/screens/conversation_filters/context/conversation_filter_context.d.ts.map +1 -1
- package/build/screens/conversation_filters/context/conversation_filter_context.js +4 -0
- package/build/screens/conversation_filters/context/conversation_filter_context.js.map +1 -1
- package/build/screens/conversation_filters/filter_types.d.ts +1 -0
- package/build/screens/conversation_filters/filter_types.d.ts.map +1 -1
- package/build/screens/conversation_filters/filter_types.js +1 -0
- package/build/screens/conversation_filters/filter_types.js.map +1 -1
- package/build/screens/conversation_filters/hooks/filters.d.ts +12 -0
- package/build/screens/conversation_filters/hooks/filters.d.ts.map +1 -1
- package/build/screens/conversation_filters/screen_props.d.ts +1 -0
- package/build/screens/conversation_filters/screen_props.d.ts.map +1 -1
- package/build/screens/conversation_filters/screen_props.js.map +1 -1
- package/build/screens/conversations/components/filter_dropdown_list_header_component.d.ts.map +1 -1
- package/build/screens/conversations/components/filter_dropdown_list_header_component.js +138 -126
- package/build/screens/conversations/components/filter_dropdown_list_header_component.js.map +1 -1
- package/build/screens/conversations/components/list_header_component.d.ts.map +1 -1
- package/build/screens/conversations/components/list_header_component.js +95 -90
- package/build/screens/conversations/components/list_header_component.js.map +1 -1
- package/build/screens/conversations/components/search_list_header_component.d.ts.map +1 -1
- package/build/screens/conversations/components/search_list_header_component.js +100 -95
- package/build/screens/conversations/components/search_list_header_component.js.map +1 -1
- package/build/screens/conversations/conversations_screen.d.ts +1 -0
- package/build/screens/conversations/conversations_screen.d.ts.map +1 -1
- package/build/screens/conversations/conversations_screen.js +18 -10
- package/build/screens/conversations/conversations_screen.js.map +1 -1
- package/build/screens/get_help_screen.d.ts.map +1 -1
- package/build/screens/get_help_screen.js +5 -21
- package/build/screens/get_help_screen.js.map +1 -1
- package/build/screens/index.d.ts +1 -0
- package/build/screens/index.d.ts.map +1 -1
- package/build/screens/index.js +1 -0
- package/build/screens/index.js.map +1 -1
- package/build/types/resources/conversation_membership.d.ts +1 -0
- package/build/types/resources/conversation_membership.d.ts.map +1 -1
- package/build/types/resources/conversation_membership.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/open_url.d.ts +11 -0
- package/build/utils/open_url.d.ts.map +1 -0
- package/build/utils/open_url.js +46 -0
- package/build/utils/open_url.js.map +1 -0
- package/build/utils/request/conversation.d.ts +3 -1
- package/build/utils/request/conversation.d.ts.map +1 -1
- package/build/utils/request/conversation.js +4 -0
- package/build/utils/request/conversation.js.map +1 -1
- package/build/utils/toast_store.d.ts +21 -0
- package/build/utils/toast_store.d.ts.map +1 -0
- package/build/utils/toast_store.js +27 -0
- package/build/utils/toast_store.js.map +1 -0
- package/build/vendor/font_awesome_pro_solid_icons.d.ts +1 -0
- package/build/vendor/font_awesome_pro_solid_icons.d.ts.map +1 -1
- package/build/vendor/font_awesome_pro_solid_icons.js +5 -0
- package/build/vendor/font_awesome_pro_solid_icons.js.map +1 -1
- package/package.json +3 -3
- package/src/__tests__/components/conversation/attachments/giphy_attachment.test.tsx +1 -1
- package/src/__tests__/screens/conversation_filters/components/conversation_filters.test.tsx +6 -0
- package/src/__tests__/screens/get_help_screen.test.ts +1 -1
- package/src/components/conversation/attachments/expanded_link.tsx +4 -4
- package/src/components/conversation/attachments/generic_file_attachment.tsx +2 -5
- package/src/components/conversation/attachments/giphy_attachment.tsx +2 -4
- package/src/components/conversation/attachments/image_attachment.tsx +2 -2
- package/src/components/conversation/message_form.tsx +2 -2
- package/src/components/conversation/message_markdown.tsx +2 -2
- package/src/components/conversations/__tests__/conversation_actions.test.tsx +77 -2
- package/src/components/conversations/__tests__/conversation_preview.test.tsx +29 -0
- package/src/components/conversations/__tests__/conversations.test.tsx +26 -0
- package/src/components/conversations/__tests__/conversations_blank_state.test.tsx +17 -0
- package/src/components/conversations/conversation_actions.tsx +73 -4
- package/src/components/conversations/conversation_preview.tsx +12 -1
- package/src/components/conversations/conversations.tsx +9 -0
- package/src/components/conversations/conversations_blank_state.tsx +18 -0
- package/src/components/conversations/hidden_indicator.tsx +30 -0
- package/src/components/conversations/hidden_results_footer.tsx +25 -0
- package/src/components/display/__tests__/toast.test.tsx +55 -0
- package/src/components/display/toast.tsx +115 -0
- package/src/components/group_conversation_list.tsx +4 -1
- package/src/contexts/conversations_context.tsx +8 -1
- package/src/hooks/__tests__/use_hide_conversation.test.tsx +189 -0
- package/src/hooks/use_api.ts +2 -1
- package/src/hooks/use_clear_conversation_filters.ts +1 -0
- package/src/hooks/use_conversation.ts +1 -0
- package/src/hooks/use_features.ts +1 -0
- package/src/hooks/use_hidden_conversations_count.ts +14 -0
- package/src/hooks/use_hide_conversation.ts +128 -0
- package/src/hooks/use_hide_conversations_enabled.ts +7 -0
- package/src/navigation/index.tsx +8 -0
- package/src/screens/__tests__/conversation_actions_screen.test.tsx +79 -0
- package/src/screens/__tests__/conversation_details_screen.test.tsx +49 -1
- package/src/screens/age_check/age_check_underage_screen.tsx +3 -3
- package/src/screens/attachment_actions/attachment_actions_screen.tsx +2 -2
- package/src/screens/bug_report_screen.tsx +4 -4
- package/src/screens/conversation_actions_screen.tsx +53 -0
- package/src/screens/conversation_details_screen.tsx +19 -0
- package/src/screens/conversation_filters/__tests__/conversation_filters.test.tsx +42 -0
- package/src/screens/conversation_filters/components/conversation_filters.tsx +22 -3
- package/src/screens/conversation_filters/components/rows.tsx +44 -10
- package/src/screens/conversation_filters/context/conversation_filter_context.tsx +4 -0
- package/src/screens/conversation_filters/filter_types.ts +1 -0
- package/src/screens/conversation_filters/screen_props.ts +1 -0
- package/src/screens/conversations/__tests__/conversations_screen.test.tsx +1 -0
- package/src/screens/conversations/components/__tests__/filter_dropdown_list_header_component.test.tsx +42 -0
- package/src/screens/conversations/components/__tests__/list_header_component.test.tsx +1 -0
- package/src/screens/conversations/components/filter_dropdown_list_header_component.tsx +21 -5
- package/src/screens/conversations/components/list_header_component.tsx +14 -4
- package/src/screens/conversations/components/search_list_header_component.tsx +14 -4
- package/src/screens/conversations/conversations_screen.tsx +3 -0
- package/src/screens/get_help_screen.tsx +5 -19
- package/src/screens/index.ts +1 -0
- package/src/types/resources/conversation_membership.ts +1 -0
- package/src/utils/__tests__/open_url.test.ts +67 -0
- package/src/utils/index.ts +1 -0
- package/src/utils/open_url.ts +47 -0
- package/src/utils/request/conversation.ts +6 -0
- package/src/utils/toast_store.ts +45 -0
- package/src/vendor/font_awesome_pro_solid_icons.ts +12 -0
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import React, { useEffect, useSyncExternalStore } from 'react'
|
|
2
|
+
import { AccessibilityInfo, StyleSheet, View } from 'react-native'
|
|
3
|
+
import Animated, { FadeInDown, FadeOutDown, ReduceMotion } from 'react-native-reanimated'
|
|
4
|
+
import { useSafeAreaInsets } from 'react-native-safe-area-context'
|
|
5
|
+
import { useReduceMotion, useTheme } from '../../hooks'
|
|
6
|
+
import { MAX_FONT_SIZE_MULTIPLIER_LANDMARK } from '../../utils/styles'
|
|
7
|
+
import { dismissToast, toastStore } from '../../utils/toast_store'
|
|
8
|
+
import { Text } from './text'
|
|
9
|
+
import { TextButton } from './text_button'
|
|
10
|
+
|
|
11
|
+
export const TOAST_DURATION_MS = 5000
|
|
12
|
+
|
|
13
|
+
export function Toast() {
|
|
14
|
+
const toast = useSyncExternalStore(toastStore.subscribe, toastStore.getSnapshot)
|
|
15
|
+
const styles = useStyles()
|
|
16
|
+
const reduceMotion = useReduceMotion() ? ReduceMotion.Always : ReduceMotion.Never
|
|
17
|
+
|
|
18
|
+
useEffect(() => {
|
|
19
|
+
if (!toast) return
|
|
20
|
+
|
|
21
|
+
AccessibilityInfo.announceForAccessibility(
|
|
22
|
+
[toast.title, toast.subtitle].filter(Boolean).join('. ')
|
|
23
|
+
)
|
|
24
|
+
const timeout = setTimeout(() => dismissToast(toast.id), TOAST_DURATION_MS)
|
|
25
|
+
return () => clearTimeout(timeout)
|
|
26
|
+
}, [toast])
|
|
27
|
+
|
|
28
|
+
useEffect(() => () => dismissToast(), [])
|
|
29
|
+
|
|
30
|
+
if (!toast) return null
|
|
31
|
+
|
|
32
|
+
const { id, title, subtitle, action } = toast
|
|
33
|
+
|
|
34
|
+
return (
|
|
35
|
+
<View style={styles.container} pointerEvents="box-none">
|
|
36
|
+
<Animated.View
|
|
37
|
+
key={id}
|
|
38
|
+
entering={FadeInDown.duration(200).reduceMotion(reduceMotion)}
|
|
39
|
+
exiting={FadeOutDown.duration(200).reduceMotion(reduceMotion)}
|
|
40
|
+
style={styles.toast}
|
|
41
|
+
accessibilityLiveRegion="polite"
|
|
42
|
+
testID="toast"
|
|
43
|
+
>
|
|
44
|
+
<View style={styles.content}>
|
|
45
|
+
<Text
|
|
46
|
+
style={styles.title}
|
|
47
|
+
maxFontSizeMultiplier={MAX_FONT_SIZE_MULTIPLIER_LANDMARK}
|
|
48
|
+
accessibilityRole="alert"
|
|
49
|
+
>
|
|
50
|
+
{title}
|
|
51
|
+
</Text>
|
|
52
|
+
{Boolean(subtitle) && (
|
|
53
|
+
<Text
|
|
54
|
+
variant="footnote"
|
|
55
|
+
style={styles.subtitle}
|
|
56
|
+
maxFontSizeMultiplier={MAX_FONT_SIZE_MULTIPLIER_LANDMARK}
|
|
57
|
+
>
|
|
58
|
+
{subtitle}
|
|
59
|
+
</Text>
|
|
60
|
+
)}
|
|
61
|
+
</View>
|
|
62
|
+
{action && (
|
|
63
|
+
<TextButton
|
|
64
|
+
textStyle={styles.actionText}
|
|
65
|
+
maxFontSizeMultiplier={MAX_FONT_SIZE_MULTIPLIER_LANDMARK}
|
|
66
|
+
onPress={() => {
|
|
67
|
+
dismissToast(id)
|
|
68
|
+
action.onPress()
|
|
69
|
+
}}
|
|
70
|
+
>
|
|
71
|
+
{action.label}
|
|
72
|
+
</TextButton>
|
|
73
|
+
)}
|
|
74
|
+
</Animated.View>
|
|
75
|
+
</View>
|
|
76
|
+
)
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
const useStyles = () => {
|
|
80
|
+
const { colors } = useTheme()
|
|
81
|
+
const { bottom } = useSafeAreaInsets()
|
|
82
|
+
|
|
83
|
+
return StyleSheet.create({
|
|
84
|
+
container: {
|
|
85
|
+
position: 'absolute',
|
|
86
|
+
left: 0,
|
|
87
|
+
right: 0,
|
|
88
|
+
bottom: bottom + 16,
|
|
89
|
+
paddingHorizontal: 16,
|
|
90
|
+
},
|
|
91
|
+
toast: {
|
|
92
|
+
flexDirection: 'row',
|
|
93
|
+
alignItems: 'center',
|
|
94
|
+
gap: 16,
|
|
95
|
+
paddingVertical: 12,
|
|
96
|
+
paddingHorizontal: 16,
|
|
97
|
+
borderRadius: 8,
|
|
98
|
+
backgroundColor: colors.fillColorNeutral010,
|
|
99
|
+
},
|
|
100
|
+
content: {
|
|
101
|
+
flex: 1,
|
|
102
|
+
gap: 2,
|
|
103
|
+
},
|
|
104
|
+
title: {
|
|
105
|
+
color: colors.fillColorNeutral100Inverted,
|
|
106
|
+
fontWeight: '600',
|
|
107
|
+
},
|
|
108
|
+
subtitle: {
|
|
109
|
+
color: colors.fillColorNeutral070,
|
|
110
|
+
},
|
|
111
|
+
actionText: {
|
|
112
|
+
color: colors.fillColorNeutral100Inverted,
|
|
113
|
+
},
|
|
114
|
+
})
|
|
115
|
+
}
|
|
@@ -33,7 +33,10 @@ interface GroupConversationsProps extends Partial<ConversationRequestArgs> {
|
|
|
33
33
|
*/
|
|
34
34
|
export const GroupConversations = ({ chat_group_graph_id, ...rest }: GroupConversationsProps) => {
|
|
35
35
|
return (
|
|
36
|
-
<ConversationsContextProvider
|
|
36
|
+
<ConversationsContextProvider
|
|
37
|
+
args={{ chat_group_graph_id, group_source_app_name: undefined }}
|
|
38
|
+
hideable={false}
|
|
39
|
+
>
|
|
37
40
|
<GroupConversationList {...rest} />
|
|
38
41
|
</ConversationsContextProvider>
|
|
39
42
|
)
|
|
@@ -14,6 +14,7 @@ interface ConversationsContextValue extends UseConversationsValue {
|
|
|
14
14
|
activeConversationId?: number
|
|
15
15
|
setActiveConversationId: (_id: number) => void
|
|
16
16
|
args: ConversationFiltersParams
|
|
17
|
+
hideable: boolean
|
|
17
18
|
}
|
|
18
19
|
|
|
19
20
|
const defaultQueryValue: UseConversationsValue = {
|
|
@@ -33,6 +34,7 @@ const ConversationsContext = createContext<ConversationsContextValue>({
|
|
|
33
34
|
args: {},
|
|
34
35
|
activeConversationId: undefined,
|
|
35
36
|
setActiveConversationId: () => {},
|
|
37
|
+
hideable: true,
|
|
36
38
|
...defaultQueryValue,
|
|
37
39
|
})
|
|
38
40
|
|
|
@@ -40,9 +42,11 @@ export const ConversationsContextProvider = ({
|
|
|
40
42
|
children,
|
|
41
43
|
args = {},
|
|
42
44
|
opts: paginatorOptions,
|
|
45
|
+
hideable = true,
|
|
43
46
|
}: PropsWithChildren<{
|
|
44
47
|
args: ConversationFiltersParams
|
|
45
48
|
opts?: ApiGetQueryOptions
|
|
49
|
+
hideable?: boolean
|
|
46
50
|
}>) => {
|
|
47
51
|
const [activeConversationId, setActiveConversationId] = useState<number | undefined>()
|
|
48
52
|
const {
|
|
@@ -50,6 +54,7 @@ export const ConversationsContextProvider = ({
|
|
|
50
54
|
group_source_app_name,
|
|
51
55
|
show_direct_messages,
|
|
52
56
|
show_archived,
|
|
57
|
+
show_hidden,
|
|
53
58
|
show_unread,
|
|
54
59
|
} = args
|
|
55
60
|
|
|
@@ -59,6 +64,7 @@ export const ConversationsContextProvider = ({
|
|
|
59
64
|
group_source_app_name,
|
|
60
65
|
show_direct_messages,
|
|
61
66
|
show_archived,
|
|
67
|
+
show_hidden,
|
|
62
68
|
show_unread,
|
|
63
69
|
},
|
|
64
70
|
paginatorOptions
|
|
@@ -69,9 +75,10 @@ export const ConversationsContextProvider = ({
|
|
|
69
75
|
args,
|
|
70
76
|
activeConversationId,
|
|
71
77
|
setActiveConversationId,
|
|
78
|
+
hideable,
|
|
72
79
|
...query,
|
|
73
80
|
}),
|
|
74
|
-
[args, activeConversationId, query]
|
|
81
|
+
[args, activeConversationId, hideable, query]
|
|
75
82
|
)
|
|
76
83
|
|
|
77
84
|
return <ConversationsContext.Provider value={value}>{children}</ConversationsContext.Provider>
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
import { QueryClientProvider } from '@tanstack/react-query'
|
|
2
|
+
import { act, renderHook } from '@testing-library/react-native'
|
|
3
|
+
import React from 'react'
|
|
4
|
+
import { Alert } from 'react-native'
|
|
5
|
+
import { buildTestQueryClient } from '../../__utils__/query_client'
|
|
6
|
+
import type { ConversationResource } from '../../types'
|
|
7
|
+
import { getConversationsRequestArgs } from '../../utils/request/conversation'
|
|
8
|
+
import { dismissToast, toastStore } from '../../utils/toast_store'
|
|
9
|
+
import { getConversationRequestArgs } from '../use_conversation'
|
|
10
|
+
import {
|
|
11
|
+
HIDDEN_AND_SILENCED_TOAST_SUBTITLE,
|
|
12
|
+
HIDDEN_TOAST_SUBTITLE,
|
|
13
|
+
useHideConversation,
|
|
14
|
+
} from '../use_hide_conversation'
|
|
15
|
+
import { getRequestQueryKey } from '../use_suspense_api'
|
|
16
|
+
|
|
17
|
+
const mockPatch = jest.fn()
|
|
18
|
+
jest.mock('../use_api_client', () => ({
|
|
19
|
+
useApiClient: () => ({ chat: { patch: mockPatch } }),
|
|
20
|
+
}))
|
|
21
|
+
|
|
22
|
+
const conversation = { id: 7, muted: false } as ConversationResource
|
|
23
|
+
const otherConversation = { id: 8, muted: false } as ConversationResource
|
|
24
|
+
const conversationKey = getRequestQueryKey(getConversationRequestArgs({ conversation_id: 7 }))
|
|
25
|
+
const allKey = getRequestQueryKey(getConversationsRequestArgs({ gids: 'all' }))
|
|
26
|
+
const unreadKey = getRequestQueryKey(
|
|
27
|
+
getConversationsRequestArgs({ gids: 'all', show_unread: true })
|
|
28
|
+
)
|
|
29
|
+
const hiddenKey = getRequestQueryKey(getConversationsRequestArgs({ show_hidden: true }))
|
|
30
|
+
|
|
31
|
+
const listData = (conversations: ConversationResource[]) => ({
|
|
32
|
+
pages: [{ data: conversations, links: {}, meta: { count: conversations.length } }],
|
|
33
|
+
pageParams: [{}],
|
|
34
|
+
})
|
|
35
|
+
|
|
36
|
+
const listIds = (queryKey: unknown[]) =>
|
|
37
|
+
(
|
|
38
|
+
queryClient.getQueryData(queryKey) as ReturnType<typeof listData> | undefined
|
|
39
|
+
)?.pages[0].data.map(({ id }) => id)
|
|
40
|
+
|
|
41
|
+
const buildQueryClient = () =>
|
|
42
|
+
buildTestQueryClient({ defaultOptions: { queries: { gcTime: Infinity } } })
|
|
43
|
+
|
|
44
|
+
let queryClient = buildQueryClient()
|
|
45
|
+
|
|
46
|
+
const wrapper = ({ children }: { children: React.ReactNode }) => (
|
|
47
|
+
<QueryClientProvider client={queryClient}>{children}</QueryClientProvider>
|
|
48
|
+
)
|
|
49
|
+
|
|
50
|
+
const renderHide = (target: ConversationResource = conversation, hidden?: boolean) =>
|
|
51
|
+
renderHook(() => useHideConversation({ conversation: target, hidden }), { wrapper })
|
|
52
|
+
|
|
53
|
+
describe('useHideConversation', () => {
|
|
54
|
+
beforeEach(() => {
|
|
55
|
+
queryClient = buildQueryClient()
|
|
56
|
+
queryClient.setQueryData(allKey, listData([conversation, otherConversation]))
|
|
57
|
+
queryClient.setQueryData(unreadKey, listData([conversation]))
|
|
58
|
+
queryClient.setQueryData(conversationKey, {
|
|
59
|
+
data: { id: 7, conversationMembership: { muted: false } },
|
|
60
|
+
})
|
|
61
|
+
mockPatch.mockReset()
|
|
62
|
+
dismissToast()
|
|
63
|
+
jest.spyOn(Alert, 'alert').mockImplementation(() => {})
|
|
64
|
+
})
|
|
65
|
+
|
|
66
|
+
afterEach(() => {
|
|
67
|
+
jest.restoreAllMocks()
|
|
68
|
+
})
|
|
69
|
+
|
|
70
|
+
it('removes the conversation from every list before the request resolves', async () => {
|
|
71
|
+
mockPatch.mockReturnValue(new Promise(() => {}))
|
|
72
|
+
const { result } = renderHide()
|
|
73
|
+
|
|
74
|
+
await act(async () => result.current.setHidden(true))
|
|
75
|
+
|
|
76
|
+
expect(listIds(allKey)).toEqual([8])
|
|
77
|
+
expect(listIds(unreadKey)).toEqual([])
|
|
78
|
+
expect(queryClient.getQueryData(conversationKey)).toEqual({
|
|
79
|
+
data: { id: 7, conversationMembership: { muted: false, hidden: true } },
|
|
80
|
+
})
|
|
81
|
+
})
|
|
82
|
+
|
|
83
|
+
it('patches hidden on the membership', async () => {
|
|
84
|
+
mockPatch.mockResolvedValue({ data: {} })
|
|
85
|
+
const { result } = renderHide()
|
|
86
|
+
|
|
87
|
+
await act(() => result.current.mutateAsync(true))
|
|
88
|
+
|
|
89
|
+
expect(mockPatch).toHaveBeenCalledWith({
|
|
90
|
+
url: '/me/conversations/7/conversation_membership',
|
|
91
|
+
data: {
|
|
92
|
+
data: { type: 'ConversationMembership', attributes: { hidden: true } },
|
|
93
|
+
fields: { ConversationMembership: 'hidden' },
|
|
94
|
+
},
|
|
95
|
+
})
|
|
96
|
+
})
|
|
97
|
+
|
|
98
|
+
it.each([
|
|
99
|
+
[false, HIDDEN_TOAST_SUBTITLE],
|
|
100
|
+
[true, HIDDEN_AND_SILENCED_TOAST_SUBTITLE],
|
|
101
|
+
])('shows an undo toast for muted=%s', async (muted, subtitle) => {
|
|
102
|
+
mockPatch.mockResolvedValue({ data: {} })
|
|
103
|
+
const { result } = renderHide({ ...conversation, muted })
|
|
104
|
+
|
|
105
|
+
await act(() => result.current.mutateAsync(true))
|
|
106
|
+
|
|
107
|
+
expect(toastStore.getSnapshot()).toMatchObject({
|
|
108
|
+
title: 'Conversation hidden',
|
|
109
|
+
subtitle,
|
|
110
|
+
action: { label: 'Undo' },
|
|
111
|
+
})
|
|
112
|
+
})
|
|
113
|
+
|
|
114
|
+
it('restores the lists and unhides on undo', async () => {
|
|
115
|
+
mockPatch.mockResolvedValue({ data: {} })
|
|
116
|
+
const { result } = renderHide()
|
|
117
|
+
await act(() => result.current.mutateAsync(true))
|
|
118
|
+
|
|
119
|
+
await act(async () => toastStore.getSnapshot()?.action?.onPress())
|
|
120
|
+
|
|
121
|
+
expect(listIds(allKey)).toEqual([7, 8])
|
|
122
|
+
expect(listIds(unreadKey)).toEqual([7])
|
|
123
|
+
expect(mockPatch).toHaveBeenLastCalledWith(
|
|
124
|
+
expect.objectContaining({
|
|
125
|
+
data: expect.objectContaining({
|
|
126
|
+
data: { type: 'ConversationMembership', attributes: { hidden: false } },
|
|
127
|
+
}),
|
|
128
|
+
})
|
|
129
|
+
)
|
|
130
|
+
})
|
|
131
|
+
|
|
132
|
+
it('puts the conversation back and alerts when hiding fails', async () => {
|
|
133
|
+
mockPatch.mockRejectedValue(new Error('nope'))
|
|
134
|
+
const { result } = renderHide()
|
|
135
|
+
|
|
136
|
+
await act(() => result.current.mutateAsync(true).catch(() => {}))
|
|
137
|
+
|
|
138
|
+
expect(listIds(allKey)).toEqual([7, 8])
|
|
139
|
+
expect(queryClient.getQueryData(conversationKey)).toEqual({
|
|
140
|
+
data: { id: 7, conversationMembership: { muted: false, hidden: false } },
|
|
141
|
+
})
|
|
142
|
+
expect(toastStore.getSnapshot()).toBeNull()
|
|
143
|
+
expect(Alert.alert).toHaveBeenCalledWith(
|
|
144
|
+
'Oops',
|
|
145
|
+
"Couldn't hide this conversation. Please try again."
|
|
146
|
+
)
|
|
147
|
+
})
|
|
148
|
+
|
|
149
|
+
describe('from the hidden list', () => {
|
|
150
|
+
beforeEach(() => {
|
|
151
|
+
queryClient.setQueryData(hiddenKey, listData([conversation, otherConversation]))
|
|
152
|
+
})
|
|
153
|
+
|
|
154
|
+
it('removes the conversation from the hidden list before the request resolves', async () => {
|
|
155
|
+
mockPatch.mockReturnValue(new Promise(() => {}))
|
|
156
|
+
const { result } = renderHide(conversation, true)
|
|
157
|
+
|
|
158
|
+
expect(result.current.hidden).toBe(true)
|
|
159
|
+
|
|
160
|
+
await act(async () => result.current.setHidden(false))
|
|
161
|
+
|
|
162
|
+
expect(listIds(hiddenKey)).toEqual([8])
|
|
163
|
+
expect(listIds(allKey)).toEqual([7, 8])
|
|
164
|
+
})
|
|
165
|
+
|
|
166
|
+
it('puts the conversation back in the hidden list when unhiding fails', async () => {
|
|
167
|
+
mockPatch.mockRejectedValue(new Error('nope'))
|
|
168
|
+
const { result } = renderHide(conversation, true)
|
|
169
|
+
|
|
170
|
+
await act(() => result.current.mutateAsync(false).catch(() => {}))
|
|
171
|
+
|
|
172
|
+
expect(listIds(hiddenKey)).toEqual([7, 8])
|
|
173
|
+
expect(Alert.alert).toHaveBeenCalledWith(
|
|
174
|
+
'Oops',
|
|
175
|
+
"Couldn't unhide this conversation. Please try again."
|
|
176
|
+
)
|
|
177
|
+
})
|
|
178
|
+
|
|
179
|
+
it('refreshes the hidden list after hiding elsewhere', async () => {
|
|
180
|
+
mockPatch.mockResolvedValue({ data: {} })
|
|
181
|
+
const { result } = renderHide(otherConversation)
|
|
182
|
+
|
|
183
|
+
await act(() => result.current.mutateAsync(true))
|
|
184
|
+
|
|
185
|
+
expect(queryClient.getQueryState(hiddenKey)?.isInvalidated).toBe(true)
|
|
186
|
+
expect(queryClient.getQueryState(unreadKey)?.isInvalidated).toBe(false)
|
|
187
|
+
})
|
|
188
|
+
})
|
|
189
|
+
})
|
package/src/hooks/use_api.ts
CHANGED
|
@@ -84,6 +84,7 @@ export const useApiPaginator = <T extends ResourceObject>(
|
|
|
84
84
|
})
|
|
85
85
|
|
|
86
86
|
const data: T[] = query.data?.pages?.flatMap(page => page.data) || []
|
|
87
|
+
const totalCount = query.data?.pages?.[0]?.meta?.totalCount ?? data.length
|
|
87
88
|
|
|
88
|
-
return { ...query, data }
|
|
89
|
+
return { ...query, data, totalCount }
|
|
89
90
|
}
|
|
@@ -61,6 +61,7 @@ export const availableFeatures = {
|
|
|
61
61
|
filter_dropdown_rollout: 'ROLLOUT_MOBILE_filter_dropdown',
|
|
62
62
|
manual_archiving: 'QA_MOBILE_manual_archiving',
|
|
63
63
|
manual_archiving_rollout: 'ROLLOUT_MOBILE_manual_archiving',
|
|
64
|
+
hide_conversations: 'ROLLOUT_hide_conversations',
|
|
64
65
|
} as const satisfies Record<string, `${'QA' | 'ROLLOUT'}_${string}`>
|
|
65
66
|
|
|
66
67
|
const featureNames = Object.values(availableFeatures)
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { ConversationResource } from '../types'
|
|
2
|
+
import { getConversationsRequestArgs } from '../utils/request/conversation'
|
|
3
|
+
import { useApiPaginator } from './use_api'
|
|
4
|
+
import { useHideConversationsEnabled } from './use_hide_conversations_enabled'
|
|
5
|
+
|
|
6
|
+
export function useHiddenConversationsCount() {
|
|
7
|
+
const enabled = useHideConversationsEnabled()
|
|
8
|
+
const { totalCount } = useApiPaginator<ConversationResource>(
|
|
9
|
+
getConversationsRequestArgs({ show_hidden: true }),
|
|
10
|
+
{ enabled }
|
|
11
|
+
)
|
|
12
|
+
|
|
13
|
+
return enabled ? totalCount : 0
|
|
14
|
+
}
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import { InfiniteData, QueryKey, useMutation, useQueryClient } from '@tanstack/react-query'
|
|
2
|
+
import { Alert } from 'react-native'
|
|
3
|
+
import {
|
|
4
|
+
ApiCollection,
|
|
5
|
+
ApiResource,
|
|
6
|
+
ConversationMembershipResource,
|
|
7
|
+
ConversationResource,
|
|
8
|
+
} from '../types'
|
|
9
|
+
import { deleteRecordInPagesData } from '../utils/cache/page_mutations'
|
|
10
|
+
import { Haptic } from '../utils/native_adapters'
|
|
11
|
+
import {
|
|
12
|
+
getConversationsRequestArgs,
|
|
13
|
+
HIDDEN_CONVERSATIONS_FILTER,
|
|
14
|
+
} from '../utils/request/conversation'
|
|
15
|
+
import { showToast } from '../utils/toast_store'
|
|
16
|
+
import { useApiClient } from './use_api_client'
|
|
17
|
+
import { getConversationRequestArgs } from './use_conversation'
|
|
18
|
+
import { getRequestQueryKey } from './use_suspense_api'
|
|
19
|
+
|
|
20
|
+
type ConversationsData = InfiniteData<ApiCollection<ConversationResource>>
|
|
21
|
+
type ListsSnapshot = Array<[QueryKey, ConversationsData | undefined]>
|
|
22
|
+
|
|
23
|
+
export const HIDDEN_TOAST_TITLE = 'Conversation hidden'
|
|
24
|
+
export const HIDDEN_TOAST_SUBTITLE = "It'll come back if someone sends a new message."
|
|
25
|
+
export const HIDDEN_AND_SILENCED_TOAST_SUBTITLE =
|
|
26
|
+
"It's silenced too, so it stays hidden until you unhide it."
|
|
27
|
+
|
|
28
|
+
export const useHideConversation = ({
|
|
29
|
+
conversation,
|
|
30
|
+
hidden: knownHidden,
|
|
31
|
+
}: {
|
|
32
|
+
conversation: ConversationResource
|
|
33
|
+
hidden?: boolean
|
|
34
|
+
}) => {
|
|
35
|
+
const apiClient = useApiClient()
|
|
36
|
+
const queryClient = useQueryClient()
|
|
37
|
+
const listsQueryKey = [getConversationsRequestArgs().url]
|
|
38
|
+
const hiddenListsQueryKey = [...listsQueryKey, { filter: HIDDEN_CONVERSATIONS_FILTER }]
|
|
39
|
+
const conversationQueryKey = getRequestQueryKey(
|
|
40
|
+
getConversationRequestArgs({ conversation_id: conversation.id })
|
|
41
|
+
)
|
|
42
|
+
const hidden = knownHidden ?? !!conversation.conversationMembership?.hidden
|
|
43
|
+
|
|
44
|
+
const setMembershipHidden = (value: boolean) =>
|
|
45
|
+
queryClient.setQueryData<ApiResource<ConversationResource>>(conversationQueryKey, prev => {
|
|
46
|
+
if (!prev?.data) return prev
|
|
47
|
+
|
|
48
|
+
return {
|
|
49
|
+
...prev,
|
|
50
|
+
data: {
|
|
51
|
+
...prev.data,
|
|
52
|
+
conversationMembership: { ...prev.data.conversationMembership, hidden: value },
|
|
53
|
+
},
|
|
54
|
+
}
|
|
55
|
+
})
|
|
56
|
+
|
|
57
|
+
const removeFromLists = (queryKey: QueryKey) =>
|
|
58
|
+
queryClient.setQueriesData<ConversationsData>({ queryKey }, prev => {
|
|
59
|
+
if (!prev?.pages) return prev
|
|
60
|
+
|
|
61
|
+
return deleteRecordInPagesData({ data: prev, record: { id: conversation.id } })
|
|
62
|
+
})
|
|
63
|
+
|
|
64
|
+
const restoreLists = (lists: ListsSnapshot) => {
|
|
65
|
+
lists.forEach(([queryKey, data]) => {
|
|
66
|
+
queryClient.setQueryData<ConversationsData>(queryKey, data)
|
|
67
|
+
})
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
const { mutate: setHidden, ...mutation } = useMutation({
|
|
71
|
+
mutationKey: ['hideConversation', conversation.id],
|
|
72
|
+
scope: { id: `hideConversation-${conversation.id}` },
|
|
73
|
+
onMutate: async (value: boolean) => {
|
|
74
|
+
await queryClient.cancelQueries({ queryKey: listsQueryKey })
|
|
75
|
+
const previousLists = queryClient.getQueriesData<ConversationsData>({
|
|
76
|
+
queryKey: listsQueryKey,
|
|
77
|
+
})
|
|
78
|
+
|
|
79
|
+
removeFromLists(value ? listsQueryKey : hiddenListsQueryKey)
|
|
80
|
+
setMembershipHidden(value)
|
|
81
|
+
|
|
82
|
+
return { previousLists }
|
|
83
|
+
},
|
|
84
|
+
mutationFn: (value: boolean) =>
|
|
85
|
+
apiClient.chat.patch<ApiResource<ConversationMembershipResource>>({
|
|
86
|
+
url: `/me/conversations/${conversation.id}/conversation_membership`,
|
|
87
|
+
data: {
|
|
88
|
+
data: { type: 'ConversationMembership', attributes: { hidden: value } },
|
|
89
|
+
fields: { ConversationMembership: 'hidden' },
|
|
90
|
+
},
|
|
91
|
+
}),
|
|
92
|
+
onSuccess: (_response, value, { previousLists }) => {
|
|
93
|
+
Haptic.notificationSuccess()
|
|
94
|
+
|
|
95
|
+
if (!value) {
|
|
96
|
+
queryClient.invalidateQueries({ queryKey: listsQueryKey })
|
|
97
|
+
return
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
queryClient.invalidateQueries({ queryKey: hiddenListsQueryKey })
|
|
101
|
+
showToast({
|
|
102
|
+
title: HIDDEN_TOAST_TITLE,
|
|
103
|
+
subtitle: conversation.muted ? HIDDEN_AND_SILENCED_TOAST_SUBTITLE : HIDDEN_TOAST_SUBTITLE,
|
|
104
|
+
action: {
|
|
105
|
+
label: 'Undo',
|
|
106
|
+
onPress: () => {
|
|
107
|
+
restoreLists(previousLists)
|
|
108
|
+
setHidden(false)
|
|
109
|
+
},
|
|
110
|
+
},
|
|
111
|
+
})
|
|
112
|
+
},
|
|
113
|
+
onError: (_error, value, context) => {
|
|
114
|
+
if (context) restoreLists(context.previousLists)
|
|
115
|
+
setMembershipHidden(!value)
|
|
116
|
+
Alert.alert(
|
|
117
|
+
'Oops',
|
|
118
|
+
`Couldn't ${value ? 'hide' : 'unhide'} this conversation. Please try again.`
|
|
119
|
+
)
|
|
120
|
+
},
|
|
121
|
+
})
|
|
122
|
+
|
|
123
|
+
return {
|
|
124
|
+
hidden,
|
|
125
|
+
setHidden,
|
|
126
|
+
...mutation,
|
|
127
|
+
}
|
|
128
|
+
}
|
package/src/navigation/index.tsx
CHANGED
|
@@ -27,6 +27,10 @@ import {
|
|
|
27
27
|
MessageReadReceiptsScreen,
|
|
28
28
|
MessageReadReceiptsScreenOptions,
|
|
29
29
|
} from '../screens/conversation/message_read_receipts_screen'
|
|
30
|
+
import {
|
|
31
|
+
ConversationActionsScreen,
|
|
32
|
+
ConversationActionsScreenOptions,
|
|
33
|
+
} from '../screens/conversation_actions_screen'
|
|
30
34
|
import { ConversationDetailsScreen } from '../screens/conversation_details_screen'
|
|
31
35
|
import {
|
|
32
36
|
ConversationFilterReceipientsScreenOptions,
|
|
@@ -342,6 +346,10 @@ export const ChatStack = createNativeStackNavigator({
|
|
|
342
346
|
// Something about sheetAllowedDetents declared inline breaks TS
|
|
343
347
|
options: MessageActionsScreenOptions,
|
|
344
348
|
},
|
|
349
|
+
ConversationActions: {
|
|
350
|
+
screen: ConversationActionsScreen,
|
|
351
|
+
options: ConversationActionsScreenOptions,
|
|
352
|
+
},
|
|
345
353
|
MessageReport: {
|
|
346
354
|
screen: MessageReportScreen,
|
|
347
355
|
options: MessageReportScreenOptions,
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { DefaultTheme, ThemeProvider } from '@react-navigation/native'
|
|
2
|
+
import { fireEvent, render } from '@testing-library/react-native'
|
|
3
|
+
import React from 'react'
|
|
4
|
+
import { SafeAreaProvider } from 'react-native-safe-area-context'
|
|
5
|
+
import type { ConversationResource } from '../../types'
|
|
6
|
+
import { ConversationActionsScreen } from '../conversation_actions_screen'
|
|
7
|
+
|
|
8
|
+
const mockNavigation = { goBack: jest.fn() }
|
|
9
|
+
jest.mock('@react-navigation/native', () => ({
|
|
10
|
+
...jest.requireActual('@react-navigation/native'),
|
|
11
|
+
useNavigation: () => mockNavigation,
|
|
12
|
+
}))
|
|
13
|
+
jest.mock('@react-navigation/elements', () => ({
|
|
14
|
+
...jest.requireActual('@react-navigation/elements'),
|
|
15
|
+
useHeaderHeight: () => 0,
|
|
16
|
+
}))
|
|
17
|
+
|
|
18
|
+
const conversation = { type: 'Conversation', id: 7, title: 'Youth Group' } as ConversationResource
|
|
19
|
+
jest.mock('../../hooks/use_conversation', () => ({
|
|
20
|
+
useConversation: () => ({ data: conversation }),
|
|
21
|
+
}))
|
|
22
|
+
|
|
23
|
+
let mockHidden = false
|
|
24
|
+
const mockSetHidden = jest.fn()
|
|
25
|
+
jest.mock('../../hooks/use_hide_conversation', () => ({
|
|
26
|
+
useHideConversation: () => ({ hidden: mockHidden, setHidden: mockSetHidden, isPending: false }),
|
|
27
|
+
}))
|
|
28
|
+
|
|
29
|
+
let mockHideEnabled = true
|
|
30
|
+
jest.mock('../../hooks/use_hide_conversations_enabled', () => ({
|
|
31
|
+
useHideConversationsEnabled: () => mockHideEnabled,
|
|
32
|
+
}))
|
|
33
|
+
|
|
34
|
+
const safeAreaMetrics = {
|
|
35
|
+
frame: { x: 0, y: 0, width: 390, height: 844 },
|
|
36
|
+
insets: { top: 0, right: 0, bottom: 0, left: 0 },
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const renderScreen = () =>
|
|
40
|
+
render(
|
|
41
|
+
<SafeAreaProvider initialMetrics={safeAreaMetrics}>
|
|
42
|
+
<ThemeProvider value={DefaultTheme}>
|
|
43
|
+
<ConversationActionsScreen route={{ params: { conversation_id: 7 } }} />
|
|
44
|
+
</ThemeProvider>
|
|
45
|
+
</SafeAreaProvider>
|
|
46
|
+
)
|
|
47
|
+
|
|
48
|
+
describe('ConversationActionsScreen', () => {
|
|
49
|
+
beforeEach(() => {
|
|
50
|
+
mockHidden = false
|
|
51
|
+
mockHideEnabled = true
|
|
52
|
+
jest.clearAllMocks()
|
|
53
|
+
})
|
|
54
|
+
|
|
55
|
+
it('offers nothing when the flag is off', () => {
|
|
56
|
+
mockHideEnabled = false
|
|
57
|
+
const { queryByText } = renderScreen()
|
|
58
|
+
|
|
59
|
+
expect(queryByText('Hide conversation')).toBeNull()
|
|
60
|
+
})
|
|
61
|
+
|
|
62
|
+
it('hides the conversation and closes the sheet', () => {
|
|
63
|
+
const { getByText } = renderScreen()
|
|
64
|
+
|
|
65
|
+
fireEvent.press(getByText('Hide conversation'))
|
|
66
|
+
|
|
67
|
+
expect(mockSetHidden).toHaveBeenCalledWith(true)
|
|
68
|
+
expect(mockNavigation.goBack).toHaveBeenCalledTimes(1)
|
|
69
|
+
})
|
|
70
|
+
|
|
71
|
+
it('unhides a hidden conversation', () => {
|
|
72
|
+
mockHidden = true
|
|
73
|
+
const { getByText } = renderScreen()
|
|
74
|
+
|
|
75
|
+
fireEvent.press(getByText('Unhide conversation'))
|
|
76
|
+
|
|
77
|
+
expect(mockSetHidden).toHaveBeenCalledWith(false)
|
|
78
|
+
})
|
|
79
|
+
})
|