@planningcenter/chat-react-native 4.8.0-rc.9 → 4.8.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/message_form.d.ts.map +1 -1
- package/build/components/conversation/message_form.js +31 -25
- package/build/components/conversation/message_form.js.map +1 -1
- package/build/components/conversations/app_update_banner.d.ts +2 -0
- package/build/components/conversations/app_update_banner.d.ts.map +1 -0
- package/build/components/conversations/app_update_banner.js +52 -0
- package/build/components/conversations/app_update_banner.js.map +1 -0
- package/build/components/conversations/bulk_conversation_actions_bar.d.ts +2 -0
- package/build/components/conversations/bulk_conversation_actions_bar.d.ts.map +1 -0
- package/build/components/conversations/bulk_conversation_actions_bar.js +215 -0
- package/build/components/conversations/bulk_conversation_actions_bar.js.map +1 -0
- package/build/components/conversations/conversation_actions.d.ts.map +1 -1
- package/build/components/conversations/conversation_actions.js +202 -161
- 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 +129 -115
- package/build/components/conversations/conversation_preview.js.map +1 -1
- package/build/components/conversations/swipeable_toggle_button.d.ts +5 -1
- package/build/components/conversations/swipeable_toggle_button.d.ts.map +1 -1
- package/build/components/conversations/swipeable_toggle_button.js +96 -67
- package/build/components/conversations/swipeable_toggle_button.js.map +1 -1
- package/build/components/display/icon.d.ts +3 -1
- package/build/components/display/icon.d.ts.map +1 -1
- package/build/components/display/icon.js +2 -0
- package/build/components/display/icon.js.map +1 -1
- package/build/components/primitive/banner_primitive.js +7 -3
- package/build/components/primitive/banner_primitive.js.map +1 -1
- package/build/screens/conversation_actions_screen.d.ts +2 -0
- package/build/screens/conversation_actions_screen.d.ts.map +1 -1
- package/build/screens/conversation_actions_screen.js +380 -46
- package/build/screens/conversation_actions_screen.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 +105 -33
- package/build/screens/conversations/conversations_screen.js.map +1 -1
- package/build/utils/theme.js +20 -21
- package/build/utils/theme.js.map +1 -1
- package/package.json +2 -2
- package/src/components/conversation/__tests__/message_form.test.tsx +19 -2
- package/src/components/conversation/message_form.tsx +15 -2
- package/src/components/conversations/__tests__/app_update_banner.test.tsx +27 -0
- package/src/components/conversations/__tests__/bulk_conversation_actions_bar.test.tsx +95 -0
- package/src/components/conversations/__tests__/conversation_actions.test.tsx +10 -3
- package/src/components/conversations/app_update_banner.tsx +36 -0
- package/src/components/conversations/bulk_conversation_actions_bar.tsx +140 -0
- package/src/components/conversations/conversation_actions.tsx +51 -34
- package/src/components/conversations/conversation_preview.tsx +8 -1
- package/src/components/conversations/swipeable_toggle_button.tsx +45 -16
- package/src/components/display/icon.tsx +3 -0
- package/src/components/primitive/banner_primitive.tsx +5 -1
- package/src/screens/__tests__/conversation_actions_screen.test.tsx +48 -6
- package/src/screens/conversation_actions_screen.tsx +145 -12
- package/src/screens/conversations/__tests__/conversations_screen.test.tsx +34 -8
- package/src/screens/conversations/conversations_screen.tsx +28 -2
- package/src/utils/theme.ts +20 -21
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { DefaultTheme, ThemeProvider } from '@react-navigation/native'
|
|
1
|
+
import { DefaultTheme, StackActions, ThemeProvider } from '@react-navigation/native'
|
|
2
2
|
import { fireEvent, render } from '@testing-library/react-native'
|
|
3
3
|
import React from 'react'
|
|
4
4
|
import { SafeAreaProvider } from 'react-native-safe-area-context'
|
|
5
5
|
import type { ConversationResource } from '../../types'
|
|
6
6
|
import { ConversationActionsScreen } from '../conversation_actions_screen'
|
|
7
7
|
|
|
8
|
-
const mockNavigation = { goBack: jest.fn() }
|
|
8
|
+
const mockNavigation = { goBack: jest.fn(), dispatch: jest.fn(), navigate: jest.fn() }
|
|
9
9
|
jest.mock('@react-navigation/native', () => ({
|
|
10
10
|
...jest.requireActual('@react-navigation/native'),
|
|
11
11
|
useNavigation: () => mockNavigation,
|
|
@@ -15,9 +15,20 @@ jest.mock('@react-navigation/elements', () => ({
|
|
|
15
15
|
useHeaderHeight: () => 0,
|
|
16
16
|
}))
|
|
17
17
|
|
|
18
|
-
|
|
18
|
+
let mockConversation = { type: 'Conversation', id: 7, title: 'Youth Group' } as ConversationResource
|
|
19
|
+
const mockSetMuted = jest.fn()
|
|
19
20
|
jest.mock('../../hooks/use_conversation', () => ({
|
|
20
|
-
useConversation: () => ({ data:
|
|
21
|
+
useConversation: () => ({ data: mockConversation }),
|
|
22
|
+
useConversationMute: () => ({ muted: false, setMuted: mockSetMuted, isPending: false }),
|
|
23
|
+
}))
|
|
24
|
+
|
|
25
|
+
const mockMarkRead = jest.fn()
|
|
26
|
+
jest.mock('../../hooks/use_conversations_actions', () => ({
|
|
27
|
+
useConversationsMarkRead: () => ({ read: true, markRead: mockMarkRead, isPending: false }),
|
|
28
|
+
}))
|
|
29
|
+
jest.mock('../../components/display', () => ({
|
|
30
|
+
...jest.requireActual('../../components/display'),
|
|
31
|
+
ConversationAvatar: () => null,
|
|
21
32
|
}))
|
|
22
33
|
|
|
23
34
|
let mockHidden = false
|
|
@@ -36,11 +47,11 @@ const safeAreaMetrics = {
|
|
|
36
47
|
insets: { top: 0, right: 0, bottom: 0, left: 0 },
|
|
37
48
|
}
|
|
38
49
|
|
|
39
|
-
const renderScreen = () =>
|
|
50
|
+
const renderScreen = (params: { read?: boolean; muted?: boolean } = {}) =>
|
|
40
51
|
render(
|
|
41
52
|
<SafeAreaProvider initialMetrics={safeAreaMetrics}>
|
|
42
53
|
<ThemeProvider value={DefaultTheme}>
|
|
43
|
-
<ConversationActionsScreen route={{ params: { conversation_id: 7 } }} />
|
|
54
|
+
<ConversationActionsScreen route={{ params: { conversation_id: 7, ...params } }} />
|
|
44
55
|
</ThemeProvider>
|
|
45
56
|
</SafeAreaProvider>
|
|
46
57
|
)
|
|
@@ -49,6 +60,7 @@ describe('ConversationActionsScreen', () => {
|
|
|
49
60
|
beforeEach(() => {
|
|
50
61
|
mockHidden = false
|
|
51
62
|
mockHideEnabled = true
|
|
63
|
+
mockConversation = { type: 'Conversation', id: 7, title: 'Youth Group' } as ConversationResource
|
|
52
64
|
jest.clearAllMocks()
|
|
53
65
|
})
|
|
54
66
|
|
|
@@ -57,6 +69,17 @@ describe('ConversationActionsScreen', () => {
|
|
|
57
69
|
const { queryByText } = renderScreen()
|
|
58
70
|
|
|
59
71
|
expect(queryByText('Hide conversation')).toBeNull()
|
|
72
|
+
expect(queryByText('Select conversations')).toBeNull()
|
|
73
|
+
})
|
|
74
|
+
|
|
75
|
+
it('asks the conversation list to enter select mode with this conversation', () => {
|
|
76
|
+
const { getByText } = renderScreen()
|
|
77
|
+
|
|
78
|
+
fireEvent.press(getByText('Select conversations'))
|
|
79
|
+
|
|
80
|
+
expect(mockNavigation.dispatch).toHaveBeenCalledWith(
|
|
81
|
+
StackActions.popTo('Conversations', { select_conversation_id: 7 }, { merge: true })
|
|
82
|
+
)
|
|
60
83
|
})
|
|
61
84
|
|
|
62
85
|
it('hides the conversation and closes the sheet', () => {
|
|
@@ -76,4 +99,23 @@ describe('ConversationActionsScreen', () => {
|
|
|
76
99
|
|
|
77
100
|
expect(mockSetHidden).toHaveBeenCalledWith(false)
|
|
78
101
|
})
|
|
102
|
+
|
|
103
|
+
it('toggles read and silenced from the state the list row passed in', () => {
|
|
104
|
+
const { getByText } = renderScreen({ read: false, muted: true })
|
|
105
|
+
|
|
106
|
+
fireEvent.press(getByText('Mark as read'))
|
|
107
|
+
fireEvent.press(getByText('Enable'))
|
|
108
|
+
|
|
109
|
+
expect(mockMarkRead).toHaveBeenCalledWith(true)
|
|
110
|
+
expect(mockSetMuted).toHaveBeenCalledWith(false)
|
|
111
|
+
})
|
|
112
|
+
|
|
113
|
+
it('offers neither silence nor hide on an archived conversation', () => {
|
|
114
|
+
mockConversation = { ...mockConversation, disabled: true, disabledReason: 'archived' }
|
|
115
|
+
const { queryByText, getByText } = renderScreen()
|
|
116
|
+
|
|
117
|
+
expect(queryByText('Silence')).toBeNull()
|
|
118
|
+
expect(queryByText('Hide conversation')).toBeNull()
|
|
119
|
+
expect(getByText('Select conversations')).toBeTruthy()
|
|
120
|
+
})
|
|
79
121
|
})
|
|
@@ -1,39 +1,150 @@
|
|
|
1
|
-
import { StaticScreenProps, useNavigation } from '@react-navigation/native'
|
|
1
|
+
import { StackActions, StaticScreenProps, useNavigation } from '@react-navigation/native'
|
|
2
2
|
import React from 'react'
|
|
3
|
-
import { StyleSheet } from 'react-native'
|
|
3
|
+
import { StyleSheet, View } from 'react-native'
|
|
4
|
+
import { ConversationAvatar, Heading, Text } from '../components/display'
|
|
4
5
|
import FormSheet, { getFormSheetScreenOptions } from '../components/primitive/form_sheet'
|
|
5
|
-
import {
|
|
6
|
+
import { useTheme } from '../hooks'
|
|
7
|
+
import { useConversation, useConversationMute } from '../hooks/use_conversation'
|
|
8
|
+
import { useConversationsMarkRead } from '../hooks/use_conversations_actions'
|
|
6
9
|
import { useHideConversation } from '../hooks/use_hide_conversation'
|
|
7
10
|
import { useHideConversationsEnabled } from '../hooks/use_hide_conversations_enabled'
|
|
11
|
+
import { isArchivedConversation, MAX_FONT_SIZE_MULTIPLIER_LANDMARK } from '../utils'
|
|
8
12
|
|
|
9
13
|
export const ConversationActionsScreenOptions = getFormSheetScreenOptions({
|
|
10
14
|
headerTitle: 'Conversation actions',
|
|
15
|
+
sheetAllowedDetents: 'fitToContents',
|
|
11
16
|
})
|
|
12
17
|
|
|
13
18
|
export type ConversationActionsScreenProps = StaticScreenProps<{
|
|
14
19
|
conversation_id: number
|
|
20
|
+
read?: boolean
|
|
21
|
+
muted?: boolean
|
|
15
22
|
}>
|
|
16
23
|
|
|
17
24
|
export function ConversationActionsScreen({ route }: ConversationActionsScreenProps) {
|
|
18
25
|
const navigation = useNavigation()
|
|
19
26
|
const styles = useStyles()
|
|
20
|
-
const {
|
|
21
|
-
const {
|
|
27
|
+
const { conversation_id } = route.params
|
|
28
|
+
const { data: conversation } = useConversation({ conversation_id })
|
|
29
|
+
const { hidden, setHidden, isPending: isHiddenPending } = useHideConversation({ conversation })
|
|
30
|
+
const markReadState = useConversationsMarkRead({ conversation })
|
|
31
|
+
const muteState = useConversationMute({ conversation_id })
|
|
22
32
|
const hideConversationsEnabled = useHideConversationsEnabled()
|
|
23
33
|
|
|
34
|
+
const read = route.params.read ?? markReadState.read
|
|
35
|
+
const muted = route.params.muted ?? muteState.muted
|
|
36
|
+
const archived = isArchivedConversation(conversation)
|
|
37
|
+
const emptyConversation = conversation.lastMessageCreatedAt === null
|
|
38
|
+
const subtitle = conversation.badges?.[0]?.text
|
|
39
|
+
|
|
40
|
+
const navigateAfterDismiss = (navigate: () => void) => {
|
|
41
|
+
navigation.goBack()
|
|
42
|
+
requestAnimationFrame(navigate)
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const handleOpenPress = () =>
|
|
46
|
+
navigateAfterDismiss(() =>
|
|
47
|
+
navigation.navigate('Conversation', {
|
|
48
|
+
conversation_id,
|
|
49
|
+
title: conversation.title ?? undefined,
|
|
50
|
+
badge: conversation.badges?.[0],
|
|
51
|
+
deleted: conversation.deleted,
|
|
52
|
+
muted,
|
|
53
|
+
})
|
|
54
|
+
)
|
|
55
|
+
|
|
56
|
+
const handleDetailsPress = () =>
|
|
57
|
+
navigateAfterDismiss(() => navigation.navigate('ConversationDetails', { conversation_id }))
|
|
58
|
+
|
|
59
|
+
const handleMarkReadPress = () => {
|
|
60
|
+
markReadState.markRead(!read)
|
|
61
|
+
navigation.goBack()
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
const handleMutePress = () => {
|
|
65
|
+
muteState.setMuted(!muted)
|
|
66
|
+
navigation.goBack()
|
|
67
|
+
}
|
|
68
|
+
|
|
24
69
|
const handleHidePress = () => {
|
|
25
70
|
setHidden(!hidden)
|
|
26
71
|
navigation.goBack()
|
|
27
72
|
}
|
|
28
73
|
|
|
74
|
+
const handleSelectPress = () => {
|
|
75
|
+
navigation.dispatch(
|
|
76
|
+
StackActions.popTo(
|
|
77
|
+
'Conversations',
|
|
78
|
+
{ select_conversation_id: conversation_id },
|
|
79
|
+
{ merge: true }
|
|
80
|
+
)
|
|
81
|
+
)
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
if (!hideConversationsEnabled) return <FormSheet.Root fitToContents>{null}</FormSheet.Root>
|
|
85
|
+
|
|
29
86
|
return (
|
|
30
|
-
<FormSheet.Root
|
|
31
|
-
|
|
87
|
+
<FormSheet.Root fitToContents>
|
|
88
|
+
<FormSheet.Header>
|
|
89
|
+
<View style={styles.header}>
|
|
90
|
+
<ConversationAvatar conversation={conversation} size="md" showFallback />
|
|
91
|
+
<View style={styles.headerText}>
|
|
92
|
+
<Heading
|
|
93
|
+
variant="h3"
|
|
94
|
+
numberOfLines={1}
|
|
95
|
+
maxFontSizeMultiplier={MAX_FONT_SIZE_MULTIPLIER_LANDMARK}
|
|
96
|
+
>
|
|
97
|
+
{conversation.title}
|
|
98
|
+
</Heading>
|
|
99
|
+
{!!subtitle && (
|
|
100
|
+
<Text
|
|
101
|
+
variant="tertiary"
|
|
102
|
+
numberOfLines={1}
|
|
103
|
+
maxFontSizeMultiplier={MAX_FONT_SIZE_MULTIPLIER_LANDMARK}
|
|
104
|
+
>
|
|
105
|
+
{subtitle}
|
|
106
|
+
</Text>
|
|
107
|
+
)}
|
|
108
|
+
</View>
|
|
109
|
+
</View>
|
|
110
|
+
</FormSheet.Header>
|
|
111
|
+
<FormSheet.Action
|
|
112
|
+
onPress={handleOpenPress}
|
|
113
|
+
title="Open conversation"
|
|
114
|
+
iconName="general.textMessage"
|
|
115
|
+
/>
|
|
116
|
+
<FormSheet.Action
|
|
117
|
+
onPress={handleDetailsPress}
|
|
118
|
+
title="Conversation details"
|
|
119
|
+
iconName="general.cog"
|
|
120
|
+
/>
|
|
121
|
+
{!emptyConversation && (
|
|
122
|
+
<FormSheet.Action
|
|
123
|
+
onPress={handleMarkReadPress}
|
|
124
|
+
title={read ? 'Mark as unread' : 'Mark as read'}
|
|
125
|
+
iconName={read ? 'checkIns.checkPending' : 'checkIns.check'}
|
|
126
|
+
disabled={markReadState.isPending}
|
|
127
|
+
/>
|
|
128
|
+
)}
|
|
129
|
+
{!archived && (
|
|
130
|
+
<FormSheet.Action
|
|
131
|
+
onPress={handleMutePress}
|
|
132
|
+
title={muted ? 'Enable' : 'Silence'}
|
|
133
|
+
iconName={muted ? 'general.bell' : 'general.bellMuted'}
|
|
134
|
+
disabled={muteState.isPending}
|
|
135
|
+
accessibilityHint={
|
|
136
|
+
muted
|
|
137
|
+
? 'Turns notifications for this conversation back on.'
|
|
138
|
+
: 'Turns off notifications for this conversation.'
|
|
139
|
+
}
|
|
140
|
+
/>
|
|
141
|
+
)}
|
|
142
|
+
{!archived && (
|
|
32
143
|
<FormSheet.Action
|
|
33
144
|
onPress={handleHidePress}
|
|
34
145
|
title={hidden ? 'Unhide conversation' : 'Hide conversation'}
|
|
35
146
|
iconName={hidden ? 'general.showEye' : 'general.hideEye'}
|
|
36
|
-
disabled={
|
|
147
|
+
disabled={isHiddenPending}
|
|
37
148
|
accessibilityHint={
|
|
38
149
|
hidden
|
|
39
150
|
? 'Shows this conversation in your conversation list again.'
|
|
@@ -41,13 +152,35 @@ export function ConversationActionsScreen({ route }: ConversationActionsScreenPr
|
|
|
41
152
|
}
|
|
42
153
|
/>
|
|
43
154
|
)}
|
|
155
|
+
<View style={styles.divider} />
|
|
156
|
+
<FormSheet.Action
|
|
157
|
+
onPress={handleSelectPress}
|
|
158
|
+
title="Select conversations"
|
|
159
|
+
iconName="general.check"
|
|
160
|
+
accessibilityHint="Selects this conversation and lets you choose more to hide, silence, or mark read."
|
|
161
|
+
/>
|
|
44
162
|
</FormSheet.Root>
|
|
45
163
|
)
|
|
46
164
|
}
|
|
47
165
|
|
|
48
|
-
const useStyles = () =>
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
166
|
+
const useStyles = () => {
|
|
167
|
+
const { colors } = useTheme()
|
|
168
|
+
|
|
169
|
+
return StyleSheet.create({
|
|
170
|
+
header: {
|
|
171
|
+
flex: 1,
|
|
172
|
+
flexDirection: 'row',
|
|
173
|
+
alignItems: 'center',
|
|
174
|
+
gap: 12,
|
|
175
|
+
},
|
|
176
|
+
headerText: {
|
|
177
|
+
flex: 1,
|
|
178
|
+
},
|
|
179
|
+
divider: {
|
|
180
|
+
height: 1,
|
|
181
|
+
marginHorizontal: 16,
|
|
182
|
+
marginVertical: 4,
|
|
183
|
+
backgroundColor: colors.borderColorDefaultBase,
|
|
52
184
|
},
|
|
53
185
|
})
|
|
186
|
+
}
|
|
@@ -9,12 +9,14 @@ import {
|
|
|
9
9
|
ImagePickerAdapter,
|
|
10
10
|
VideoAdapter,
|
|
11
11
|
} from '../../../utils/native_adapters'
|
|
12
|
-
import { ConversationsScreen } from '../conversations_screen'
|
|
12
|
+
import { ConversationsScreen, ConversationsScreenProps } from '../conversations_screen'
|
|
13
13
|
|
|
14
14
|
const mockGet = jest.fn()
|
|
15
|
+
const mockSetParams = jest.fn()
|
|
16
|
+
const mockEnterSelectMode = jest.fn()
|
|
15
17
|
jest.mock('@react-navigation/native', () => ({
|
|
16
18
|
...jest.requireActual('@react-navigation/native'),
|
|
17
|
-
useNavigation: () => ({ setOptions: jest.fn(), goBack: jest.fn() }),
|
|
19
|
+
useNavigation: () => ({ setOptions: jest.fn(), goBack: jest.fn(), setParams: mockSetParams }),
|
|
18
20
|
}))
|
|
19
21
|
jest.mock('../../../hooks/use_api_client', () => ({
|
|
20
22
|
useApiClient: () => ({ chat: { get: mockGet } }),
|
|
@@ -25,14 +27,20 @@ jest.mock('../../../hooks/use_product_analytics', () => ({
|
|
|
25
27
|
}))
|
|
26
28
|
jest.mock('../../../contexts/conversations_context', () => ({
|
|
27
29
|
ConversationsContextProvider: ({ children }: { children: React.ReactNode }) => children,
|
|
28
|
-
useConversationsContext: () => ({
|
|
30
|
+
useConversationsContext: () => ({
|
|
31
|
+
selectMode: false,
|
|
32
|
+
selectedIds: [],
|
|
33
|
+
enterSelectMode: mockEnterSelectMode,
|
|
34
|
+
}),
|
|
29
35
|
}))
|
|
30
36
|
jest.mock('../../../components', () => ({
|
|
31
|
-
Conversations: ({ ListHeaderComponent }: { ListHeaderComponent: React.
|
|
32
|
-
|
|
33
|
-
),
|
|
37
|
+
Conversations: ({ ListHeaderComponent }: { ListHeaderComponent: React.ReactElement }) =>
|
|
38
|
+
ListHeaderComponent,
|
|
34
39
|
}))
|
|
35
40
|
jest.mock('../../../components/display/toast', () => ({ Toast: () => null }))
|
|
41
|
+
jest.mock('../../../components/conversations/bulk_conversation_actions_bar', () => ({
|
|
42
|
+
BulkConversationActionsBar: () => null,
|
|
43
|
+
}))
|
|
36
44
|
jest.mock('../components/list_header_component', () => {
|
|
37
45
|
const { Text } = require('react-native')
|
|
38
46
|
return { ListHeaderComponent: () => <Text>Default header</Text> }
|
|
@@ -61,7 +69,10 @@ const configureAdapters = () => {
|
|
|
61
69
|
})
|
|
62
70
|
}
|
|
63
71
|
|
|
64
|
-
const renderWithFeatures = (
|
|
72
|
+
const renderWithFeatures = (
|
|
73
|
+
enabledFeatures: string[],
|
|
74
|
+
params: ConversationsScreenProps['route']['params'] = {}
|
|
75
|
+
) => {
|
|
65
76
|
mockGet.mockResolvedValue({
|
|
66
77
|
data: enabledFeatures.map((name, index) => ({
|
|
67
78
|
type: 'Feature',
|
|
@@ -76,7 +87,7 @@ const renderWithFeatures = (enabledFeatures: string[]) => {
|
|
|
76
87
|
return render(
|
|
77
88
|
<QueryClientProvider client={buildTestQueryClient()}>
|
|
78
89
|
<Suspense fallback={null}>
|
|
79
|
-
<ConversationsScreen route={{ params
|
|
90
|
+
<ConversationsScreen route={{ params }} />
|
|
80
91
|
</Suspense>
|
|
81
92
|
</QueryClientProvider>
|
|
82
93
|
)
|
|
@@ -111,3 +122,18 @@ describe('ConversationsScreen header gating', () => {
|
|
|
111
122
|
expect(await view.findByText('Default header')).toBeTruthy()
|
|
112
123
|
})
|
|
113
124
|
})
|
|
125
|
+
|
|
126
|
+
describe('ConversationsScreen select mode request', () => {
|
|
127
|
+
beforeEach(() => {
|
|
128
|
+
configureAdapters()
|
|
129
|
+
jest.clearAllMocks()
|
|
130
|
+
})
|
|
131
|
+
|
|
132
|
+
it('enters select mode for the requested conversation and consumes the request', async () => {
|
|
133
|
+
const view = renderWithFeatures([], { select_conversation_id: 7 })
|
|
134
|
+
await view.findByText('Default header')
|
|
135
|
+
|
|
136
|
+
expect(mockEnterSelectMode).toHaveBeenCalledWith(7)
|
|
137
|
+
expect(mockSetParams).toHaveBeenCalledWith({ select_conversation_id: undefined })
|
|
138
|
+
})
|
|
139
|
+
})
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { StaticScreenProps, useNavigation } from '@react-navigation/native'
|
|
2
|
-
import React, { useLayoutEffect, useRef } from 'react'
|
|
2
|
+
import React, { useEffect, useLayoutEffect, useRef } from 'react'
|
|
3
3
|
import { StyleSheet, View } from 'react-native'
|
|
4
4
|
import { Conversations } from '../../components'
|
|
5
|
+
import { AppUpdateBanner } from '../../components/conversations/app_update_banner'
|
|
6
|
+
import { BulkConversationActionsBar } from '../../components/conversations/bulk_conversation_actions_bar'
|
|
5
7
|
import {
|
|
6
8
|
composeOptions,
|
|
7
9
|
withRightClose,
|
|
@@ -29,6 +31,7 @@ export type ConversationsScreenProps = StaticScreenProps<{
|
|
|
29
31
|
show_archived?: boolean
|
|
30
32
|
show_hidden?: boolean
|
|
31
33
|
show_unread?: boolean
|
|
34
|
+
select_conversation_id?: number
|
|
32
35
|
}>
|
|
33
36
|
|
|
34
37
|
export const conversationsScreenOptions = ({
|
|
@@ -53,7 +56,16 @@ export function ConversationsScreen({ route }: ConversationsScreenProps) {
|
|
|
53
56
|
<View style={styles.container}>
|
|
54
57
|
<ConversationsContextProvider args={route.params} opts={{ throwOnError: true }}>
|
|
55
58
|
<SelectModeHeader title={route.params?.title} />
|
|
56
|
-
<
|
|
59
|
+
<SelectModeRequest conversationId={route.params?.select_conversation_id} />
|
|
60
|
+
<Conversations
|
|
61
|
+
ListHeaderComponent={
|
|
62
|
+
<>
|
|
63
|
+
<Header />
|
|
64
|
+
<AppUpdateBanner />
|
|
65
|
+
</>
|
|
66
|
+
}
|
|
67
|
+
/>
|
|
68
|
+
<BulkConversationActionsBar />
|
|
57
69
|
</ConversationsContextProvider>
|
|
58
70
|
<Toast />
|
|
59
71
|
</View>
|
|
@@ -85,6 +97,20 @@ function SelectModeHeader({ title }: { title?: string }) {
|
|
|
85
97
|
return null
|
|
86
98
|
}
|
|
87
99
|
|
|
100
|
+
function SelectModeRequest({ conversationId }: { conversationId?: number }) {
|
|
101
|
+
const navigation = useNavigation()
|
|
102
|
+
const { enterSelectMode } = useConversationsContext()
|
|
103
|
+
|
|
104
|
+
useEffect(() => {
|
|
105
|
+
if (conversationId === undefined) return
|
|
106
|
+
|
|
107
|
+
enterSelectMode(conversationId)
|
|
108
|
+
navigation.setParams({ select_conversation_id: undefined })
|
|
109
|
+
}, [conversationId, enterSelectMode, navigation])
|
|
110
|
+
|
|
111
|
+
return null
|
|
112
|
+
}
|
|
113
|
+
|
|
88
114
|
const useListHeaderComponent = () => {
|
|
89
115
|
const filterDropdownEnabled = useFilterDropdownEnabled()
|
|
90
116
|
const searchEnabled = useSearchEnabled()
|
package/src/utils/theme.ts
CHANGED
|
@@ -142,20 +142,20 @@ const colorsChatLight: ChatColors = {
|
|
|
142
142
|
statusErrorText: tokens.textColorStatusError,
|
|
143
143
|
statusErrorBorder: tokens.borderColorStatusError,
|
|
144
144
|
statusErrorFill: tokens.fillColorStatusErrorSolid,
|
|
145
|
-
statusInfoComposedIcon: tokens.
|
|
146
|
-
statusInfoComposedText: tokens.
|
|
145
|
+
statusInfoComposedIcon: tokens.textColorStatusInfo,
|
|
146
|
+
statusInfoComposedText: tokens.colorNeutral24,
|
|
147
147
|
statusInfoComposedBackground: tokens.fillColorStatusInfoGhost,
|
|
148
|
-
statusSuccessComposedIcon: tokens.
|
|
149
|
-
statusSuccessComposedText: tokens.
|
|
148
|
+
statusSuccessComposedIcon: tokens.textColorStatusSuccess,
|
|
149
|
+
statusSuccessComposedText: tokens.colorNeutral24,
|
|
150
150
|
statusSuccessComposedBackground: tokens.fillColorStatusSuccessGhost,
|
|
151
|
-
statusWarningComposedIcon: tokens.
|
|
152
|
-
statusWarningComposedText: tokens.
|
|
151
|
+
statusWarningComposedIcon: tokens.textColorStatusWarning,
|
|
152
|
+
statusWarningComposedText: tokens.colorNeutral24,
|
|
153
153
|
statusWarningComposedBackground: tokens.fillColorStatusWarningGhost,
|
|
154
|
-
statusErrorComposedIcon: tokens.
|
|
155
|
-
statusErrorComposedText: tokens.
|
|
154
|
+
statusErrorComposedIcon: tokens.textColorStatusError,
|
|
155
|
+
statusErrorComposedText: tokens.colorNeutral24,
|
|
156
156
|
statusErrorComposedBackground: tokens.fillColorStatusErrorGhost,
|
|
157
|
-
statusNeutralComposedIcon: tokens.
|
|
158
|
-
statusNeutralComposedText: tokens.
|
|
157
|
+
statusNeutralComposedIcon: tokens.textColorStatusNeutral,
|
|
158
|
+
statusNeutralComposedText: tokens.colorNeutral24,
|
|
159
159
|
statusNeutralComposedBackground: tokens.fillColorStatusNeutralGhost,
|
|
160
160
|
borderColorChip: tokens.colorNeutral88,
|
|
161
161
|
fillColorChip: 'transparent',
|
|
@@ -189,21 +189,20 @@ const colorsChatDark: ChatColors = {
|
|
|
189
189
|
statusErrorBorder: tokens.borderColorStatusErrorDark,
|
|
190
190
|
statusErrorFill: tokens.fillColorStatusErrorSolidDark,
|
|
191
191
|
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
statusInfoComposedText: tokens.textColorStatusInfoDark,
|
|
192
|
+
statusInfoComposedIcon: tokens.textColorStatusInfoDark,
|
|
193
|
+
statusInfoComposedText: tokens.colorNeutral88,
|
|
195
194
|
statusInfoComposedBackground: tokens.fillColorStatusInfoGhostDark,
|
|
196
|
-
statusSuccessComposedIcon: tokens.
|
|
197
|
-
statusSuccessComposedText: tokens.
|
|
195
|
+
statusSuccessComposedIcon: tokens.textColorStatusSuccessDark,
|
|
196
|
+
statusSuccessComposedText: tokens.colorNeutral88,
|
|
198
197
|
statusSuccessComposedBackground: tokens.fillColorStatusSuccessGhostDark,
|
|
199
|
-
statusWarningComposedIcon: tokens.
|
|
200
|
-
statusWarningComposedText: tokens.
|
|
198
|
+
statusWarningComposedIcon: tokens.textColorStatusWarningDark,
|
|
199
|
+
statusWarningComposedText: tokens.colorNeutral88,
|
|
201
200
|
statusWarningComposedBackground: tokens.fillColorStatusWarningGhostDark,
|
|
202
|
-
statusErrorComposedIcon: tokens.
|
|
203
|
-
statusErrorComposedText: tokens.
|
|
201
|
+
statusErrorComposedIcon: tokens.textColorStatusErrorDark,
|
|
202
|
+
statusErrorComposedText: tokens.colorNeutral88,
|
|
204
203
|
statusErrorComposedBackground: tokens.fillColorStatusErrorGhostDark,
|
|
205
|
-
statusNeutralComposedIcon: tokens.
|
|
206
|
-
statusNeutralComposedText: tokens.
|
|
204
|
+
statusNeutralComposedIcon: tokens.textColorStatusNeutralDark,
|
|
205
|
+
statusNeutralComposedText: tokens.colorNeutral88,
|
|
207
206
|
statusNeutralComposedBackground: tokens.fillColorStatusNeutralGhostDark,
|
|
208
207
|
borderColorChip: tokens.colorNeutral24,
|
|
209
208
|
fillColorChip: 'transparent',
|