@planningcenter/chat-react-native 4.7.0 → 4.7.1-qa-staging.1
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/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/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/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/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__/screens/conversation_filters/components/conversation_filters.test.tsx +6 -0
- 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/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/index.ts +1 -0
- package/src/types/resources/conversation_membership.ts +1 -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
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { useNavigation } from '@react-navigation/native'
|
|
1
2
|
import React, { ReactNode, useCallback, useEffect, useRef, useState } from 'react'
|
|
2
3
|
import {
|
|
3
4
|
AccessibilityActionEvent,
|
|
@@ -17,8 +18,11 @@ import {
|
|
|
17
18
|
useConversationsMarkRead,
|
|
18
19
|
useConversationsMute,
|
|
19
20
|
} from '../../hooks/use_conversations_actions'
|
|
21
|
+
import { useHideConversation } from '../../hooks/use_hide_conversation'
|
|
22
|
+
import { useHideConversationsEnabled } from '../../hooks/use_hide_conversations_enabled'
|
|
20
23
|
import { ConversationResource } from '../../types'
|
|
21
24
|
import { isArchivedConversation, platformPressedOpacityStyle } from '../../utils'
|
|
25
|
+
import { Haptic } from '../../utils/native_adapters'
|
|
22
26
|
import { tokens } from '../../vendor/tapestry/tokens'
|
|
23
27
|
import { SwipeableToggleButton } from './swipeable_toggle_button'
|
|
24
28
|
|
|
@@ -36,8 +40,10 @@ export function ConversationActions({
|
|
|
36
40
|
accessibilityLabel?: string
|
|
37
41
|
}) {
|
|
38
42
|
const swipeableRef = useRef<SwipeableMethods>(null)
|
|
43
|
+
const navigation = useNavigation()
|
|
39
44
|
const styles = useStyles()
|
|
40
|
-
const { activeConversationId, setActiveConversationId } =
|
|
45
|
+
const { activeConversationId, setActiveConversationId, hideable, args } =
|
|
46
|
+
useConversationsContext()
|
|
41
47
|
const [disabled, setDisabled] = useState(false)
|
|
42
48
|
const overshootLeft = Platform.OS === 'ios'
|
|
43
49
|
const androidRippleColor = useCreateAndroidRippleColor({
|
|
@@ -51,9 +57,16 @@ export function ConversationActions({
|
|
|
51
57
|
} = useConversationsMarkRead({
|
|
52
58
|
conversation,
|
|
53
59
|
})
|
|
60
|
+
const {
|
|
61
|
+
hidden,
|
|
62
|
+
setHidden,
|
|
63
|
+
isPending: isHiddenPending,
|
|
64
|
+
} = useHideConversation({ conversation, hidden: args.show_hidden || undefined })
|
|
65
|
+
const hideConversationsEnabled = useHideConversationsEnabled()
|
|
54
66
|
|
|
55
67
|
const isConversationEmpty = conversation.lastMessageCreatedAt === null
|
|
56
68
|
const canMute = !isArchivedConversation(conversation)
|
|
69
|
+
const canHide = hideable && hideConversationsEnabled && !isArchivedConversation(conversation)
|
|
57
70
|
|
|
58
71
|
const handleSwipeableClose = useCallback(() => {
|
|
59
72
|
setDisabled(false)
|
|
@@ -75,6 +88,18 @@ export function ConversationActions({
|
|
|
75
88
|
handleSwipeableClose()
|
|
76
89
|
}, [muted, handleSwipeableClose, setMuted])
|
|
77
90
|
|
|
91
|
+
const handleHide = useCallback(() => {
|
|
92
|
+
setHidden(!hidden)
|
|
93
|
+
handleSwipeableClose()
|
|
94
|
+
}, [hidden, handleSwipeableClose, setHidden])
|
|
95
|
+
|
|
96
|
+
const handleLongPress = useCallback(() => {
|
|
97
|
+
if (disabled) return
|
|
98
|
+
|
|
99
|
+
Haptic.impactLight()
|
|
100
|
+
navigation.navigate('ConversationActions', { conversation_id: conversation.id })
|
|
101
|
+
}, [disabled, navigation, conversation.id])
|
|
102
|
+
|
|
78
103
|
const handleLatestMessageUnread = useCallback(() => {
|
|
79
104
|
markRead(!read)
|
|
80
105
|
handleSwipeableClose()
|
|
@@ -98,7 +123,20 @@ export function ConversationActions({
|
|
|
98
123
|
]
|
|
99
124
|
: []
|
|
100
125
|
|
|
101
|
-
const
|
|
126
|
+
const hideAccessibilityAction = canHide
|
|
127
|
+
? [
|
|
128
|
+
{
|
|
129
|
+
name: hidden ? 'unhide' : 'hide',
|
|
130
|
+
label: hidden ? 'Unhide' : 'Hide',
|
|
131
|
+
},
|
|
132
|
+
]
|
|
133
|
+
: []
|
|
134
|
+
|
|
135
|
+
const accessibilityActions = [
|
|
136
|
+
...muteAccessibilityAction,
|
|
137
|
+
...hideAccessibilityAction,
|
|
138
|
+
...readAccessibilityAction,
|
|
139
|
+
]
|
|
102
140
|
|
|
103
141
|
const handleAccessibilityAction = useCallback(
|
|
104
142
|
(event: AccessibilityActionEvent) => {
|
|
@@ -115,9 +153,13 @@ export function ConversationActions({
|
|
|
115
153
|
case 'unmute':
|
|
116
154
|
handleMute()
|
|
117
155
|
break
|
|
156
|
+
case 'hide':
|
|
157
|
+
case 'unhide':
|
|
158
|
+
handleHide()
|
|
159
|
+
break
|
|
118
160
|
}
|
|
119
161
|
},
|
|
120
|
-
[handleLatestMessageUnread, handleMute]
|
|
162
|
+
[handleLatestMessageUnread, handleMute, handleHide]
|
|
121
163
|
)
|
|
122
164
|
|
|
123
165
|
useEffect(() => {
|
|
@@ -141,11 +183,15 @@ export function ConversationActions({
|
|
|
141
183
|
<LeftActions
|
|
142
184
|
isConversationEmpty={isConversationEmpty}
|
|
143
185
|
canMute={canMute}
|
|
186
|
+
canHide={canHide}
|
|
144
187
|
handleMute={handleMute}
|
|
188
|
+
handleHide={handleHide}
|
|
145
189
|
handleLatestMessageUnread={handleLatestMessageUnread}
|
|
146
190
|
muted={muted}
|
|
191
|
+
hidden={hidden}
|
|
147
192
|
read={read}
|
|
148
193
|
isMutedPending={isMutedPending}
|
|
194
|
+
isHiddenPending={isHiddenPending}
|
|
149
195
|
isMarkReadPending={isMarkReadPending}
|
|
150
196
|
/>
|
|
151
197
|
)}
|
|
@@ -153,6 +199,7 @@ export function ConversationActions({
|
|
|
153
199
|
<Pressable
|
|
154
200
|
testID={`conversation-${conversation.id}`}
|
|
155
201
|
onPress={handlePress}
|
|
202
|
+
onLongPress={canHide ? handleLongPress : undefined}
|
|
156
203
|
style={({ pressed }) => [style, pressed && platformPressedOpacityStyle]}
|
|
157
204
|
android_ripple={{ color: androidRippleColor, borderless: false, foreground: true }}
|
|
158
205
|
accessibilityLabel={accessibilityLabel}
|
|
@@ -169,31 +216,44 @@ export function ConversationActions({
|
|
|
169
216
|
interface LeftActionsProps {
|
|
170
217
|
isConversationEmpty: boolean
|
|
171
218
|
canMute: boolean
|
|
219
|
+
canHide: boolean
|
|
172
220
|
handleMute: () => void
|
|
221
|
+
handleHide: () => void
|
|
173
222
|
handleLatestMessageUnread: () => void
|
|
174
223
|
muted: boolean
|
|
224
|
+
hidden: boolean
|
|
175
225
|
read: boolean
|
|
176
226
|
isMutedPending: boolean
|
|
227
|
+
isHiddenPending: boolean
|
|
177
228
|
isMarkReadPending: boolean
|
|
178
229
|
}
|
|
179
230
|
|
|
180
231
|
function LeftActions({
|
|
181
232
|
isConversationEmpty,
|
|
182
233
|
canMute,
|
|
234
|
+
canHide,
|
|
183
235
|
handleMute,
|
|
236
|
+
handleHide,
|
|
184
237
|
handleLatestMessageUnread,
|
|
185
238
|
muted,
|
|
239
|
+
hidden,
|
|
186
240
|
read,
|
|
187
241
|
isMutedPending,
|
|
242
|
+
isHiddenPending,
|
|
188
243
|
isMarkReadPending,
|
|
189
244
|
}: LeftActionsProps) {
|
|
190
|
-
const styles = useStyles({ actionButtonCount:
|
|
245
|
+
const styles = useStyles({ actionButtonCount: 1 + Number(canMute) + Number(canHide) })
|
|
191
246
|
|
|
192
247
|
const muteToggleContent = {
|
|
193
248
|
true: { iconName: 'general.bell', label: 'Enable' },
|
|
194
249
|
false: { iconName: 'general.bellMuted', label: 'Silence' },
|
|
195
250
|
} as const
|
|
196
251
|
|
|
252
|
+
const hideToggleContent = {
|
|
253
|
+
true: { iconName: 'general.showEye', label: 'Unhide' },
|
|
254
|
+
false: { iconName: 'general.hideEye', label: 'Hide' },
|
|
255
|
+
} as const
|
|
256
|
+
|
|
197
257
|
const latestMessageUnreadToggleContent = {
|
|
198
258
|
true: { iconName: 'general.outlinedTextMessage', label: 'Mark read' },
|
|
199
259
|
false: { iconName: 'general.textMessageNotifications', label: 'Mark unread' },
|
|
@@ -218,6 +278,15 @@ function LeftActions({
|
|
|
218
278
|
backgroundColor={tokens.fillColorInteractionSwipeSecondary}
|
|
219
279
|
/>
|
|
220
280
|
)}
|
|
281
|
+
{canHide && (
|
|
282
|
+
<SwipeableToggleButton
|
|
283
|
+
loading={isHiddenPending}
|
|
284
|
+
toggled={hidden}
|
|
285
|
+
onPress={handleHide}
|
|
286
|
+
toggleContent={hideToggleContent}
|
|
287
|
+
backgroundColor={tokens.colorNeutral45}
|
|
288
|
+
/>
|
|
289
|
+
)}
|
|
221
290
|
</View>
|
|
222
291
|
)
|
|
223
292
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import React from 'react'
|
|
2
2
|
import { StyleSheet, View, ViewStyle } from 'react-native'
|
|
3
|
+
import { useConversationsContext } from '../../contexts/conversations_context'
|
|
3
4
|
import {
|
|
4
5
|
useTheme,
|
|
5
6
|
useAtFontScaleBreakpoint,
|
|
@@ -21,6 +22,7 @@ import {
|
|
|
21
22
|
type BadgeProps,
|
|
22
23
|
} from '../display'
|
|
23
24
|
import { ConversationActions } from './conversation_actions'
|
|
25
|
+
import { HiddenIndicator } from './hidden_indicator'
|
|
24
26
|
import { MuteIndicator } from './mute_indicator'
|
|
25
27
|
import { UnreadCountBadge } from './unread_count_badge'
|
|
26
28
|
|
|
@@ -40,6 +42,9 @@ export const ConversationPreview = ({
|
|
|
40
42
|
style,
|
|
41
43
|
}: ConversationPreviewProps) => {
|
|
42
44
|
const styles = useStyles()
|
|
45
|
+
const {
|
|
46
|
+
args: { show_hidden: hidden = false },
|
|
47
|
+
} = useConversationsContext()
|
|
43
48
|
const {
|
|
44
49
|
conversationPreview,
|
|
45
50
|
lastMessageCreatedAt,
|
|
@@ -54,7 +59,7 @@ export const ConversationPreview = ({
|
|
|
54
59
|
const archived = isArchivedConversation(conversation)
|
|
55
60
|
const emptyConversation = !lastMessageCreatedAt
|
|
56
61
|
const fallbackIconName = emptyConversation ? 'people.noTextMessage' : 'general.person'
|
|
57
|
-
const hasMetaContent = lastMessageCreatedAt || unreadCount > 0 || muted
|
|
62
|
+
const hasMetaContent = lastMessageCreatedAt || unreadCount > 0 || muted || hidden
|
|
58
63
|
const isUnread = unreadCount > 0 || unreadReaction
|
|
59
64
|
|
|
60
65
|
const numberOfLinesScaledTitle = useScalableNumberOfLines(1)
|
|
@@ -68,6 +73,7 @@ export const ConversationPreview = ({
|
|
|
68
73
|
conversation,
|
|
69
74
|
showBadges,
|
|
70
75
|
archived,
|
|
76
|
+
hidden,
|
|
71
77
|
})
|
|
72
78
|
|
|
73
79
|
return (
|
|
@@ -117,6 +123,7 @@ export const ConversationPreview = ({
|
|
|
117
123
|
<View style={styles.statusContainer}>
|
|
118
124
|
<UnreadCountBadge count={unreadCount} unreadReaction={unreadReaction} showDot={muted} />
|
|
119
125
|
<MuteIndicator muted={muted} />
|
|
126
|
+
<HiddenIndicator hidden={hidden} />
|
|
120
127
|
</View>
|
|
121
128
|
</View>
|
|
122
129
|
)}
|
|
@@ -214,11 +221,13 @@ interface GetConversationAccessibilityLabelProps {
|
|
|
214
221
|
conversation: ConversationResource
|
|
215
222
|
showBadges: boolean
|
|
216
223
|
archived: boolean
|
|
224
|
+
hidden: boolean
|
|
217
225
|
}
|
|
218
226
|
const getConversationAccessibilityLabel = ({
|
|
219
227
|
conversation,
|
|
220
228
|
showBadges,
|
|
221
229
|
archived,
|
|
230
|
+
hidden,
|
|
222
231
|
}: GetConversationAccessibilityLabelProps) => {
|
|
223
232
|
const { badges, title, conversationPreview, muted, disabled, unreadCount, unreadReaction } =
|
|
224
233
|
conversation
|
|
@@ -231,6 +240,7 @@ const getConversationAccessibilityLabel = ({
|
|
|
231
240
|
badge: hasBadges ? `for ${badges[0]?.pcoResourceType} ${badges[0]?.text || ''}` : '',
|
|
232
241
|
disabled: archived ? 'Archived' : disabled ? 'Disabled' : '',
|
|
233
242
|
muted: muted ? 'Muted' : '',
|
|
243
|
+
hidden: hidden ? 'Hidden' : '',
|
|
234
244
|
readStatus: hasUnreadMessages
|
|
235
245
|
? `${unreadCount} unread messages`
|
|
236
246
|
: unreadReaction
|
|
@@ -246,6 +256,7 @@ const getConversationAccessibilityLabel = ({
|
|
|
246
256
|
label.badge,
|
|
247
257
|
label.disabled,
|
|
248
258
|
label.muted,
|
|
259
|
+
label.hidden,
|
|
249
260
|
label.readStatus,
|
|
250
261
|
label.lastMessage,
|
|
251
262
|
]
|
|
@@ -12,6 +12,7 @@ import { ArchivedResultsFooter } from './archived_results_footer'
|
|
|
12
12
|
import { ConversationPreview, ConversationPreviewSkeleton } from './conversation_preview'
|
|
13
13
|
import { ConversationsBlankState } from './conversations_blank_state'
|
|
14
14
|
import { FilteredResultsFooter } from './filtered_results_footer'
|
|
15
|
+
import { HiddenResultsFooter } from './hidden_results_footer'
|
|
15
16
|
|
|
16
17
|
interface ConversationsProps {
|
|
17
18
|
ListHeaderComponent?:
|
|
@@ -36,6 +37,7 @@ export const Conversations = ({ ListHeaderComponent }: ConversationsProps) => {
|
|
|
36
37
|
group_source_app_name,
|
|
37
38
|
show_direct_messages,
|
|
38
39
|
show_archived,
|
|
40
|
+
show_hidden,
|
|
39
41
|
show_unread,
|
|
40
42
|
},
|
|
41
43
|
} = useConversationsContext()
|
|
@@ -48,12 +50,16 @@ export const Conversations = ({ ListHeaderComponent }: ConversationsProps) => {
|
|
|
48
50
|
!!group_source_app_name ||
|
|
49
51
|
!!show_direct_messages ||
|
|
50
52
|
!!show_archived ||
|
|
53
|
+
!!show_hidden ||
|
|
51
54
|
!!show_unread
|
|
52
55
|
const showArchivedResultsFooter = !!show_archived && !isLoading && !hasNextPage
|
|
56
|
+
const showHiddenResultsFooter =
|
|
57
|
+
!!show_hidden && !isLoading && !hasNextPage && conversations.length > 0
|
|
53
58
|
const showFilteredResultsFooter =
|
|
54
59
|
filterDropdownEnabled &&
|
|
55
60
|
isFilterApplied &&
|
|
56
61
|
!show_archived &&
|
|
62
|
+
!show_hidden &&
|
|
57
63
|
!hasNextPage &&
|
|
58
64
|
!isLoading &&
|
|
59
65
|
conversations.length > 0
|
|
@@ -86,12 +92,15 @@ export const Conversations = ({ ListHeaderComponent }: ConversationsProps) => {
|
|
|
86
92
|
ListEmptyComponent={
|
|
87
93
|
<ConversationsBlankState
|
|
88
94
|
isFilterApplied={isFilterApplied}
|
|
95
|
+
isHiddenFilterApplied={!!show_hidden}
|
|
89
96
|
canCreateConversations={canCreateConversations}
|
|
90
97
|
/>
|
|
91
98
|
}
|
|
92
99
|
ListFooterComponent={
|
|
93
100
|
showArchivedResultsFooter ? (
|
|
94
101
|
<ArchivedResultsFooter onViewActiveConversations={clearFilters} />
|
|
102
|
+
) : showHiddenResultsFooter ? (
|
|
103
|
+
<HiddenResultsFooter />
|
|
95
104
|
) : showFilteredResultsFooter ? (
|
|
96
105
|
<FilteredResultsFooter />
|
|
97
106
|
) : null
|
|
@@ -6,16 +6,34 @@ import BlankState from '../primitive/blank_state_primitive'
|
|
|
6
6
|
|
|
7
7
|
interface ConversationsBlankStateProps {
|
|
8
8
|
isFilterApplied: boolean
|
|
9
|
+
isHiddenFilterApplied?: boolean
|
|
9
10
|
canCreateConversations: boolean
|
|
10
11
|
}
|
|
11
12
|
|
|
12
13
|
export function ConversationsBlankState({
|
|
13
14
|
isFilterApplied,
|
|
15
|
+
isHiddenFilterApplied = false,
|
|
14
16
|
canCreateConversations,
|
|
15
17
|
}: ConversationsBlankStateProps) {
|
|
16
18
|
const filterDropdownEnabled = useFilterDropdownEnabled()
|
|
17
19
|
const clearFilters = useClearConversationFilters()
|
|
18
20
|
|
|
21
|
+
if (isHiddenFilterApplied) {
|
|
22
|
+
return (
|
|
23
|
+
<View style={styles.container}>
|
|
24
|
+
<BlankState.Root>
|
|
25
|
+
<BlankState.Imagery name="general.hideEye" />
|
|
26
|
+
<BlankState.Content>
|
|
27
|
+
<BlankState.Heading>No hidden conversations</BlankState.Heading>
|
|
28
|
+
<BlankState.Text>
|
|
29
|
+
Swipe left on a conversation to hide it from your list.
|
|
30
|
+
</BlankState.Text>
|
|
31
|
+
</BlankState.Content>
|
|
32
|
+
</BlankState.Root>
|
|
33
|
+
</View>
|
|
34
|
+
)
|
|
35
|
+
}
|
|
36
|
+
|
|
19
37
|
if (filterDropdownEnabled && isFilterApplied) {
|
|
20
38
|
return (
|
|
21
39
|
<View style={styles.container}>
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import { StyleSheet } from 'react-native'
|
|
3
|
+
import { useTheme } from '../../hooks'
|
|
4
|
+
import { MAX_FONT_SIZE_MULTIPLIER } from '../../utils'
|
|
5
|
+
import { Icon } from '../display'
|
|
6
|
+
|
|
7
|
+
export const HiddenIndicator = ({ hidden }: { hidden: boolean }) => {
|
|
8
|
+
const styles = useStyles()
|
|
9
|
+
|
|
10
|
+
if (!hidden) return null
|
|
11
|
+
|
|
12
|
+
return (
|
|
13
|
+
<Icon
|
|
14
|
+
name="general.hideEye"
|
|
15
|
+
style={styles.hiddenIcon}
|
|
16
|
+
testID="conversation-hidden-icon"
|
|
17
|
+
maxFontSizeMultiplier={MAX_FONT_SIZE_MULTIPLIER}
|
|
18
|
+
/>
|
|
19
|
+
)
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const useStyles = () => {
|
|
23
|
+
const { colors } = useTheme()
|
|
24
|
+
return StyleSheet.create({
|
|
25
|
+
hiddenIcon: {
|
|
26
|
+
color: colors.iconColorDefaultDim,
|
|
27
|
+
fontSize: 16,
|
|
28
|
+
},
|
|
29
|
+
})
|
|
30
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import { StyleSheet, View } from 'react-native'
|
|
3
|
+
import { Text } from '../display'
|
|
4
|
+
|
|
5
|
+
export function HiddenResultsFooter() {
|
|
6
|
+
return (
|
|
7
|
+
<View style={styles.container}>
|
|
8
|
+
<Text variant="tertiary" style={styles.text}>
|
|
9
|
+
Hidden just for you. A conversation comes back to your list when someone sends a new
|
|
10
|
+
message, unless it’s also silenced.
|
|
11
|
+
</Text>
|
|
12
|
+
</View>
|
|
13
|
+
)
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const styles = StyleSheet.create({
|
|
17
|
+
container: {
|
|
18
|
+
alignItems: 'center',
|
|
19
|
+
paddingVertical: 24,
|
|
20
|
+
paddingHorizontal: 16,
|
|
21
|
+
},
|
|
22
|
+
text: {
|
|
23
|
+
textAlign: 'center',
|
|
24
|
+
},
|
|
25
|
+
})
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { act, fireEvent, render } from '@testing-library/react-native'
|
|
2
|
+
import React from 'react'
|
|
3
|
+
import { SafeAreaProvider } from 'react-native-safe-area-context'
|
|
4
|
+
import { dismissToast, showToast } from '../../../utils/toast_store'
|
|
5
|
+
import { Toast, TOAST_DURATION_MS } from '../toast'
|
|
6
|
+
|
|
7
|
+
const safeAreaMetrics = {
|
|
8
|
+
frame: { x: 0, y: 0, width: 390, height: 844 },
|
|
9
|
+
insets: { top: 0, right: 0, bottom: 0, left: 0 },
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
const renderToast = () =>
|
|
13
|
+
render(
|
|
14
|
+
<SafeAreaProvider initialMetrics={safeAreaMetrics}>
|
|
15
|
+
<Toast />
|
|
16
|
+
</SafeAreaProvider>
|
|
17
|
+
)
|
|
18
|
+
|
|
19
|
+
describe('Toast', () => {
|
|
20
|
+
beforeEach(() => {
|
|
21
|
+
jest.useFakeTimers()
|
|
22
|
+
dismissToast()
|
|
23
|
+
})
|
|
24
|
+
|
|
25
|
+
afterEach(() => {
|
|
26
|
+
jest.useRealTimers()
|
|
27
|
+
})
|
|
28
|
+
|
|
29
|
+
it('runs the action and dismisses when the action is pressed', () => {
|
|
30
|
+
const onUndo = jest.fn()
|
|
31
|
+
const view = renderToast()
|
|
32
|
+
act(() =>
|
|
33
|
+
showToast({
|
|
34
|
+
title: 'Conversation hidden',
|
|
35
|
+
subtitle: 'Subtitle',
|
|
36
|
+
action: { label: 'Undo', onPress: onUndo },
|
|
37
|
+
})
|
|
38
|
+
)
|
|
39
|
+
|
|
40
|
+
expect(view.getByText('Subtitle')).toBeTruthy()
|
|
41
|
+
fireEvent.press(view.getByText('Undo'))
|
|
42
|
+
|
|
43
|
+
expect(onUndo).toHaveBeenCalledTimes(1)
|
|
44
|
+
expect(view.queryByText('Conversation hidden')).toBeNull()
|
|
45
|
+
})
|
|
46
|
+
|
|
47
|
+
it('dismisses itself after a delay', () => {
|
|
48
|
+
const view = renderToast()
|
|
49
|
+
act(() => showToast({ title: 'Conversation hidden' }))
|
|
50
|
+
|
|
51
|
+
act(() => jest.advanceTimersByTime(TOAST_DURATION_MS))
|
|
52
|
+
|
|
53
|
+
expect(view.queryByText('Conversation hidden')).toBeNull()
|
|
54
|
+
})
|
|
55
|
+
})
|
|
@@ -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>
|