@planningcenter/chat-react-native 4.7.1-qa-staging.9 → 4.7.1-qa-1119.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.
Files changed (129) hide show
  1. package/build/components/conversations/bulk_conversation_actions_bar.d.ts +2 -0
  2. package/build/components/conversations/bulk_conversation_actions_bar.d.ts.map +1 -0
  3. package/build/components/conversations/bulk_conversation_actions_bar.js +215 -0
  4. package/build/components/conversations/bulk_conversation_actions_bar.js.map +1 -0
  5. package/build/components/conversations/conversation_actions.d.ts +2 -1
  6. package/build/components/conversations/conversation_actions.d.ts.map +1 -1
  7. package/build/components/conversations/conversation_actions.js +173 -130
  8. package/build/components/conversations/conversation_actions.js.map +1 -1
  9. package/build/components/conversations/conversation_preview.d.ts.map +1 -1
  10. package/build/components/conversations/conversation_preview.js +168 -110
  11. package/build/components/conversations/conversation_preview.js.map +1 -1
  12. package/build/components/conversations/conversations.d.ts.map +1 -1
  13. package/build/components/conversations/conversations.js +50 -48
  14. package/build/components/conversations/conversations.js.map +1 -1
  15. package/build/components/display/checkbox.d.ts +8 -0
  16. package/build/components/display/checkbox.d.ts.map +1 -0
  17. package/build/components/display/checkbox.js +87 -0
  18. package/build/components/display/checkbox.js.map +1 -0
  19. package/build/components/display/icon.d.ts +3 -1
  20. package/build/components/display/icon.d.ts.map +1 -1
  21. package/build/components/display/icon.js +2 -0
  22. package/build/components/display/icon.js.map +1 -1
  23. package/build/components/display/index.d.ts +1 -0
  24. package/build/components/display/index.d.ts.map +1 -1
  25. package/build/components/display/index.js +1 -0
  26. package/build/components/display/index.js.map +1 -1
  27. package/build/contexts/conversations_context.d.ts +5 -0
  28. package/build/contexts/conversations_context.d.ts.map +1 -1
  29. package/build/contexts/conversations_context.js +121 -32
  30. package/build/contexts/conversations_context.js.map +1 -1
  31. package/build/contexts/session_context.d.ts +0 -1
  32. package/build/contexts/session_context.d.ts.map +1 -1
  33. package/build/contexts/session_context.js.map +1 -1
  34. package/build/hooks/use_bulk_conversation_actions.d.ts +8 -0
  35. package/build/hooks/use_bulk_conversation_actions.d.ts.map +1 -0
  36. package/build/hooks/use_bulk_conversation_actions.js +309 -0
  37. package/build/hooks/use_bulk_conversation_actions.js.map +1 -0
  38. package/build/hooks/use_conversations_cache.d.ts +14 -2
  39. package/build/hooks/use_conversations_cache.d.ts.map +1 -1
  40. package/build/hooks/use_conversations_cache.js +149 -56
  41. package/build/hooks/use_conversations_cache.js.map +1 -1
  42. package/build/navigation/index.d.ts.map +1 -1
  43. package/build/navigation/index.js +5 -7
  44. package/build/navigation/index.js.map +1 -1
  45. package/build/screens/conversation_actions_screen.d.ts +2 -0
  46. package/build/screens/conversation_actions_screen.d.ts.map +1 -1
  47. package/build/screens/conversation_actions_screen.js +380 -46
  48. package/build/screens/conversation_actions_screen.js.map +1 -1
  49. package/build/screens/conversation_filter_recipients/components/checkbox_row.d.ts.map +1 -1
  50. package/build/screens/conversation_filter_recipients/components/checkbox_row.js +9 -64
  51. package/build/screens/conversation_filter_recipients/components/checkbox_row.js.map +1 -1
  52. package/build/screens/conversations/conversations_screen.d.ts +5 -0
  53. package/build/screens/conversations/conversations_screen.d.ts.map +1 -1
  54. package/build/screens/conversations/conversations_screen.js +156 -31
  55. package/build/screens/conversations/conversations_screen.js.map +1 -1
  56. package/build/utils/native_adapters/configuration.d.ts +3 -0
  57. package/build/utils/native_adapters/configuration.d.ts.map +1 -1
  58. package/build/utils/native_adapters/configuration.js +3 -0
  59. package/build/utils/native_adapters/configuration.js.map +1 -1
  60. package/build/utils/native_adapters/index.d.ts +1 -0
  61. package/build/utils/native_adapters/index.d.ts.map +1 -1
  62. package/build/utils/native_adapters/index.js +1 -0
  63. package/build/utils/native_adapters/index.js.map +1 -1
  64. package/build/utils/native_adapters/updates.d.ts +11 -0
  65. package/build/utils/native_adapters/updates.d.ts.map +1 -0
  66. package/build/utils/native_adapters/updates.js +8 -0
  67. package/build/utils/native_adapters/updates.js.map +1 -0
  68. package/package.json +3 -3
  69. package/src/__tests__/contexts/session_context.tsx +19 -39
  70. package/src/__tests__/hooks/useTheme.tsx +0 -7
  71. package/src/__tests__/hooks/use_async_storage.test.tsx +1 -87
  72. package/src/__tests__/hooks/use_attachment_uploader.test.tsx +0 -11
  73. package/src/__tests__/hooks/use_font_scale.test.ts +0 -25
  74. package/src/__tests__/utils/cache/page_mutations.ts +3 -68
  75. package/src/__tests__/utils/client.ts +6 -15
  76. package/src/__tests__/utils/native_adapters/configuration.ts +15 -50
  77. package/src/__tests__/utils/parse_simple_markdown.ts +0 -6
  78. package/src/__tests__/utils/session.ts +0 -11
  79. package/src/__tests__/utils/theme.ts +0 -17
  80. package/src/components/conversations/__tests__/bulk_conversation_actions_bar.test.tsx +95 -0
  81. package/src/components/conversations/__tests__/conversation_actions.test.tsx +35 -3
  82. package/src/components/conversations/__tests__/conversation_preview.test.tsx +69 -3
  83. package/src/components/conversations/__tests__/conversations.test.tsx +4 -1
  84. package/src/components/conversations/bulk_conversation_actions_bar.tsx +140 -0
  85. package/src/components/conversations/conversation_actions.tsx +17 -9
  86. package/src/components/conversations/conversation_preview.tsx +20 -2
  87. package/src/components/conversations/conversations.tsx +2 -1
  88. package/src/components/display/__tests__/filter_dropdown.test.tsx +1 -19
  89. package/src/components/display/__tests__/icon_tile.test.tsx +24 -7
  90. package/src/components/display/checkbox.tsx +47 -0
  91. package/src/components/display/icon.tsx +3 -0
  92. package/src/components/display/index.ts +1 -0
  93. package/src/components/page/__tests__/component_error_boundary.test.tsx +0 -12
  94. package/src/contexts/__tests__/conversations_context.test.tsx +86 -0
  95. package/src/contexts/conversations_context.tsx +69 -2
  96. package/src/contexts/session_context.tsx +0 -1
  97. package/src/hooks/__tests__/jolt_refresh_throttling.test.tsx +0 -35
  98. package/src/hooks/__tests__/use_bulk_conversation_actions.test.tsx +119 -0
  99. package/src/hooks/__tests__/use_hide_conversation.test.tsx +15 -3
  100. package/src/hooks/use_bulk_conversation_actions.ts +173 -0
  101. package/src/hooks/use_conversations_cache.ts +32 -3
  102. package/src/navigation/index.tsx +8 -8
  103. package/src/screens/__tests__/conversation_actions_screen.test.tsx +48 -6
  104. package/src/screens/__tests__/conversation_details_screen.test.tsx +0 -19
  105. package/src/screens/avatar_picker/__tests__/avatar_picker_state.test.ts +0 -14
  106. package/src/screens/conversation_actions_screen.tsx +145 -12
  107. package/src/screens/conversation_filter_recipients/components/checkbox_row.tsx +3 -35
  108. package/src/screens/conversations/__tests__/conversations_screen.test.tsx +35 -9
  109. package/src/screens/conversations/components/__tests__/filter_dropdown_list_header_component.test.tsx +0 -8
  110. package/src/screens/conversations/components/__tests__/search_list_header_component.test.tsx +0 -10
  111. package/src/screens/conversations/conversations_screen.tsx +67 -3
  112. package/src/screens/search/components/__tests__/search_results_list.test.tsx +1 -0
  113. package/src/utils/__tests__/attachment_kind.test.ts +0 -4
  114. package/src/utils/__tests__/convert_attachments_for_create.test.ts +0 -28
  115. package/src/utils/__tests__/is_input_editable.test.ts +1 -2
  116. package/src/utils/__tests__/message_text.test.ts +0 -5
  117. package/src/utils/__tests__/session_manager.test.ts +0 -83
  118. package/src/utils/__tests__/sha_256.test.ts +0 -34
  119. package/src/utils/__tests__/uri.test.ts +51 -0
  120. package/src/utils/native_adapters/configuration.ts +5 -0
  121. package/src/utils/native_adapters/index.ts +1 -0
  122. package/src/utils/native_adapters/updates.ts +16 -0
  123. package/src/__tests__/event-polyfill.test.ts +0 -313
  124. package/src/__tests__/index.tsx +0 -5
  125. package/src/__tests__/jest.ts +0 -11
  126. package/src/__tests__/utils/uri.ts +0 -65
  127. package/src/components/display/__tests__/version_footer.test.tsx +0 -48
  128. package/src/screens/search/components/__tests__/search_blank_states.test.tsx +0 -20
  129. package/src/utils/__tests__/membership_sync_info_text.test.ts +0 -15
