@planningcenter/chat-react-native 4.7.1-qa-staging.8 → 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.
- 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 +2 -1
- package/build/components/conversations/conversation_actions.d.ts.map +1 -1
- package/build/components/conversations/conversation_actions.js +173 -130
- 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 +168 -110
- 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 +50 -48
- package/build/components/conversations/conversations.js.map +1 -1
- package/build/components/display/checkbox.d.ts +8 -0
- package/build/components/display/checkbox.d.ts.map +1 -0
- package/build/components/display/checkbox.js +87 -0
- package/build/components/display/checkbox.js.map +1 -0
- 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/display/index.d.ts +1 -0
- package/build/components/display/index.d.ts.map +1 -1
- package/build/components/display/index.js +1 -0
- package/build/components/display/index.js.map +1 -1
- package/build/contexts/api_provider.d.ts.map +1 -1
- package/build/contexts/api_provider.js +2 -0
- package/build/contexts/api_provider.js.map +1 -1
- package/build/contexts/conversations_context.d.ts +5 -0
- package/build/contexts/conversations_context.d.ts.map +1 -1
- package/build/contexts/conversations_context.js +121 -32
- package/build/contexts/conversations_context.js.map +1 -1
- package/build/contexts/session_context.d.ts +0 -1
- package/build/contexts/session_context.d.ts.map +1 -1
- package/build/contexts/session_context.js +3 -0
- package/build/contexts/session_context.js.map +1 -1
- package/build/hooks/use_bulk_conversation_actions.d.ts +8 -0
- package/build/hooks/use_bulk_conversation_actions.d.ts.map +1 -0
- package/build/hooks/use_bulk_conversation_actions.js +309 -0
- package/build/hooks/use_bulk_conversation_actions.js.map +1 -0
- package/build/hooks/use_conversation_jolt_events.d.ts.map +1 -1
- package/build/hooks/use_conversation_jolt_events.js +3 -2
- package/build/hooks/use_conversation_jolt_events.js.map +1 -1
- package/build/hooks/use_conversations_actions.d.ts +9 -9
- package/build/hooks/use_conversations_actions.d.ts.map +1 -1
- package/build/hooks/use_conversations_actions.js +12 -7
- package/build/hooks/use_conversations_actions.js.map +1 -1
- package/build/hooks/use_conversations_cache.d.ts +15 -5
- package/build/hooks/use_conversations_cache.d.ts.map +1 -1
- package/build/hooks/use_conversations_cache.js +170 -122
- package/build/hooks/use_conversations_cache.js.map +1 -1
- package/build/hooks/use_conversations_jolt_events.d.ts.map +1 -1
- package/build/hooks/use_conversations_jolt_events.js +47 -20
- package/build/hooks/use_conversations_jolt_events.js.map +1 -1
- package/build/hooks/use_mark_latest_message_read.d.ts.map +1 -1
- package/build/hooks/use_mark_latest_message_read.js +5 -4
- package/build/hooks/use_mark_latest_message_read.js.map +1 -1
- package/build/navigation/index.d.ts.map +1 -1
- package/build/navigation/index.js +5 -7
- package/build/navigation/index.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/conversation_filter_recipients/components/checkbox_row.d.ts.map +1 -1
- package/build/screens/conversation_filter_recipients/components/checkbox_row.js +9 -64
- package/build/screens/conversation_filter_recipients/components/checkbox_row.js.map +1 -1
- package/build/screens/conversations/conversations_screen.d.ts +5 -0
- package/build/screens/conversations/conversations_screen.d.ts.map +1 -1
- package/build/screens/conversations/conversations_screen.js +156 -31
- package/build/screens/conversations/conversations_screen.js.map +1 -1
- package/build/types/jolt_events/index.d.ts +2 -0
- package/build/types/jolt_events/index.d.ts.map +1 -1
- package/build/types/jolt_events/index.js.map +1 -1
- package/build/types/jolt_events/person_events.d.ts +9 -0
- package/build/types/jolt_events/person_events.d.ts.map +1 -0
- package/build/types/jolt_events/person_events.js +2 -0
- package/build/types/jolt_events/person_events.js.map +1 -0
- package/build/utils/jolt/parse_stream_user_event_type.d.ts +3 -0
- package/build/utils/jolt/parse_stream_user_event_type.d.ts.map +1 -0
- package/build/utils/jolt/parse_stream_user_event_type.js +9 -0
- package/build/utils/jolt/parse_stream_user_event_type.js.map +1 -0
- package/build/utils/native_adapters/configuration.d.ts +3 -0
- package/build/utils/native_adapters/configuration.d.ts.map +1 -1
- package/build/utils/native_adapters/configuration.js +3 -0
- package/build/utils/native_adapters/configuration.js.map +1 -1
- package/build/utils/native_adapters/index.d.ts +1 -0
- package/build/utils/native_adapters/index.d.ts.map +1 -1
- package/build/utils/native_adapters/index.js +1 -0
- package/build/utils/native_adapters/index.js.map +1 -1
- package/build/utils/native_adapters/updates.d.ts +11 -0
- package/build/utils/native_adapters/updates.d.ts.map +1 -0
- package/build/utils/native_adapters/updates.js +8 -0
- package/build/utils/native_adapters/updates.js.map +1 -0
- package/build/utils/throttled_refresh.d.ts +7 -0
- package/build/utils/throttled_refresh.d.ts.map +1 -0
- package/build/utils/throttled_refresh.js +42 -0
- package/build/utils/throttled_refresh.js.map +1 -0
- package/package.json +3 -3
- package/src/__tests__/contexts/session_context.tsx +19 -39
- package/src/__tests__/hooks/useTheme.tsx +0 -7
- package/src/__tests__/hooks/use_async_storage.test.tsx +1 -87
- package/src/__tests__/hooks/use_attachment_uploader.test.tsx +0 -11
- package/src/__tests__/hooks/use_font_scale.test.ts +0 -25
- package/src/__tests__/utils/cache/page_mutations.ts +3 -68
- package/src/__tests__/utils/client.ts +6 -15
- package/src/__tests__/utils/native_adapters/configuration.ts +15 -50
- package/src/__tests__/utils/parse_simple_markdown.ts +0 -6
- package/src/__tests__/utils/session.ts +0 -11
- package/src/__tests__/utils/theme.ts +0 -17
- package/src/components/conversations/__tests__/bulk_conversation_actions_bar.test.tsx +95 -0
- package/src/components/conversations/__tests__/conversation_actions.test.tsx +35 -3
- package/src/components/conversations/__tests__/conversation_preview.test.tsx +69 -3
- package/src/components/conversations/__tests__/conversations.test.tsx +4 -1
- package/src/components/conversations/bulk_conversation_actions_bar.tsx +140 -0
- package/src/components/conversations/conversation_actions.tsx +17 -9
- package/src/components/conversations/conversation_preview.tsx +20 -2
- package/src/components/conversations/conversations.tsx +2 -1
- package/src/components/display/__tests__/filter_dropdown.test.tsx +1 -19
- package/src/components/display/__tests__/icon_tile.test.tsx +24 -7
- package/src/components/display/checkbox.tsx +47 -0
- package/src/components/display/icon.tsx +3 -0
- package/src/components/display/index.ts +1 -0
- package/src/components/page/__tests__/component_error_boundary.test.tsx +0 -12
- package/src/contexts/__tests__/conversations_context.test.tsx +86 -0
- package/src/contexts/api_provider.tsx +2 -0
- package/src/contexts/conversations_context.tsx +69 -2
- package/src/contexts/session_context.tsx +3 -1
- package/src/hooks/__tests__/jolt_refresh_throttling.test.tsx +194 -0
- package/src/hooks/__tests__/use_bulk_conversation_actions.test.tsx +119 -0
- package/src/hooks/__tests__/use_conversations_jolt_events.test.tsx +1 -0
- package/src/hooks/__tests__/use_conversations_mark_read.test.tsx +38 -12
- package/src/hooks/__tests__/use_hide_conversation.test.tsx +15 -3
- package/src/hooks/__tests__/use_mark_latest_message_read.test.tsx +23 -2
- package/src/hooks/use_bulk_conversation_actions.ts +173 -0
- package/src/hooks/use_conversation_jolt_events.ts +2 -1
- package/src/hooks/use_conversations_actions.ts +7 -4
- package/src/hooks/use_conversations_cache.ts +33 -26
- package/src/hooks/use_conversations_jolt_events.ts +24 -10
- package/src/hooks/use_mark_latest_message_read.ts +6 -5
- package/src/navigation/index.tsx +8 -8
- package/src/screens/__tests__/conversation_actions_screen.test.tsx +48 -6
- package/src/screens/__tests__/conversation_details_screen.test.tsx +0 -19
- package/src/screens/avatar_picker/__tests__/avatar_picker_state.test.ts +0 -14
- package/src/screens/conversation_actions_screen.tsx +145 -12
- package/src/screens/conversation_filter_recipients/components/checkbox_row.tsx +3 -35
- package/src/screens/conversations/__tests__/conversations_screen.test.tsx +35 -9
- package/src/screens/conversations/components/__tests__/filter_dropdown_list_header_component.test.tsx +0 -8
- package/src/screens/conversations/components/__tests__/search_list_header_component.test.tsx +0 -10
- package/src/screens/conversations/conversations_screen.tsx +67 -3
- package/src/screens/search/components/__tests__/search_results_list.test.tsx +1 -0
- package/src/types/jolt_events/index.ts +2 -0
- package/src/types/jolt_events/person_events.ts +16 -0
- package/src/utils/__tests__/attachment_kind.test.ts +0 -4
- package/src/utils/__tests__/convert_attachments_for_create.test.ts +0 -28
- package/src/utils/__tests__/is_input_editable.test.ts +1 -2
- package/src/utils/__tests__/message_text.test.ts +0 -5
- package/src/utils/__tests__/session_manager.test.ts +0 -83
- package/src/utils/__tests__/sha_256.test.ts +0 -34
- package/src/utils/__tests__/throttled_refresh.test.ts +101 -0
- package/src/utils/__tests__/uri.test.ts +51 -0
- package/src/utils/jolt/__tests__/parse_stream_user_event_type.test.ts +27 -0
- package/src/utils/jolt/parse_stream_user_event_type.ts +16 -0
- package/src/utils/native_adapters/configuration.ts +5 -0
- package/src/utils/native_adapters/index.ts +1 -0
- package/src/utils/native_adapters/updates.ts +16 -0
- package/src/utils/throttled_refresh.ts +62 -0
- package/src/__tests__/event-polyfill.test.ts +0 -313
- package/src/__tests__/index.tsx +0 -5
- package/src/__tests__/jest.ts +0 -11
- package/src/__tests__/utils/uri.ts +0 -65
- package/src/components/display/__tests__/version_footer.test.tsx +0 -48
- package/src/screens/search/components/__tests__/search_blank_states.test.tsx +0 -20
- package/src/utils/__tests__/membership_sync_info_text.test.ts +0 -15
|
@@ -54,10 +54,6 @@ describe('ChatAdapters', () => {
|
|
|
54
54
|
notificationError: jest.fn(),
|
|
55
55
|
})
|
|
56
56
|
|
|
57
|
-
it('should be defined', () => {
|
|
58
|
-
expect(ChatAdapters).toBeDefined()
|
|
59
|
-
})
|
|
60
|
-
|
|
61
57
|
it('should configure the clipboard', () => {
|
|
62
58
|
ChatAdapters.configure({
|
|
63
59
|
clipboard,
|
|
@@ -71,42 +67,30 @@ describe('ChatAdapters', () => {
|
|
|
71
67
|
})
|
|
72
68
|
|
|
73
69
|
describe('linking adapter', () => {
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
ChatAdapters.configure({
|
|
77
|
-
clipboard,
|
|
78
|
-
audio,
|
|
79
|
-
video,
|
|
80
|
-
imagePicker,
|
|
81
|
-
})
|
|
82
|
-
|
|
83
|
-
expect(Linking).toBeDefined()
|
|
84
|
-
expect(Linking.openURL).toBeDefined()
|
|
85
|
-
expect(Linking.canOpenURL).toBeDefined()
|
|
86
|
-
})
|
|
70
|
+
it('opens URLs through React Native Linking by default', async () => {
|
|
71
|
+
ChatAdapters.configure({ clipboard, audio, video, imagePicker })
|
|
87
72
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
})
|
|
73
|
+
await Linking.openURL('https://www.google.com')
|
|
74
|
+
|
|
75
|
+
expect(RNLinking.openURL).toHaveBeenCalledWith('https://www.google.com')
|
|
92
76
|
})
|
|
93
77
|
|
|
94
|
-
|
|
78
|
+
it('calls the host methods bound to React Native Linking', async () => {
|
|
79
|
+
const receivers: unknown[] = []
|
|
95
80
|
const linking = new LinkingAdapter({
|
|
96
|
-
openURL: async function (
|
|
97
|
-
|
|
98
|
-
expect(this).toBe(RNLinking)
|
|
81
|
+
openURL: async function (this: unknown) {
|
|
82
|
+
receivers.push(this)
|
|
99
83
|
},
|
|
100
|
-
canOpenURL: async function (
|
|
101
|
-
|
|
102
|
-
expect(this).toBe(RNLinking)
|
|
103
|
-
|
|
84
|
+
canOpenURL: async function (this: unknown) {
|
|
85
|
+
receivers.push(this)
|
|
104
86
|
return true
|
|
105
87
|
},
|
|
106
88
|
})
|
|
107
89
|
|
|
108
|
-
linking.openURL('https://www.google.com')
|
|
109
|
-
linking.canOpenURL('https://www.google.com')
|
|
90
|
+
await linking.openURL('https://www.google.com')
|
|
91
|
+
await linking.canOpenURL('https://www.google.com')
|
|
92
|
+
|
|
93
|
+
expect(receivers).toEqual([RNLinking, RNLinking])
|
|
110
94
|
})
|
|
111
95
|
})
|
|
112
96
|
|
|
@@ -157,24 +141,5 @@ describe('ChatAdapters', () => {
|
|
|
157
141
|
|
|
158
142
|
expect(Haptic).toEqual(haptic)
|
|
159
143
|
})
|
|
160
|
-
|
|
161
|
-
it('should be configured with defaults', () => {
|
|
162
|
-
ChatAdapters.configure({
|
|
163
|
-
clipboard,
|
|
164
|
-
audio,
|
|
165
|
-
video,
|
|
166
|
-
imagePicker,
|
|
167
|
-
})
|
|
168
|
-
|
|
169
|
-
expect(Haptic).toBeDefined()
|
|
170
|
-
expect(Haptic.impactLight).toBeDefined()
|
|
171
|
-
expect(Haptic.impactMedium).toBeDefined()
|
|
172
|
-
expect(Haptic.impactHeavy).toBeDefined()
|
|
173
|
-
expect(Haptic.rigid).toBeDefined()
|
|
174
|
-
expect(Haptic.soft).toBeDefined()
|
|
175
|
-
expect(Haptic.notificationSuccess).toBeDefined()
|
|
176
|
-
expect(Haptic.notificationWarning).toBeDefined()
|
|
177
|
-
expect(Haptic.notificationError).toBeDefined()
|
|
178
|
-
})
|
|
179
144
|
})
|
|
180
145
|
})
|
|
@@ -51,12 +51,6 @@ describe('parseSimpleMarkdown', () => {
|
|
|
51
51
|
expect(result).toEqual([{ type: 'text', content: '* Item 1\n* Item 2\n* Item 3' }])
|
|
52
52
|
})
|
|
53
53
|
|
|
54
|
-
it('parses ordered lists correctly', () => {
|
|
55
|
-
const input = '1. Item 1\n2. Item 2\n3. Item 3'
|
|
56
|
-
const result = parseSimpleMarkdown(input)
|
|
57
|
-
expect(result).toEqual([{ type: 'text', content: '1. Item 1\n2. Item 2\n3. Item 3' }])
|
|
58
|
-
})
|
|
59
|
-
|
|
60
54
|
it('handles plain text without formatting', () => {
|
|
61
55
|
const input = 'Just plain text'
|
|
62
56
|
const result = parseSimpleMarkdown(input)
|
|
@@ -37,17 +37,6 @@ describe('Session', () => {
|
|
|
37
37
|
expect(hydratedSession.token).toEqual(token)
|
|
38
38
|
expect(hydratedSession.isAuthenticated).toEqual(true)
|
|
39
39
|
})
|
|
40
|
-
|
|
41
|
-
it('should store the environment of hydrated Session instance', () => {
|
|
42
|
-
const env = 'production'
|
|
43
|
-
const session = new Session({ token, env })
|
|
44
|
-
|
|
45
|
-
const sessionString = session.toString()
|
|
46
|
-
const hydratedSession = Session.hydrate(sessionString)
|
|
47
|
-
expect(hydratedSession.env).toEqual(env)
|
|
48
|
-
expect(hydratedSession.token).toEqual(token)
|
|
49
|
-
expect(hydratedSession.isAuthenticated).toEqual(true)
|
|
50
|
-
})
|
|
51
40
|
})
|
|
52
41
|
|
|
53
42
|
describe('failure', () => {
|
|
@@ -10,10 +10,6 @@ describe('defaultTheme', () => {
|
|
|
10
10
|
expect(defaultTheme('light').colors).toMatchObject(aliasTokensColorMap.light)
|
|
11
11
|
})
|
|
12
12
|
|
|
13
|
-
test('falls back to the light palette when colorScheme is null', () => {
|
|
14
|
-
expect(defaultTheme(null).colors).toMatchObject(aliasTokensColorMap.light)
|
|
15
|
-
})
|
|
16
|
-
|
|
17
13
|
test('falls back to the light palette for React Native 0.83\'s "unspecified" variant', () => {
|
|
18
14
|
// RN 0.83 added "unspecified" to ColorSchemeName. Anything that is not
|
|
19
15
|
// literally "dark" should fall through to the light palette so we never
|
|
@@ -22,19 +18,6 @@ describe('defaultTheme', () => {
|
|
|
22
18
|
})
|
|
23
19
|
|
|
24
20
|
describe('chip tokens', () => {
|
|
25
|
-
test('seeds static defaults for the non-selected chip trio in both schemes', () => {
|
|
26
|
-
const light = defaultTheme('light').colors
|
|
27
|
-
const dark = defaultTheme('dark').colors
|
|
28
|
-
|
|
29
|
-
expect(light.borderColorChip).toBe('hsl(0, 0%, 88%)')
|
|
30
|
-
expect(light.fillColorChip).toBe('transparent')
|
|
31
|
-
expect(light.textColorChip).toBe('hsl(0, 0%, 45%)')
|
|
32
|
-
|
|
33
|
-
expect(dark.borderColorChip).toBe('hsl(0, 0%, 24%)')
|
|
34
|
-
expect(dark.fillColorChip).toBe('transparent')
|
|
35
|
-
expect(dark.textColorChip).toBe('hsl(0, 0%, 68%)')
|
|
36
|
-
})
|
|
37
|
-
|
|
38
21
|
test('never seeds a static default for the selected chip trio', () => {
|
|
39
22
|
const { colors } = defaultTheme('light')
|
|
40
23
|
|
|
@@ -0,0 +1,95 @@
|
|
|
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 type { ConversationResource } from '../../../types'
|
|
5
|
+
import { BulkConversationActionsBar } from '../bulk_conversation_actions_bar'
|
|
6
|
+
|
|
7
|
+
jest.mock('react-native-reanimated', () => ({
|
|
8
|
+
...jest.requireActual('react-native-reanimated/mock'),
|
|
9
|
+
LayoutAnimationConfig: ({ children }: { children: React.ReactNode }) => children,
|
|
10
|
+
useReducedMotion: () => false,
|
|
11
|
+
}))
|
|
12
|
+
|
|
13
|
+
const mockHide = jest.fn(async () => {})
|
|
14
|
+
const mockSilence = jest.fn(async () => {})
|
|
15
|
+
jest.mock('../../../hooks/use_bulk_conversation_actions', () => ({
|
|
16
|
+
useBulkConversationActions: () => ({
|
|
17
|
+
hide: mockHide,
|
|
18
|
+
unhide: jest.fn(),
|
|
19
|
+
silence: mockSilence,
|
|
20
|
+
markRead: jest.fn(),
|
|
21
|
+
}),
|
|
22
|
+
}))
|
|
23
|
+
|
|
24
|
+
const createdAt = '2026-10-01T12:00:00Z'
|
|
25
|
+
|
|
26
|
+
const conversation = (overrides: Partial<ConversationResource>): ConversationResource => ({
|
|
27
|
+
type: 'Conversation',
|
|
28
|
+
id: 1,
|
|
29
|
+
title: 'Youth Group',
|
|
30
|
+
conversationPreview: null,
|
|
31
|
+
createdAt,
|
|
32
|
+
lastMessageCreatedAt: createdAt,
|
|
33
|
+
muted: false,
|
|
34
|
+
repliesDisabled: false,
|
|
35
|
+
unreadCount: 1,
|
|
36
|
+
unreadReaction: false,
|
|
37
|
+
updatedAt: createdAt,
|
|
38
|
+
...overrides,
|
|
39
|
+
})
|
|
40
|
+
|
|
41
|
+
const first = conversation({ id: 1 })
|
|
42
|
+
const second = conversation({ id: 2 })
|
|
43
|
+
const archived = conversation({ id: 3, disabled: true, disabledReason: 'archived' })
|
|
44
|
+
const mockConversations = [first, second, archived]
|
|
45
|
+
|
|
46
|
+
const mockClearSelection = jest.fn()
|
|
47
|
+
let mockSelectedIds: number[] = []
|
|
48
|
+
jest.mock('../../../contexts/conversations_context', () => ({
|
|
49
|
+
useConversationsContext: () => ({
|
|
50
|
+
selectMode: true,
|
|
51
|
+
selectedIds: mockSelectedIds,
|
|
52
|
+
conversations: mockConversations,
|
|
53
|
+
hideable: true,
|
|
54
|
+
clearSelection: mockClearSelection,
|
|
55
|
+
args: {},
|
|
56
|
+
}),
|
|
57
|
+
}))
|
|
58
|
+
|
|
59
|
+
const safeAreaMetrics = {
|
|
60
|
+
frame: { x: 0, y: 0, width: 390, height: 844 },
|
|
61
|
+
insets: { top: 0, right: 0, bottom: 0, left: 0 },
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
const renderBar = () =>
|
|
65
|
+
render(
|
|
66
|
+
<SafeAreaProvider initialMetrics={safeAreaMetrics}>
|
|
67
|
+
<BulkConversationActionsBar />
|
|
68
|
+
</SafeAreaProvider>
|
|
69
|
+
)
|
|
70
|
+
|
|
71
|
+
describe('BulkConversationActionsBar', () => {
|
|
72
|
+
beforeEach(() => jest.clearAllMocks())
|
|
73
|
+
|
|
74
|
+
it('hides every selected conversation and then clears the selection', async () => {
|
|
75
|
+
mockSelectedIds = [1, 2]
|
|
76
|
+
const view = renderBar()
|
|
77
|
+
|
|
78
|
+
await act(async () => fireEvent.press(view.getByText('Hide')))
|
|
79
|
+
|
|
80
|
+
expect(mockHide).toHaveBeenCalledWith([first, second])
|
|
81
|
+
expect(mockClearSelection).toHaveBeenCalled()
|
|
82
|
+
})
|
|
83
|
+
|
|
84
|
+
it('disables hide and silence when an archived conversation is selected', () => {
|
|
85
|
+
mockSelectedIds = [1, 3]
|
|
86
|
+
const view = renderBar()
|
|
87
|
+
|
|
88
|
+
fireEvent.press(view.getByText('Hide'))
|
|
89
|
+
fireEvent.press(view.getByText('Silence'))
|
|
90
|
+
|
|
91
|
+
expect(mockHide).not.toHaveBeenCalled()
|
|
92
|
+
expect(mockSilence).not.toHaveBeenCalled()
|
|
93
|
+
expect(mockClearSelection).not.toHaveBeenCalled()
|
|
94
|
+
})
|
|
95
|
+
})
|
|
@@ -67,9 +67,13 @@ const conversation = (overrides: Partial<ConversationResource>): ConversationRes
|
|
|
67
67
|
...overrides,
|
|
68
68
|
})
|
|
69
69
|
|
|
70
|
-
const renderActions = (overrides: Partial<ConversationResource
|
|
70
|
+
const renderActions = (overrides: Partial<ConversationResource>, selected?: boolean) =>
|
|
71
71
|
render(
|
|
72
|
-
<ConversationActions
|
|
72
|
+
<ConversationActions
|
|
73
|
+
conversation={conversation(overrides)}
|
|
74
|
+
onPress={jest.fn()}
|
|
75
|
+
selected={selected}
|
|
76
|
+
>
|
|
73
77
|
<Text>Youth Group</Text>
|
|
74
78
|
</ConversationActions>
|
|
75
79
|
)
|
|
@@ -137,6 +141,34 @@ describe('ConversationActions hide', () => {
|
|
|
137
141
|
|
|
138
142
|
fireEvent(view.getByTestId('conversation-7'), 'longPress')
|
|
139
143
|
|
|
140
|
-
expect(mockNavigate).toHaveBeenCalledWith('ConversationActions', {
|
|
144
|
+
expect(mockNavigate).toHaveBeenCalledWith('ConversationActions', {
|
|
145
|
+
conversation_id: 7,
|
|
146
|
+
read: false,
|
|
147
|
+
muted: false,
|
|
148
|
+
})
|
|
149
|
+
})
|
|
150
|
+
})
|
|
151
|
+
|
|
152
|
+
describe('ConversationActions select mode', () => {
|
|
153
|
+
beforeEach(() => {
|
|
154
|
+
mockHideEnabled = true
|
|
155
|
+
mockHideable = true
|
|
156
|
+
})
|
|
157
|
+
|
|
158
|
+
it('presents the row as a checked checkbox without row actions', () => {
|
|
159
|
+
const view = renderActions({}, true)
|
|
160
|
+
const row = view.getByTestId('conversation-7')
|
|
161
|
+
|
|
162
|
+
expect(row.props.accessibilityRole).toBe('checkbox')
|
|
163
|
+
expect(row.props.accessibilityState).toEqual({ checked: true })
|
|
164
|
+
expect(row.props.accessibilityActions).toEqual([])
|
|
165
|
+
})
|
|
166
|
+
|
|
167
|
+
it('keeps the button role and row actions outside select mode', () => {
|
|
168
|
+
const view = renderActions({})
|
|
169
|
+
const row = view.getByTestId('conversation-7')
|
|
170
|
+
|
|
171
|
+
expect(row.props.accessibilityRole).toBe('button')
|
|
172
|
+
expect(row.props.accessibilityActions.length).toBeGreaterThan(0)
|
|
141
173
|
})
|
|
142
174
|
})
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { fireEvent } from '@testing-library/react-native'
|
|
1
2
|
import React from 'react'
|
|
2
3
|
import { renderWithQueryClient } from '../../../__utils__/render_with_query_client'
|
|
3
4
|
import { ConversationFiltersParams } from '../../../screens/conversation_filters/screen_props'
|
|
@@ -6,19 +7,40 @@ import { formatDatePreview } from '../../../utils/date'
|
|
|
6
7
|
import { ConversationPreview } from '../conversation_preview'
|
|
7
8
|
|
|
8
9
|
let mockArgs: ConversationFiltersParams = {}
|
|
10
|
+
let mockSelectMode = false
|
|
11
|
+
let mockSelectedIds: number[] = []
|
|
12
|
+
const mockToggleSelected = jest.fn()
|
|
9
13
|
jest.mock('../../../contexts/conversations_context', () => ({
|
|
10
|
-
useConversationsContext: () => ({
|
|
14
|
+
useConversationsContext: () => ({
|
|
15
|
+
args: mockArgs,
|
|
16
|
+
selectMode: mockSelectMode,
|
|
17
|
+
selectedIds: mockSelectedIds,
|
|
18
|
+
toggleSelected: mockToggleSelected,
|
|
19
|
+
}),
|
|
11
20
|
}))
|
|
12
21
|
jest.mock('../conversation_actions', () => ({
|
|
13
22
|
ConversationActions: ({
|
|
14
23
|
children,
|
|
15
24
|
accessibilityLabel,
|
|
25
|
+
onPress,
|
|
26
|
+
selected,
|
|
16
27
|
}: {
|
|
17
28
|
children: React.ReactNode
|
|
18
29
|
accessibilityLabel?: string
|
|
30
|
+
onPress: () => void
|
|
31
|
+
selected?: boolean
|
|
19
32
|
}) => {
|
|
20
|
-
const {
|
|
21
|
-
return
|
|
33
|
+
const { Pressable: MockPressable } = jest.requireActual('react-native')
|
|
34
|
+
return (
|
|
35
|
+
<MockPressable
|
|
36
|
+
accessibilityLabel={accessibilityLabel}
|
|
37
|
+
accessibilityRole="checkbox"
|
|
38
|
+
accessibilityState={{ checked: selected }}
|
|
39
|
+
onPress={onPress}
|
|
40
|
+
>
|
|
41
|
+
{children}
|
|
42
|
+
</MockPressable>
|
|
43
|
+
)
|
|
22
44
|
},
|
|
23
45
|
}))
|
|
24
46
|
|
|
@@ -131,4 +153,48 @@ describe('ConversationPreview', () => {
|
|
|
131
153
|
).toBeNull()
|
|
132
154
|
})
|
|
133
155
|
})
|
|
156
|
+
|
|
157
|
+
describe('select mode', () => {
|
|
158
|
+
const onPress = jest.fn()
|
|
159
|
+
const renderSelectable = () =>
|
|
160
|
+
renderWithQueryClient(
|
|
161
|
+
<ConversationPreview conversation={conversation(messagePreview)} onPress={onPress} />
|
|
162
|
+
)
|
|
163
|
+
|
|
164
|
+
beforeEach(() => {
|
|
165
|
+
mockSelectMode = true
|
|
166
|
+
mockSelectedIds = []
|
|
167
|
+
jest.clearAllMocks()
|
|
168
|
+
})
|
|
169
|
+
|
|
170
|
+
afterAll(() => {
|
|
171
|
+
mockSelectMode = false
|
|
172
|
+
})
|
|
173
|
+
|
|
174
|
+
it('toggles the conversation instead of opening it', () => {
|
|
175
|
+
const view = renderSelectable()
|
|
176
|
+
|
|
177
|
+
fireEvent.press(view.getByText('Worship Team'))
|
|
178
|
+
|
|
179
|
+
expect(mockToggleSelected).toHaveBeenCalledWith(7)
|
|
180
|
+
expect(onPress).not.toHaveBeenCalled()
|
|
181
|
+
})
|
|
182
|
+
|
|
183
|
+
it('marks a selected conversation as checked', () => {
|
|
184
|
+
mockSelectedIds = [7]
|
|
185
|
+
const view = renderSelectable()
|
|
186
|
+
|
|
187
|
+
expect(view.getByRole('checkbox', { checked: true })).toBeTruthy()
|
|
188
|
+
})
|
|
189
|
+
|
|
190
|
+
it('opens the conversation outside select mode', () => {
|
|
191
|
+
mockSelectMode = false
|
|
192
|
+
const view = renderSelectable()
|
|
193
|
+
|
|
194
|
+
fireEvent.press(view.getByText('Worship Team'))
|
|
195
|
+
|
|
196
|
+
expect(onPress).toHaveBeenCalled()
|
|
197
|
+
expect(mockToggleSelected).not.toHaveBeenCalled()
|
|
198
|
+
})
|
|
199
|
+
})
|
|
134
200
|
})
|
|
@@ -58,12 +58,15 @@ describe('Conversations archived footer', () => {
|
|
|
58
58
|
|
|
59
59
|
fireEvent.press(view.getByLabelText('View active conversations'))
|
|
60
60
|
|
|
61
|
-
expect(mockSetParams).
|
|
61
|
+
expect(mockSetParams).toHaveBeenCalledTimes(1)
|
|
62
|
+
expect(mockSetParams.mock.calls[0][0]).toStrictEqual({
|
|
62
63
|
title: undefined,
|
|
63
64
|
chat_group_graph_id: undefined,
|
|
64
65
|
group_source_app_name: undefined,
|
|
65
66
|
show_direct_messages: undefined,
|
|
66
67
|
show_archived: undefined,
|
|
68
|
+
show_hidden: undefined,
|
|
69
|
+
show_unread: undefined,
|
|
67
70
|
})
|
|
68
71
|
})
|
|
69
72
|
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import React, { useEffect, useState } from 'react'
|
|
2
|
+
import { Pressable, StyleSheet } from 'react-native'
|
|
3
|
+
import Animated, { FadeIn, LayoutAnimationConfig, ReduceMotion } from 'react-native-reanimated'
|
|
4
|
+
import { useSafeAreaInsets } from 'react-native-safe-area-context'
|
|
5
|
+
import { useConversationsContext } from '../../contexts/conversations_context'
|
|
6
|
+
import { useReduceMotion, useTheme } from '../../hooks'
|
|
7
|
+
import { useBulkConversationActions } from '../../hooks/use_bulk_conversation_actions'
|
|
8
|
+
import { ConversationResource } from '../../types'
|
|
9
|
+
import {
|
|
10
|
+
MAX_FONT_SIZE_MULTIPLIER_LANDMARK,
|
|
11
|
+
isArchivedConversation,
|
|
12
|
+
platformPressedOpacityStyle,
|
|
13
|
+
} from '../../utils'
|
|
14
|
+
import { dismissToast } from '../../utils/toast_store'
|
|
15
|
+
import { Icon, IconString, Text } from '../display'
|
|
16
|
+
|
|
17
|
+
export function BulkConversationActionsBar() {
|
|
18
|
+
const styles = useStyles()
|
|
19
|
+
const reduceMotion = useReduceMotion() ? ReduceMotion.Always : ReduceMotion.Never
|
|
20
|
+
const {
|
|
21
|
+
selectMode,
|
|
22
|
+
selectedIds,
|
|
23
|
+
conversations,
|
|
24
|
+
hideable,
|
|
25
|
+
clearSelection,
|
|
26
|
+
args: { show_hidden: hiddenView = false },
|
|
27
|
+
} = useConversationsContext()
|
|
28
|
+
const { hide, unhide, silence, markRead } = useBulkConversationActions()
|
|
29
|
+
const [pending, setPending] = useState(false)
|
|
30
|
+
|
|
31
|
+
const selected = conversations.filter(({ id }) => selectedIds.includes(id))
|
|
32
|
+
const disabled = pending || selected.length === 0
|
|
33
|
+
const canSilence = !disabled && !selected.some(isArchivedConversation)
|
|
34
|
+
const canHide = canSilence && hideable
|
|
35
|
+
|
|
36
|
+
const run = (action: (_conversations: ConversationResource[]) => Promise<void>) => async () => {
|
|
37
|
+
setPending(true)
|
|
38
|
+
try {
|
|
39
|
+
await action(selected)
|
|
40
|
+
} finally {
|
|
41
|
+
setPending(false)
|
|
42
|
+
clearSelection()
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
useEffect(() => {
|
|
47
|
+
if (selectMode) dismissToast()
|
|
48
|
+
}, [selectMode])
|
|
49
|
+
|
|
50
|
+
return (
|
|
51
|
+
<LayoutAnimationConfig skipEntering>
|
|
52
|
+
{selectMode && (
|
|
53
|
+
<Animated.View
|
|
54
|
+
entering={FadeIn.duration(300).reduceMotion(reduceMotion)}
|
|
55
|
+
style={styles.container}
|
|
56
|
+
testID="bulk-conversation-actions-bar"
|
|
57
|
+
>
|
|
58
|
+
<BulkAction
|
|
59
|
+
title="Mark read"
|
|
60
|
+
iconName="general.check"
|
|
61
|
+
disabled={disabled}
|
|
62
|
+
onPress={run(markRead)}
|
|
63
|
+
/>
|
|
64
|
+
<BulkAction
|
|
65
|
+
title="Silence"
|
|
66
|
+
iconName="general.bellMuted"
|
|
67
|
+
disabled={!canSilence}
|
|
68
|
+
onPress={run(silence)}
|
|
69
|
+
/>
|
|
70
|
+
<BulkAction
|
|
71
|
+
title={hiddenView ? 'Unhide' : 'Hide'}
|
|
72
|
+
iconName={hiddenView ? 'general.showEye' : 'general.hideEye'}
|
|
73
|
+
disabled={!canHide}
|
|
74
|
+
onPress={run(hiddenView ? unhide : hide)}
|
|
75
|
+
/>
|
|
76
|
+
</Animated.View>
|
|
77
|
+
)}
|
|
78
|
+
</LayoutAnimationConfig>
|
|
79
|
+
)
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
function BulkAction({
|
|
83
|
+
title,
|
|
84
|
+
iconName,
|
|
85
|
+
disabled,
|
|
86
|
+
onPress,
|
|
87
|
+
}: {
|
|
88
|
+
title: string
|
|
89
|
+
iconName: IconString
|
|
90
|
+
disabled: boolean
|
|
91
|
+
onPress: () => void
|
|
92
|
+
}) {
|
|
93
|
+
const styles = useStyles({ disabled })
|
|
94
|
+
|
|
95
|
+
return (
|
|
96
|
+
<Pressable
|
|
97
|
+
onPress={onPress}
|
|
98
|
+
disabled={disabled}
|
|
99
|
+
accessibilityRole="button"
|
|
100
|
+
accessibilityState={{ disabled }}
|
|
101
|
+
style={({ pressed }) => [styles.action, pressed && platformPressedOpacityStyle]}
|
|
102
|
+
>
|
|
103
|
+
<Icon name={iconName} size={20} style={styles.actionIcon} accessibilityElementsHidden />
|
|
104
|
+
<Text style={styles.actionTitle} maxFontSizeMultiplier={MAX_FONT_SIZE_MULTIPLIER_LANDMARK}>
|
|
105
|
+
{title}
|
|
106
|
+
</Text>
|
|
107
|
+
</Pressable>
|
|
108
|
+
)
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
const useStyles = ({ disabled = false }: { disabled?: boolean } = {}) => {
|
|
112
|
+
const { bottom } = useSafeAreaInsets()
|
|
113
|
+
const { colors } = useTheme()
|
|
114
|
+
const containerVerticalPadding = 12
|
|
115
|
+
const actionColor = disabled ? colors.textColorDefaultDisabled : colors.textColorDefaultPrimary
|
|
116
|
+
|
|
117
|
+
return StyleSheet.create({
|
|
118
|
+
container: {
|
|
119
|
+
flexDirection: 'row',
|
|
120
|
+
backgroundColor: colors.surfaceColor090,
|
|
121
|
+
paddingHorizontal: 16,
|
|
122
|
+
paddingTop: containerVerticalPadding,
|
|
123
|
+
paddingBottom: bottom + containerVerticalPadding,
|
|
124
|
+
borderTopWidth: 1,
|
|
125
|
+
borderTopColor: colors.borderColorDefaultDim,
|
|
126
|
+
},
|
|
127
|
+
action: {
|
|
128
|
+
flex: 1,
|
|
129
|
+
alignItems: 'center',
|
|
130
|
+
gap: 4,
|
|
131
|
+
},
|
|
132
|
+
actionIcon: {
|
|
133
|
+
color: actionColor,
|
|
134
|
+
},
|
|
135
|
+
actionTitle: {
|
|
136
|
+
color: actionColor,
|
|
137
|
+
fontWeight: '600',
|
|
138
|
+
},
|
|
139
|
+
})
|
|
140
|
+
}
|
|
@@ -32,12 +32,14 @@ export function ConversationActions({
|
|
|
32
32
|
style,
|
|
33
33
|
onPress,
|
|
34
34
|
accessibilityLabel,
|
|
35
|
+
selected,
|
|
35
36
|
}: {
|
|
36
37
|
children: ReactNode
|
|
37
38
|
conversation: ConversationResource
|
|
38
39
|
onPress: () => void
|
|
39
40
|
style?: StyleProp<ViewStyle>
|
|
40
41
|
accessibilityLabel?: string
|
|
42
|
+
selected?: boolean
|
|
41
43
|
}) {
|
|
42
44
|
const swipeableRef = useRef<SwipeableMethods>(null)
|
|
43
45
|
const navigation = useNavigation()
|
|
@@ -67,6 +69,8 @@ export function ConversationActions({
|
|
|
67
69
|
const isConversationEmpty = conversation.lastMessageCreatedAt === null
|
|
68
70
|
const canMute = !isArchivedConversation(conversation)
|
|
69
71
|
const canHide = hideable && hideConversationsEnabled && !isArchivedConversation(conversation)
|
|
72
|
+
const selectMode = selected !== undefined
|
|
73
|
+
const canOpenActions = hideable && hideConversationsEnabled && !selectMode
|
|
70
74
|
|
|
71
75
|
const handleSwipeableClose = useCallback(() => {
|
|
72
76
|
setDisabled(false)
|
|
@@ -97,8 +101,8 @@ export function ConversationActions({
|
|
|
97
101
|
if (disabled) return
|
|
98
102
|
|
|
99
103
|
Haptic.impactLight()
|
|
100
|
-
navigation.navigate('ConversationActions', { conversation_id: conversation.id })
|
|
101
|
-
}, [disabled, navigation, conversation.id])
|
|
104
|
+
navigation.navigate('ConversationActions', { conversation_id: conversation.id, read, muted })
|
|
105
|
+
}, [disabled, navigation, conversation.id, read, muted])
|
|
102
106
|
|
|
103
107
|
const handleLatestMessageUnread = useCallback(() => {
|
|
104
108
|
markRead(!read)
|
|
@@ -132,11 +136,9 @@ export function ConversationActions({
|
|
|
132
136
|
]
|
|
133
137
|
: []
|
|
134
138
|
|
|
135
|
-
const accessibilityActions =
|
|
136
|
-
|
|
137
|
-
...hideAccessibilityAction,
|
|
138
|
-
...readAccessibilityAction,
|
|
139
|
-
]
|
|
139
|
+
const accessibilityActions = selectMode
|
|
140
|
+
? []
|
|
141
|
+
: [...muteAccessibilityAction, ...hideAccessibilityAction, ...readAccessibilityAction]
|
|
140
142
|
|
|
141
143
|
const handleAccessibilityAction = useCallback(
|
|
142
144
|
(event: AccessibilityActionEvent) => {
|
|
@@ -162,6 +164,10 @@ export function ConversationActions({
|
|
|
162
164
|
[handleLatestMessageUnread, handleMute, handleHide]
|
|
163
165
|
)
|
|
164
166
|
|
|
167
|
+
useEffect(() => {
|
|
168
|
+
if (selectMode) handleSwipeableClose()
|
|
169
|
+
}, [selectMode, handleSwipeableClose])
|
|
170
|
+
|
|
165
171
|
useEffect(() => {
|
|
166
172
|
if (activeConversationId === conversation.id) return
|
|
167
173
|
|
|
@@ -171,6 +177,7 @@ export function ConversationActions({
|
|
|
171
177
|
return (
|
|
172
178
|
<ReanimatedSwipeable
|
|
173
179
|
ref={swipeableRef}
|
|
180
|
+
enabled={!selectMode}
|
|
174
181
|
childrenContainerStyle={styles.swipeableChildContainer}
|
|
175
182
|
containerStyle={styles.swipeableContainer}
|
|
176
183
|
overshootFriction={8}
|
|
@@ -199,11 +206,12 @@ export function ConversationActions({
|
|
|
199
206
|
<Pressable
|
|
200
207
|
testID={`conversation-${conversation.id}`}
|
|
201
208
|
onPress={handlePress}
|
|
202
|
-
onLongPress={
|
|
209
|
+
onLongPress={canOpenActions ? handleLongPress : undefined}
|
|
203
210
|
style={({ pressed }) => [style, pressed && platformPressedOpacityStyle]}
|
|
204
211
|
android_ripple={{ color: androidRippleColor, borderless: false, foreground: true }}
|
|
205
212
|
accessibilityLabel={accessibilityLabel}
|
|
206
|
-
accessibilityRole=
|
|
213
|
+
accessibilityRole={selectMode ? 'checkbox' : 'button'}
|
|
214
|
+
accessibilityState={selectMode ? { checked: selected } : undefined}
|
|
207
215
|
accessibilityActions={accessibilityActions}
|
|
208
216
|
onAccessibilityAction={handleAccessibilityAction}
|
|
209
217
|
>
|