@planningcenter/chat-react-native 4.8.0-rc.8 → 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/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/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/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/theme.ts +20 -21
|
@@ -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()
|
|
@@ -9,6 +9,7 @@ import { LinkingAdapter } from './linking'
|
|
|
9
9
|
import { LogAdapter } from './log'
|
|
10
10
|
import { MenuAdapter } from './menu'
|
|
11
11
|
import { StorageAdapter } from './storage_adapter'
|
|
12
|
+
import { UpdatesAdapter } from './updates'
|
|
12
13
|
import { VideoAdapter } from './video'
|
|
13
14
|
|
|
14
15
|
type ChatConfigurations = {
|
|
@@ -21,6 +22,7 @@ type ChatConfigurations = {
|
|
|
21
22
|
linking?: LinkingAdapter
|
|
22
23
|
haptic?: HapticAdapter
|
|
23
24
|
menu?: MenuAdapter
|
|
25
|
+
updates?: UpdatesAdapter
|
|
24
26
|
}
|
|
25
27
|
|
|
26
28
|
export class ChatAdapters {
|
|
@@ -34,6 +36,7 @@ export class ChatAdapters {
|
|
|
34
36
|
Linking = configurations.linking || new LinkingAdapter(RNLinking)
|
|
35
37
|
Haptic = configurations.haptic || new HapticAdapter()
|
|
36
38
|
Menu = configurations.menu || new MenuAdapter()
|
|
39
|
+
Updates = configurations.updates || new UpdatesAdapter()
|
|
37
40
|
}
|
|
38
41
|
}
|
|
39
42
|
|
|
@@ -87,6 +90,8 @@ export let Haptic: HapticAdapter = new HapticAdapter()
|
|
|
87
90
|
|
|
88
91
|
export let Menu: MenuAdapter = new MenuAdapter()
|
|
89
92
|
|
|
93
|
+
export let Updates: UpdatesAdapter = new UpdatesAdapter()
|
|
94
|
+
|
|
90
95
|
export let Storage = new StorageAdapter({
|
|
91
96
|
getItem: AsyncStorage.getItem,
|
|
92
97
|
setItem: AsyncStorage.setItem,
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { noop } from 'lodash'
|
|
2
|
+
|
|
3
|
+
interface Updates {
|
|
4
|
+
useDownloadedUpdateId: () => string | undefined
|
|
5
|
+
restart: () => void
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export class UpdatesAdapter {
|
|
9
|
+
useDownloadedUpdateId: () => string | undefined
|
|
10
|
+
restart: () => void
|
|
11
|
+
|
|
12
|
+
constructor(methods?: Updates) {
|
|
13
|
+
this.useDownloadedUpdateId = methods?.useDownloadedUpdateId ?? (() => undefined)
|
|
14
|
+
this.restart = methods?.restart ?? noop
|
|
15
|
+
}
|
|
16
|
+
}
|
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',
|