@@ -1,4 +1,4 @@
1
- import { InfiniteData, useQueryClient } from '@tanstack/react-query'
1
+ import { InfiniteData, QueryKey, useQueryClient } from '@tanstack/react-query'
2
2
  import { ApiCollection, ConversationResource } from '../types'
3
3
  import {
4
4
  deleteRecordInPagesData,
@@ -10,6 +10,7 @@ import { useApiClient } from './use_api_client'
10
10
  import { getRequestQueryKey } from './use_suspense_api'
11
11
 
12
12
  type QueryData = InfiniteData<ApiCollection<ConversationResource>>
13
+ export type ConversationListsSnapshot = Array<[QueryKey, QueryData | undefined]>
13
14
 
14
15
  export function useConversationsCache(args?: Partial<ConversationRequestArgs>) {
15
16
  const apiClient = useApiClient()
@@ -63,8 +64,32 @@ export function useConversationsCache(args?: Partial<ConversationRequestArgs>) {
63
64
  })
64
65
  }
65
66
 
66
- const invalidateAllLists = () =>
67
- queryClient.invalidateQueries({ queryKey: [conversationsRequestArgs.url] })
67
+ const listsQueryKey = (filter?: string) =>
68
+ filter ? [conversationsRequestArgs.url, { filter }] : [conversationsRequestArgs.url]
69
+
70
+ const invalidateAllLists = ({ filter }: { filter?: string } = {}) =>
71
+ queryClient.invalidateQueries({ queryKey: listsQueryKey(filter) })
72
+
73
+ const cancelAllLists = () => queryClient.cancelQueries({ queryKey: listsQueryKey() })
74
+
75
+ const snapshotAllLists = (): ConversationListsSnapshot =>
76
+ queryClient.getQueriesData<QueryData>({ queryKey: listsQueryKey() })
77
+
78
+ const restoreLists = (lists: ConversationListsSnapshot) =>
79
+ lists.forEach(([queryKey, data]) => queryClient.setQueryData<QueryData>(queryKey, data))
80
+
81
+ const removeFromAllLists = (ids: number[], { filter }: { filter?: string } = {}) =>
82
+ queryClient.setQueriesData<QueryData>({ queryKey: listsQueryKey(filter) }, prev => {
83
+ if (!prev?.pages) return prev
84
+
85
+ return {
86
+ ...prev,
87
+ pages: prev.pages.map(page => ({
88
+ ...page,
89
+ data: page.data.filter(({ id }) => !ids.includes(id)),
90
+ })),
91
+ }
92
+ })
68
93
 
69
94
  const handleConversationDestroy = ({ id }: { id: number }) => {
70
95
  if (!id) return
@@ -93,12 +118,16 @@ export function useConversationsCache(args?: Partial<ConversationRequestArgs>) {
93
118
  }
94
119
 
95
120
  return {
121
+ cancelAllLists,
96
122
  queryKey: conversationQueryKey,
97
123
  create: updateOrCreate,
98
124
  destroy: handleConversationDestroy,
99
125
  fetchSync: fetchAndSync,
100
126
  invalidate: () => queryClient.invalidateQueries({ queryKey: conversationQueryKey }),
101
127
  invalidateAllLists,
128
+ removeFromAllLists,
129
+ restoreLists,
130
+ snapshotAllLists,
102
131
  update: updateOrCreate,
103
132
  updateAll,
104
133
  updateInAllLists,
@@ -60,7 +60,10 @@ import {
60
60
  ConversationSelectTypeScreen,
61
61
  ConversationSelectTypeScreenOptions,
62
62
  } from '../screens/conversation_select_type_screen'
63
- import { ConversationsScreen } from '../screens/conversations/conversations_screen'
63
+ import {
64
+ ConversationsScreen,
65
+ conversationsScreenOptions,
66
+ } from '../screens/conversations/conversations_screen'
64
67
  import { GetHelpScreen } from '../screens/get_help_screen'
65
68
  import {
66
69
  GroupNotificationLevelSelectScreen,
@@ -181,13 +184,10 @@ export const ChatStack = createNativeStackNavigator({
181
184
  Conversations: {
182
185
  screen: ConversationsScreen,
183
186
  options: ({ route, navigation }) =>
184
- composeOptions(
185
- {
186
- headerTitle: (route.params as { title?: string })?.title ?? 'Chat',
187
- headerBackVisible: false,
188
- },
189
- withRightClose({ onPress: navigation.goBack })
190
- ),
187
+ conversationsScreenOptions({
188
+ title: (route.params as { title?: string })?.title,
189
+ onClose: navigation.goBack,
190
+ }),
191
191
  },
192
192
  ConversationFilters: {
193
193
  screen: ConversationFiltersScreen,
@@ -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
- const conversation = { type: 'Conversation', id: 7, title: 'Youth Group' } as ConversationResource
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: conversation }),
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
  })
@@ -257,16 +257,6 @@ describe('ConversationDetailsScreen archive', () => {
257
257
  expect(queryByText('Archive conversation…')).toBeNull()
258
258
  })
259
259
 
260
- it.each(['QA_MOBILE_manual_archiving', 'ROLLOUT_MOBILE_manual_archiving'])(
261
- 'offers archiving with only %s on',
262
- flag => {
263
- mockEnabledFeatures = [flag]
264
- const { getByText } = renderScreen()
265
-
266
- expect(getByText('Archive conversation…')).toBeTruthy()
267
- }
268
- )
269
-
270
260
  it('hides archiving when neither mobile flag is on', () => {
271
261
  mockEnabledFeatures = ['ROLLOUT_WEB_manual_archiving']
272
262
  const { queryByText } = renderScreen()
@@ -299,15 +289,6 @@ describe('ConversationDetailsScreen archive', () => {
299
289
  expect(mockNavigation.goBack).not.toHaveBeenCalled()
300
290
  expect(mockNavigation.navigate).not.toHaveBeenCalled()
301
291
  })
302
-
303
- it('does nothing when the confirmation is cancelled', () => {
304
- const { getByText } = renderScreen()
305
- fireEvent.press(getByText('Archive conversation…'))
306
-
307
- alertButton('Cancel')?.onPress?.()
308
-
309
- expect(mockArchive).not.toHaveBeenCalled()
310
- })
311
292
  })
312
293
 
313
294
  describe('ConversationDetailsScreen hide', () => {
@@ -10,20 +10,6 @@ import {
10
10
 
11
11
  const emptyState = initEmptyAvatarPickerState()
12
12
 
13
- describe('initEmptyAvatarPickerState', () => {
14
- it('starts clean', () => {
15
- expect(emptyState).toMatchObject({
16
- activeTab: 'icon',
17
- selectedType: null,
18
- selectedKey: null,
19
- selectedColor: DEFAULT_AVATAR_COLOR_KEY,
20
- imagePreviewUri: null,
21
- imageAsset: null,
22
- isDirty: false,
23
- })
24
- })
25
- })
26
-
27
13
  describe('initAvatarPickerState', () => {
28
14
  it('seeds from icon avatar', () => {
29
15
  const conversation = {
@@ -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 { useConversation } from '../hooks/use_conversation'
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 { data: conversation } = useConversation(route.params)
21
- const { hidden, setHidden, isPending } = useHideConversation({ conversation })
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 style={styles.formSheetContent}>
31
- {hideConversationsEnabled && (
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={isPending}
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
- StyleSheet.create({
50
- formSheetContent: {
51
- paddingTop: 16,
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
+ }
@@ -1,8 +1,7 @@
1
1
  import { type RouteProp, useRoute } from '@react-navigation/native'
2
- import { Pressable, View, StyleSheet, type ViewStyle } from 'react-native'
3
- import { Icon, Text } from '../../../components'
2
+ import { Pressable, StyleSheet, type ViewStyle } from 'react-native'
3
+ import { Checkbox, Text } from '../../../components'
4
4
  import { useTheme } from '../../../hooks'
5
- import { tokens } from '../../../vendor/tapestry/tokens'
6
5
  import { ConversationFilterRecipientsScreenProps, SetTeamFilters, TeamProps } from '../types'
7
6
 
8
7
  interface TeamRowProps {
@@ -43,7 +42,7 @@ export const CheckboxRow = ({
43
42
  accessibilityLabelledBy={accessibilityLabelledBy}
44
43
  accessibilityLabel={`${teamName} team`}
45
44
  >
46
- <CheckboxIcon checked={checked} />
45
+ <Checkbox checked={checked} />
47
46
  <Text style={styles.label} numberOfLines={2}>
48
47
  {teamName}
49
48
  </Text>
@@ -51,28 +50,9 @@ export const CheckboxRow = ({
51
50
  )
52
51
  }
53
52
 
54
- function CheckboxIcon({ checked }: { checked: boolean }) {
55
- const styles = useStyles()
56
- const checkedStyle = checked ? styles.checkedContainer : styles.uncheckedContainer
57
-
58
- return (
59
- <View style={checkedStyle}>
60
- {checked && <Icon name="general.thickCheckmark" style={styles.checkedIcon} />}
61
- </View>
62
- )
63
- }
64
-
65
53
  const useStyles = () => {
66
54
  const { colors } = useTheme()
67
55
 
68
- const baseCheckboxStyles: ViewStyle = {
69
- width: 20,
70
- height: 20,
71
- borderRadius: 40,
72
- alignItems: 'center',
73
- justifyContent: 'center',
74
- }
75
-
76
56
  return StyleSheet.create({
77
57
  checkboxRow: {
78
58
  flexDirection: 'row',
@@ -89,17 +69,5 @@ const useStyles = () => {
89
69
  label: {
90
70
  flex: 1,
91
71
  },
92
- checkedContainer: {
93
- ...baseCheckboxStyles,
94
- backgroundColor: colors.statusSuccessIcon,
95
- },
96
- uncheckedContainer: {
97
- ...baseCheckboxStyles,
98
- borderWidth: 2,
99
- borderColor: colors.borderColorDefaultDarker,
100
- },
101
- checkedIcon: {
102
- color: tokens.colorNeutral100White,
103
- },
104
72
  })
105
73
  }
@@ -9,9 +9,15 @@ 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()
17
+ jest.mock('@react-navigation/native', () => ({
18
+ ...jest.requireActual('@react-navigation/native'),
19
+ useNavigation: () => ({ setOptions: jest.fn(), goBack: jest.fn(), setParams: mockSetParams }),
20
+ }))
15
21
  jest.mock('../../../hooks/use_api_client', () => ({
16
22
  useApiClient: () => ({ chat: { get: mockGet } }),
17
23
  }))
@@ -21,6 +27,11 @@ jest.mock('../../../hooks/use_product_analytics', () => ({
21
27
  }))
22
28
  jest.mock('../../../contexts/conversations_context', () => ({
23
29
  ConversationsContextProvider: ({ children }: { children: React.ReactNode }) => children,
30
+ useConversationsContext: () => ({
31
+ selectMode: false,
32
+ selectedIds: [],
33
+ enterSelectMode: mockEnterSelectMode,
34
+ }),
24
35
  }))
25
36
  jest.mock('../../../components', () => ({
26
37
  Conversations: ({ ListHeaderComponent }: { ListHeaderComponent: React.ComponentType }) => (
@@ -28,6 +39,9 @@ jest.mock('../../../components', () => ({
28
39
  ),
29
40
  }))
30
41
  jest.mock('../../../components/display/toast', () => ({ Toast: () => null }))
42
+ jest.mock('../../../components/conversations/bulk_conversation_actions_bar', () => ({
43
+ BulkConversationActionsBar: () => null,
44
+ }))
31
45
  jest.mock('../components/list_header_component', () => {
32
46
  const { Text } = require('react-native')
33
47
  return { ListHeaderComponent: () => <Text>Default header</Text> }
@@ -56,7 +70,10 @@ const configureAdapters = () => {
56
70
  })
57
71
  }
58
72
 
59
- const renderWithFeatures = (enabledFeatures: string[]) => {
73
+ const renderWithFeatures = (
74
+ enabledFeatures: string[],
75
+ params: ConversationsScreenProps['route']['params'] = {}
76
+ ) => {
60
77
  mockGet.mockResolvedValue({
61
78
  data: enabledFeatures.map((name, index) => ({
62
79
  type: 'Feature',
@@ -71,7 +88,7 @@ const renderWithFeatures = (enabledFeatures: string[]) => {
71
88
  return render(
72
89
  <QueryClientProvider client={buildTestQueryClient()}>
73
90
  <Suspense fallback={null}>
74
- <ConversationsScreen route={{ params: {} }} />
91
+ <ConversationsScreen route={{ params }} />
75
92
  </Suspense>
76
93
  </QueryClientProvider>
77
94
  )
@@ -100,15 +117,24 @@ describe('ConversationsScreen header gating', () => {
100
117
  expect(await view.findByText('Filter dropdown header')).toBeTruthy()
101
118
  })
102
119
 
103
- it('shows the filter dropdown header with only its rollout flag on', async () => {
104
- const view = renderWithFeatures(['ROLLOUT_MOBILE_filter_dropdown'])
105
-
106
- expect(await view.findByText('Filter dropdown header')).toBeTruthy()
107
- })
108
-
109
120
  it('shows the default header with neither flag on', async () => {
110
121
  const view = renderWithFeatures(['ROLLOUT_WEB_search'])
111
122
 
112
123
  expect(await view.findByText('Default header')).toBeTruthy()
113
124
  })
114
125
  })
126
+
127
+ describe('ConversationsScreen select mode request', () => {
128
+ beforeEach(() => {
129
+ configureAdapters()
130
+ jest.clearAllMocks()
131
+ })
132
+
133
+ it('enters select mode for the requested conversation and consumes the request', async () => {
134
+ const view = renderWithFeatures([], { select_conversation_id: 7 })
135
+ await view.findByText('Default header')
136
+
137
+ expect(mockEnterSelectMode).toHaveBeenCalledWith(7)
138
+ expect(mockSetParams).toHaveBeenCalledWith({ select_conversation_id: undefined })
139
+ })
140
+ })
@@ -326,14 +326,6 @@ describe('FilterDropdownListHeaderComponent', () => {
326
326
  )
327
327
  })
328
328
 
329
- it('More filters opens the filters sheet', () => {
330
- render(<FilterDropdownListHeaderComponent />)
331
-
332
- fireEvent.press(screen.getByRole('menuitem', { name: 'More filters' }))
333
-
334
- expect(mockNavigate).toHaveBeenCalledWith('ConversationFilters', expect.any(Object))
335
- })
336
-
337
329
  it('More filters carries the Unread filter into the sheet', () => {
338
330
  setRouteParams({ show_unread: true })
339
331
 
@@ -49,14 +49,4 @@ describe('SearchListHeaderComponent search button', () => {
49
49
  expect(mockNavigate).toHaveBeenCalledTimes(1)
50
50
  expect(mockNavigate).toHaveBeenCalledWith('Search')
51
51
  })
52
-
53
- it('renders the search button after the other actions', () => {
54
- const view = render(<SearchListHeaderComponent />)
55
-
56
- const buttons = view.getAllByRole('button').map(button => button.props.accessibilityLabel)
57
-
58
- expect(buttons.indexOf('Search')).toBeGreaterThanOrEqual(0)
59
- expect(buttons.indexOf('Search')).toBeGreaterThan(buttons.indexOf('Chat settings'))
60
- expect(buttons.indexOf('Search')).toBeGreaterThan(buttons.indexOf('New conversation'))
61
- })
62
52
  })