@planningcenter/chat-react-native 3.39.0-rc.1 → 3.39.0-rc.11
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/messages_disabled_banners.d.ts +6 -1
- package/build/components/conversation/messages_disabled_banners.d.ts.map +1 -1
- package/build/components/conversation/messages_disabled_banners.js +8 -2
- package/build/components/conversation/messages_disabled_banners.js.map +1 -1
- package/build/components/primitive/form_sheet.d.ts +1 -0
- package/build/components/primitive/form_sheet.d.ts.map +1 -1
- package/build/components/primitive/form_sheet.js +17 -7
- package/build/components/primitive/form_sheet.js.map +1 -1
- package/build/contexts/api_provider.js +2 -1
- package/build/contexts/api_provider.js.map +1 -1
- package/build/contexts/conversations_context.d.ts.map +1 -1
- package/build/contexts/conversations_context.js +6 -2
- package/build/contexts/conversations_context.js.map +1 -1
- package/build/hooks/direct_messages/use_direct_message_candidates.d.ts.map +1 -1
- package/build/hooks/direct_messages/use_direct_message_candidates.js +1 -0
- package/build/hooks/direct_messages/use_direct_message_candidates.js.map +1 -1
- package/build/hooks/groups/use_group_chat_conversation_payload.d.ts.map +1 -1
- package/build/hooks/groups/use_group_chat_conversation_payload.js +2 -1
- package/build/hooks/groups/use_group_chat_conversation_payload.js.map +1 -1
- package/build/hooks/index.d.ts +1 -0
- package/build/hooks/index.d.ts.map +1 -1
- package/build/hooks/index.js +1 -0
- package/build/hooks/index.js.map +1 -1
- package/build/hooks/services/use_services_chat_conversation_payload.d.ts.map +1 -1
- package/build/hooks/services/use_services_chat_conversation_payload.js +2 -1
- package/build/hooks/services/use_services_chat_conversation_payload.js.map +1 -1
- package/build/hooks/use_api.d.ts +5 -1
- package/build/hooks/use_api.d.ts.map +1 -1
- package/build/hooks/use_api.js +2 -1
- package/build/hooks/use_api.js.map +1 -1
- package/build/hooks/use_chat_configuration.d.ts.map +1 -1
- package/build/hooks/use_chat_configuration.js +2 -1
- package/build/hooks/use_chat_configuration.js.map +1 -1
- package/build/hooks/use_chat_permissions.d.ts.map +1 -1
- package/build/hooks/use_chat_permissions.js +4 -1
- package/build/hooks/use_chat_permissions.js.map +1 -1
- package/build/hooks/use_conversation.d.ts.map +1 -1
- package/build/hooks/use_conversation.js +1 -0
- package/build/hooks/use_conversation.js.map +1 -1
- package/build/hooks/use_conversation_jolt_events.d.ts.map +1 -1
- package/build/hooks/use_conversation_jolt_events.js +2 -2
- package/build/hooks/use_conversation_jolt_events.js.map +1 -1
- package/build/hooks/use_current_person.d.ts.map +1 -1
- package/build/hooks/use_current_person.js +4 -2
- package/build/hooks/use_current_person.js.map +1 -1
- package/build/hooks/use_features.d.ts.map +1 -1
- package/build/hooks/use_features.js +2 -1
- package/build/hooks/use_features.js.map +1 -1
- package/build/hooks/use_groups.d.ts.map +1 -1
- package/build/hooks/use_groups.js +2 -1
- package/build/hooks/use_groups.js.map +1 -1
- package/build/hooks/use_groups_groups.d.ts.map +1 -1
- package/build/hooks/use_groups_groups.js +2 -1
- package/build/hooks/use_groups_groups.js.map +1 -1
- package/build/hooks/use_has_direct_messages.d.ts +2 -0
- package/build/hooks/use_has_direct_messages.d.ts.map +1 -0
- package/build/hooks/use_has_direct_messages.js +17 -0
- package/build/hooks/use_has_direct_messages.js.map +1 -0
- package/build/hooks/use_jolt.d.ts.map +1 -1
- package/build/hooks/use_jolt.js +2 -1
- package/build/hooks/use_jolt.js.map +1 -1
- package/build/hooks/use_organization.d.ts.map +1 -1
- package/build/hooks/use_organization.js +4 -1
- package/build/hooks/use_organization.js.map +1 -1
- package/build/hooks/use_person_settings.d.ts +6 -0
- package/build/hooks/use_person_settings.d.ts.map +1 -0
- package/build/hooks/use_person_settings.js +26 -0
- package/build/hooks/use_person_settings.js.map +1 -0
- package/build/navigation/index.d.ts +13 -0
- package/build/navigation/index.d.ts.map +1 -1
- package/build/navigation/index.js +9 -0
- package/build/navigation/index.js.map +1 -1
- package/build/screens/conversation_details_screen.d.ts.map +1 -1
- package/build/screens/conversation_details_screen.js +2 -1
- package/build/screens/conversation_details_screen.js.map +1 -1
- package/build/screens/conversation_filters/components/conversation_filters.d.ts.map +1 -1
- package/build/screens/conversation_filters/components/conversation_filters.js +20 -5
- package/build/screens/conversation_filters/components/conversation_filters.js.map +1 -1
- package/build/screens/conversation_filters/components/rows.d.ts +2 -1
- package/build/screens/conversation_filters/components/rows.d.ts.map +1 -1
- package/build/screens/conversation_filters/components/rows.js +2 -2
- package/build/screens/conversation_filters/components/rows.js.map +1 -1
- package/build/screens/conversation_filters/context/conversation_filter_context.d.ts.map +1 -1
- package/build/screens/conversation_filters/context/conversation_filter_context.js +4 -0
- package/build/screens/conversation_filters/context/conversation_filter_context.js.map +1 -1
- package/build/screens/conversation_filters/filter_types.d.ts +1 -0
- package/build/screens/conversation_filters/filter_types.d.ts.map +1 -1
- package/build/screens/conversation_filters/filter_types.js +1 -0
- package/build/screens/conversation_filters/filter_types.js.map +1 -1
- package/build/screens/conversation_filters/screen_props.d.ts +1 -0
- package/build/screens/conversation_filters/screen_props.d.ts.map +1 -1
- package/build/screens/conversation_filters/screen_props.js.map +1 -1
- package/build/screens/conversation_screen.d.ts.map +1 -1
- package/build/screens/conversation_screen.js +1 -1
- package/build/screens/conversation_screen.js.map +1 -1
- package/build/screens/conversation_select_recipients/conversation_select_direct_message_recipients_screen.d.ts +1 -2
- package/build/screens/conversation_select_recipients/conversation_select_direct_message_recipients_screen.d.ts.map +1 -1
- package/build/screens/conversation_select_recipients/conversation_select_direct_message_recipients_screen.js +319 -10
- package/build/screens/conversation_select_recipients/conversation_select_direct_message_recipients_screen.js.map +1 -1
- package/build/screens/conversation_select_type_screen.d.ts.map +1 -1
- package/build/screens/conversation_select_type_screen.js +4 -2
- package/build/screens/conversation_select_type_screen.js.map +1 -1
- package/build/screens/conversations/components/list_header_component.d.ts.map +1 -1
- package/build/screens/conversations/components/list_header_component.js +35 -17
- package/build/screens/conversations/components/list_header_component.js.map +1 -1
- package/build/screens/conversations/conversations_screen.d.ts +1 -0
- package/build/screens/conversations/conversations_screen.d.ts.map +1 -1
- package/build/screens/conversations/conversations_screen.js.map +1 -1
- package/build/screens/get_help_screen.d.ts.map +1 -1
- package/build/screens/get_help_screen.js +2 -18
- package/build/screens/get_help_screen.js.map +1 -1
- package/build/screens/index.d.ts +1 -0
- package/build/screens/index.d.ts.map +1 -1
- package/build/screens/index.js +1 -0
- package/build/screens/index.js.map +1 -1
- package/build/screens/settings_screen.d.ts +5 -0
- package/build/screens/settings_screen.d.ts.map +1 -0
- package/build/screens/settings_screen.js +56 -0
- package/build/screens/settings_screen.js.map +1 -0
- package/build/types/jolt_events/conversation_events.d.ts +2 -0
- package/build/types/jolt_events/conversation_events.d.ts.map +1 -1
- package/build/types/jolt_events/conversation_events.js.map +1 -1
- package/build/types/resources/conversation.d.ts +2 -0
- package/build/types/resources/conversation.d.ts.map +1 -1
- package/build/types/resources/conversation.js.map +1 -1
- package/build/types/resources/organization.d.ts +1 -0
- package/build/types/resources/organization.d.ts.map +1 -1
- package/build/types/resources/organization.js.map +1 -1
- package/build/types/resources/person.d.ts +1 -0
- package/build/types/resources/person.d.ts.map +1 -1
- package/build/types/resources/person.js.map +1 -1
- package/build/utils/request/conversation.d.ts +2 -1
- package/build/utils/request/conversation.d.ts.map +1 -1
- package/build/utils/request/conversation.js +15 -6
- package/build/utils/request/conversation.js.map +1 -1
- package/build/utils/time.d.ts +8 -0
- package/build/utils/time.d.ts.map +1 -0
- package/build/utils/time.js +15 -0
- package/build/utils/time.js.map +1 -0
- package/package.json +2 -2
- package/src/components/conversation/messages_disabled_banners.tsx +16 -2
- package/src/components/primitive/form_sheet.tsx +23 -6
- package/src/contexts/api_provider.tsx +4 -1
- package/src/contexts/conversations_context.tsx +6 -2
- package/src/hooks/direct_messages/use_direct_message_candidates.ts +1 -0
- package/src/hooks/groups/use_group_chat_conversation_payload.ts +2 -1
- package/src/hooks/index.ts +1 -0
- package/src/hooks/services/use_services_chat_conversation_payload.ts +2 -1
- package/src/hooks/use_api.ts +10 -1
- package/src/hooks/use_chat_configuration.ts +2 -1
- package/src/hooks/use_chat_permissions.ts +4 -1
- package/src/hooks/use_conversation.ts +1 -0
- package/src/hooks/use_conversation_jolt_events.ts +3 -2
- package/src/hooks/use_current_person.ts +4 -2
- package/src/hooks/use_features.ts +2 -1
- package/src/hooks/use_groups.ts +16 -12
- package/src/hooks/use_groups_groups.ts +19 -15
- package/src/hooks/use_has_direct_messages.ts +21 -0
- package/src/hooks/use_jolt.ts +2 -1
- package/src/hooks/use_organization.ts +4 -1
- package/src/hooks/use_person_settings.ts +29 -0
- package/src/navigation/index.tsx +11 -0
- package/src/screens/conversation_details_screen.tsx +2 -1
- package/src/screens/conversation_filters/components/conversation_filters.tsx +25 -5
- package/src/screens/conversation_filters/components/rows.tsx +16 -3
- package/src/screens/conversation_filters/context/conversation_filter_context.tsx +4 -0
- package/src/screens/conversation_filters/filter_types.ts +1 -0
- package/src/screens/conversation_filters/screen_props.ts +1 -0
- package/src/screens/conversation_screen.tsx +2 -1
- package/src/screens/conversation_select_recipients/conversation_select_direct_message_recipients_screen.tsx +513 -10
- package/src/screens/conversation_select_type_screen.tsx +6 -2
- package/src/screens/conversations/components/list_header_component.tsx +84 -34
- package/src/screens/conversations/conversations_screen.tsx +1 -0
- package/src/screens/get_help_screen.tsx +2 -29
- package/src/screens/index.ts +1 -0
- package/src/screens/settings_screen.tsx +67 -0
- package/src/types/jolt_events/conversation_events.ts +2 -0
- package/src/types/resources/conversation.ts +3 -0
- package/src/types/resources/organization.ts +1 -0
- package/src/types/resources/person.ts +1 -0
- package/src/utils/__tests__/conversation.test.ts +14 -0
- package/src/utils/request/conversation.ts +13 -5
- package/src/utils/time.ts +17 -0
|
@@ -2,12 +2,18 @@ import { RouteProp, useNavigation, useRoute } from '@react-navigation/native'
|
|
|
2
2
|
import React, { useCallback, useMemo } from 'react'
|
|
3
3
|
import { Alert, ScrollView, StyleSheet, View } from 'react-native'
|
|
4
4
|
import { Heading, TextButton, ToggleButton } from '../../../components'
|
|
5
|
-
import {
|
|
6
|
-
|
|
5
|
+
import {
|
|
6
|
+
useAtFontScaleBreakpoint,
|
|
7
|
+
useCanCreateConversations,
|
|
8
|
+
useCurrentPersonCache,
|
|
9
|
+
useDirectMessagesEnabled,
|
|
10
|
+
useHasDirectMessages,
|
|
11
|
+
useNewConversationEntry,
|
|
12
|
+
useTheme,
|
|
13
|
+
} from '../../../hooks'
|
|
7
14
|
import { useAppName } from '../../../hooks/use_app_name'
|
|
8
15
|
import { useMarkAllRead } from '../../../hooks/use_conversations_actions'
|
|
9
16
|
import { useCanDisplayGroups } from '../../../hooks/use_groups'
|
|
10
|
-
import { useNewConversationEntry } from '../../../hooks/use_new_conversation_entry'
|
|
11
17
|
import { useNewConversationFromFilter } from '../../../hooks/use_new_conversation_from_filter'
|
|
12
18
|
import { GraphId } from '../../../types/resources/group_resource'
|
|
13
19
|
import { MAX_FONT_SIZE_MULTIPLIER_LANDMARK } from '../../../utils'
|
|
@@ -22,6 +28,7 @@ enum FilterTypes {
|
|
|
22
28
|
All = 'All',
|
|
23
29
|
Groups = 'Groups',
|
|
24
30
|
Teams = 'Teams',
|
|
31
|
+
DMs = 'DMs',
|
|
25
32
|
More = 'More',
|
|
26
33
|
}
|
|
27
34
|
|
|
@@ -29,8 +36,15 @@ export const ListHeaderComponent = () => {
|
|
|
29
36
|
const navigation = useNavigation()
|
|
30
37
|
const canFilterByTeams = useCanDisplayGroups({ source_app_name: 'Services', source_type: 'Team' })
|
|
31
38
|
const canFilterByGroups = useCanDisplayGroups({ source_app_name: 'Groups', source_type: 'Group' })
|
|
39
|
+
const directMessagesEnabled = useDirectMessagesEnabled()
|
|
40
|
+
const hasDirectMessages = useHasDirectMessages()
|
|
41
|
+
const canFilterByDMs = directMessagesEnabled && hasDirectMessages
|
|
32
42
|
const route = useRoute<RouteProp<ConversationsScreenProps['route']>>()
|
|
33
|
-
const {
|
|
43
|
+
const {
|
|
44
|
+
chat_group_graph_id,
|
|
45
|
+
group_source_app_name = '',
|
|
46
|
+
show_direct_messages,
|
|
47
|
+
} = route.params || {}
|
|
34
48
|
const currentPersonCache = useCurrentPersonCache()
|
|
35
49
|
const { markAllRead, isPending } = useMarkAllRead()
|
|
36
50
|
const canCreateConversations = useCanCreateConversations()
|
|
@@ -47,10 +61,12 @@ export const ListHeaderComponent = () => {
|
|
|
47
61
|
return FilterTypes.Groups
|
|
48
62
|
} else if (/services/i.test(group_source_app_name)) {
|
|
49
63
|
return FilterTypes.Teams
|
|
64
|
+
} else if (show_direct_messages) {
|
|
65
|
+
return FilterTypes.DMs
|
|
50
66
|
}
|
|
51
67
|
|
|
52
68
|
return FilterTypes.All
|
|
53
|
-
}, [chat_group_graph_id, group_source_app_name])
|
|
69
|
+
}, [chat_group_graph_id, group_source_app_name, show_direct_messages])
|
|
54
70
|
|
|
55
71
|
const handleNewConversationNavigation = useCallback(() => {
|
|
56
72
|
if (newConversationFromFilter || entryMode === 'select_type') {
|
|
@@ -75,6 +91,10 @@ export const ListHeaderComponent = () => {
|
|
|
75
91
|
}
|
|
76
92
|
}, [navigation, route.params, entryMode, newConversationFromFilter])
|
|
77
93
|
|
|
94
|
+
const handleChatSettings = useCallback(() => {
|
|
95
|
+
navigation.navigate('ChatSettings', {})
|
|
96
|
+
}, [navigation])
|
|
97
|
+
|
|
78
98
|
const handleMoreOptions = useCallback(() => {
|
|
79
99
|
navigation.navigate('ConversationsMoreActions')
|
|
80
100
|
}, [navigation])
|
|
@@ -83,8 +103,9 @@ export const ListHeaderComponent = () => {
|
|
|
83
103
|
navigation.navigate('ConversationFilters', {
|
|
84
104
|
chat_group_graph_id,
|
|
85
105
|
group_source_app_name,
|
|
106
|
+
show_direct_messages,
|
|
86
107
|
})
|
|
87
|
-
}, [navigation, chat_group_graph_id, group_source_app_name])
|
|
108
|
+
}, [navigation, chat_group_graph_id, group_source_app_name, show_direct_messages])
|
|
88
109
|
|
|
89
110
|
const handleMarkAllRead = useCallback(() => {
|
|
90
111
|
currentPersonCache.update({ unreadCount: 0 })
|
|
@@ -103,8 +124,8 @@ export const ListHeaderComponent = () => {
|
|
|
103
124
|
|
|
104
125
|
const hasSomeSourceFilterCapability = canFilterByTeams || canFilterByGroups
|
|
105
126
|
const hasMultiSourceFilterCapabilities = canFilterByTeams && canFilterByGroups
|
|
106
|
-
const
|
|
107
|
-
|
|
127
|
+
const showFilterRow = hasMultiSourceFilterCapabilities || canFilterByDMs
|
|
128
|
+
const shouldShowHeaderFiltersButton = hasSomeSourceFilterCapability && !showFilterRow
|
|
108
129
|
const moreFiltersButtonA11yLabel = shouldShowHeaderFiltersButton
|
|
109
130
|
? 'View filters'
|
|
110
131
|
: 'View more filters'
|
|
@@ -136,6 +157,14 @@ export const ListHeaderComponent = () => {
|
|
|
136
157
|
</TextButton>
|
|
137
158
|
</View>
|
|
138
159
|
<View style={styles.actionsContainer}>
|
|
160
|
+
{directMessagesEnabled && (
|
|
161
|
+
<ListHeaderActionButton
|
|
162
|
+
name="general.cog"
|
|
163
|
+
onPress={handleChatSettings}
|
|
164
|
+
accessibilityLabel="Chat settings"
|
|
165
|
+
maxFontSizeMultiplier={MAX_FONT_SIZE_MULTIPLIER_LANDMARK}
|
|
166
|
+
/>
|
|
167
|
+
)}
|
|
139
168
|
{canCreateConversations && (
|
|
140
169
|
<ListHeaderActionButton
|
|
141
170
|
name="churchCenter.signups"
|
|
@@ -156,7 +185,7 @@ export const ListHeaderComponent = () => {
|
|
|
156
185
|
{shouldShowHeaderFiltersButton && <ToggleButton {...moreFiltersButtonProps} />}
|
|
157
186
|
</View>
|
|
158
187
|
</View>
|
|
159
|
-
{
|
|
188
|
+
{showFilterRow && (
|
|
160
189
|
<ScrollView
|
|
161
190
|
horizontal
|
|
162
191
|
showsHorizontalScrollIndicator={false}
|
|
@@ -170,36 +199,57 @@ export const ListHeaderComponent = () => {
|
|
|
170
199
|
navigation.setParams({
|
|
171
200
|
chat_group_graph_id: undefined,
|
|
172
201
|
group_source_app_name: undefined,
|
|
202
|
+
show_direct_messages: undefined,
|
|
173
203
|
})
|
|
174
204
|
}
|
|
175
205
|
accessibilityLabel="Show all conversations"
|
|
176
206
|
style={styles.filterButton}
|
|
177
207
|
/>
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
208
|
+
{canFilterByGroups && (
|
|
209
|
+
<ToggleButton
|
|
210
|
+
title={FilterTypes.Groups}
|
|
211
|
+
active={active === FilterTypes.Groups}
|
|
212
|
+
onPress={() =>
|
|
213
|
+
navigation.setParams({
|
|
214
|
+
chat_group_graph_id: undefined,
|
|
215
|
+
group_source_app_name: 'Groups',
|
|
216
|
+
show_direct_messages: undefined,
|
|
217
|
+
})
|
|
218
|
+
}
|
|
219
|
+
accessibilityLabel="Filter to group conversations"
|
|
220
|
+
style={styles.filterButton}
|
|
221
|
+
/>
|
|
222
|
+
)}
|
|
223
|
+
{canFilterByTeams && (
|
|
224
|
+
<ToggleButton
|
|
225
|
+
title={FilterTypes.Teams}
|
|
226
|
+
active={active === FilterTypes.Teams}
|
|
227
|
+
onPress={() =>
|
|
228
|
+
navigation.setParams({
|
|
229
|
+
chat_group_graph_id: undefined,
|
|
230
|
+
group_source_app_name: 'Services',
|
|
231
|
+
show_direct_messages: undefined,
|
|
232
|
+
})
|
|
233
|
+
}
|
|
234
|
+
accessibilityLabel="Filter to team conversations"
|
|
235
|
+
style={styles.filterButton}
|
|
236
|
+
/>
|
|
237
|
+
)}
|
|
238
|
+
{canFilterByDMs && (
|
|
239
|
+
<ToggleButton
|
|
240
|
+
title={FilterTypes.DMs}
|
|
241
|
+
active={active === FilterTypes.DMs}
|
|
242
|
+
onPress={() =>
|
|
243
|
+
navigation.setParams({
|
|
244
|
+
chat_group_graph_id: undefined,
|
|
245
|
+
group_source_app_name: undefined,
|
|
246
|
+
show_direct_messages: true,
|
|
247
|
+
})
|
|
248
|
+
}
|
|
249
|
+
accessibilityLabel="Filter to direct message conversations"
|
|
250
|
+
style={styles.filterButton}
|
|
251
|
+
/>
|
|
252
|
+
)}
|
|
203
253
|
<ToggleButton {...moreFiltersButtonProps} />
|
|
204
254
|
</ScrollView>
|
|
205
255
|
)}
|
|
@@ -12,6 +12,7 @@ export type ConversationsScreenProps = StaticScreenProps<{
|
|
|
12
12
|
title?: string
|
|
13
13
|
chat_group_graph_id?: GraphId
|
|
14
14
|
group_source_app_name?: AppName
|
|
15
|
+
show_direct_messages?: boolean
|
|
15
16
|
}>
|
|
16
17
|
|
|
17
18
|
export function ConversationsScreen({ route }: ConversationsScreenProps) {
|
|
@@ -4,6 +4,7 @@ import { Alert, Linking, StyleSheet, View } from 'react-native'
|
|
|
4
4
|
import { Heading, PressableRow, Text, TextInlineButton } from '../components'
|
|
5
5
|
import { useApiGet, useTheme } from '../hooks'
|
|
6
6
|
import { useAppName } from '../hooks/use_app_name'
|
|
7
|
+
import { useOrganization } from '../hooks/use_organization'
|
|
7
8
|
import { ResourceObject } from '../types'
|
|
8
9
|
import { Clipboard } from '../utils'
|
|
9
10
|
|
|
@@ -13,34 +14,6 @@ type GetHelpScreenRouteProps = {
|
|
|
13
14
|
|
|
14
15
|
type GetHelpScreenProps = StaticScreenProps<GetHelpScreenRouteProps>
|
|
15
16
|
|
|
16
|
-
interface OrganizationResource extends ResourceObject {
|
|
17
|
-
id: number
|
|
18
|
-
name: string
|
|
19
|
-
contactEmail: string
|
|
20
|
-
contactPhoneNumber: string
|
|
21
|
-
churchCenterChatHelpUrl: string
|
|
22
|
-
servicesChatHelpUrl: string
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
const useOrganization = () => {
|
|
26
|
-
const { data: organization } = useApiGet<OrganizationResource>({
|
|
27
|
-
url: '/',
|
|
28
|
-
data: {
|
|
29
|
-
fields: {
|
|
30
|
-
Organization: [
|
|
31
|
-
'contact_phone_number',
|
|
32
|
-
'contact_email',
|
|
33
|
-
'name',
|
|
34
|
-
'church_center_chat_help_url',
|
|
35
|
-
'services_chat_help_url',
|
|
36
|
-
],
|
|
37
|
-
},
|
|
38
|
-
},
|
|
39
|
-
})
|
|
40
|
-
|
|
41
|
-
return organization
|
|
42
|
-
}
|
|
43
|
-
|
|
44
17
|
interface HelpUrlResource extends ResourceObject {
|
|
45
18
|
id: number
|
|
46
19
|
link: string
|
|
@@ -67,7 +40,7 @@ export const GetHelpScreen = ({ route }: GetHelpScreenProps) => {
|
|
|
67
40
|
const styles = useStyles()
|
|
68
41
|
const appName = useAppName()
|
|
69
42
|
const navigation = useNavigation()
|
|
70
|
-
const organization = useOrganization()
|
|
43
|
+
const { data: organization } = useOrganization()
|
|
71
44
|
const contactPresent = organization?.contactEmail || organization?.contactPhoneNumber
|
|
72
45
|
const helpUrls = useHelpUrls()
|
|
73
46
|
const appSpecificHelpUrls = useMemo(
|
package/src/screens/index.ts
CHANGED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { StaticScreenProps } from '@react-navigation/native'
|
|
2
|
+
import React from 'react'
|
|
3
|
+
import { StyleSheet, View } from 'react-native'
|
|
4
|
+
import { Heading, Text } from '../components'
|
|
5
|
+
import { Switch } from '../components/display/switch'
|
|
6
|
+
import { useTheme } from '../hooks'
|
|
7
|
+
import { usePersonSettings } from '../hooks/use_person_settings'
|
|
8
|
+
|
|
9
|
+
export type SettingsScreenProps = StaticScreenProps<{}>
|
|
10
|
+
|
|
11
|
+
export function SettingsScreen({}: SettingsScreenProps) {
|
|
12
|
+
const styles = useStyles()
|
|
13
|
+
const { directMessagesDisabled, setDirectMessagesDisabled, isMutating } = usePersonSettings()
|
|
14
|
+
|
|
15
|
+
return (
|
|
16
|
+
<View style={styles.container}>
|
|
17
|
+
<View style={styles.sectionOuter}>
|
|
18
|
+
<View style={styles.sectionHeader}>
|
|
19
|
+
<Heading variant="h2">Messages</Heading>
|
|
20
|
+
</View>
|
|
21
|
+
<View style={styles.settingRow}>
|
|
22
|
+
<View style={styles.settingRowText}>
|
|
23
|
+
<Text>Allow direct messages</Text>
|
|
24
|
+
<Text variant="tertiary">
|
|
25
|
+
When disabled, you won't be able to participate in direct messages.
|
|
26
|
+
</Text>
|
|
27
|
+
</View>
|
|
28
|
+
<Switch
|
|
29
|
+
value={!directMessagesDisabled}
|
|
30
|
+
onValueChange={enabled => setDirectMessagesDisabled(!enabled)}
|
|
31
|
+
disabled={isMutating}
|
|
32
|
+
/>
|
|
33
|
+
</View>
|
|
34
|
+
</View>
|
|
35
|
+
</View>
|
|
36
|
+
)
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const useStyles = () => {
|
|
40
|
+
const { colors } = useTheme()
|
|
41
|
+
return StyleSheet.create({
|
|
42
|
+
container: {
|
|
43
|
+
flex: 1,
|
|
44
|
+
},
|
|
45
|
+
sectionOuter: {
|
|
46
|
+
paddingLeft: 16,
|
|
47
|
+
},
|
|
48
|
+
sectionHeader: {
|
|
49
|
+
paddingRight: 16,
|
|
50
|
+
paddingTop: 24,
|
|
51
|
+
paddingBottom: 12,
|
|
52
|
+
borderBottomWidth: 1,
|
|
53
|
+
borderBottomColor: colors.borderColorDefaultBase,
|
|
54
|
+
},
|
|
55
|
+
settingRow: {
|
|
56
|
+
flexDirection: 'row',
|
|
57
|
+
alignItems: 'flex-start',
|
|
58
|
+
justifyContent: 'space-between',
|
|
59
|
+
paddingRight: 16,
|
|
60
|
+
paddingVertical: 12,
|
|
61
|
+
},
|
|
62
|
+
settingRowText: {
|
|
63
|
+
flex: 1,
|
|
64
|
+
gap: 8,
|
|
65
|
+
},
|
|
66
|
+
})
|
|
67
|
+
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { CustomMessage } from '@planningcenter/jolt-client/dist/types/JoltConnection'
|
|
2
|
+
import type { ConversationDisabledReason } from '../resources/conversation'
|
|
2
3
|
|
|
3
4
|
type DateString = string
|
|
4
5
|
interface BaseConversationEventData extends Record<string, unknown> {
|
|
@@ -15,6 +16,7 @@ interface BaseConversationEventData extends Record<string, unknown> {
|
|
|
15
16
|
latest_read_message_sort_key?: string
|
|
16
17
|
organization_id: number
|
|
17
18
|
disabled: boolean
|
|
19
|
+
disabled_reason?: ConversationDisabledReason
|
|
18
20
|
replies_disabled: boolean
|
|
19
21
|
subtitle?: string
|
|
20
22
|
title: string
|
|
@@ -4,6 +4,8 @@ import { ConversationMembershipResource } from './conversation_membership'
|
|
|
4
4
|
import { GroupResource } from './group_resource'
|
|
5
5
|
import { MemberAbilityResource } from './member_ability'
|
|
6
6
|
|
|
7
|
+
export type ConversationDisabledReason = 'safety_check' | 'direct_messages_disabled'
|
|
8
|
+
|
|
7
9
|
export interface ConversationResource {
|
|
8
10
|
type: 'Conversation'
|
|
9
11
|
id: number
|
|
@@ -13,6 +15,7 @@ export interface ConversationResource {
|
|
|
13
15
|
createdAt: string
|
|
14
16
|
deleted?: boolean
|
|
15
17
|
disabled?: boolean
|
|
18
|
+
disabledReason?: ConversationDisabledReason
|
|
16
19
|
genderOption?: string | null
|
|
17
20
|
groups?: GroupResource[]
|
|
18
21
|
previewAvatarUrls?: string[]
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { getConversationsRequestArgs } from '../request/conversation'
|
|
2
|
+
|
|
3
|
+
const groupId = 'Groups-Group-1' as const
|
|
4
|
+
|
|
5
|
+
describe('getConversationsRequestArgs', () => {
|
|
6
|
+
it.each([
|
|
7
|
+
['no args', {}, 'mine_or_not_empty'],
|
|
8
|
+
['group_source_app_name', { group_source_app_name: 'Groups' }, 'group_source_app_name'],
|
|
9
|
+
['chat_group_graph_id', { chat_group_graph_id: groupId }, 'group'],
|
|
10
|
+
['show_direct_messages', { show_direct_messages: true }, 'mine_or_not_empty,direct_message'],
|
|
11
|
+
])('%s uses filter: %s', (_label, args, expectedFilter) => {
|
|
12
|
+
expect(getConversationsRequestArgs(args).data.filter).toBe(expectedFilter)
|
|
13
|
+
})
|
|
14
|
+
})
|
|
@@ -5,18 +5,25 @@ export interface ConversationRequestArgs {
|
|
|
5
5
|
gids: string
|
|
6
6
|
chat_group_graph_id?: GraphId
|
|
7
7
|
group_source_app_name?: string
|
|
8
|
+
show_direct_messages?: boolean
|
|
8
9
|
}
|
|
9
10
|
|
|
10
11
|
export const getConversationsRequestArgs = ({
|
|
11
12
|
gids,
|
|
12
13
|
chat_group_graph_id,
|
|
13
14
|
group_source_app_name,
|
|
15
|
+
show_direct_messages,
|
|
14
16
|
}: Partial<ConversationRequestArgs> = {}): GetRequest => {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
17
|
+
let filter: string
|
|
18
|
+
if (chat_group_graph_id) {
|
|
19
|
+
filter = 'group'
|
|
20
|
+
} else if (show_direct_messages) {
|
|
21
|
+
filter = 'mine_or_not_empty,direct_message'
|
|
22
|
+
} else if (group_source_app_name) {
|
|
23
|
+
filter = 'group_source_app_name'
|
|
24
|
+
} else {
|
|
25
|
+
filter = 'mine_or_not_empty'
|
|
26
|
+
}
|
|
20
27
|
|
|
21
28
|
return {
|
|
22
29
|
url: '/me/conversations',
|
|
@@ -32,6 +39,7 @@ export const getConversationsRequestArgs = ({
|
|
|
32
39
|
'created_at',
|
|
33
40
|
'badges',
|
|
34
41
|
'disabled',
|
|
42
|
+
'disabled_reason',
|
|
35
43
|
'groups',
|
|
36
44
|
'last_message_author_id',
|
|
37
45
|
'last_message_author_name',
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
type TimeUnit = 'hours' | 'minutes' | 'seconds'
|
|
2
|
+
|
|
3
|
+
export function toMs(value: number, unit: TimeUnit): number {
|
|
4
|
+
switch (unit) {
|
|
5
|
+
case 'hours':
|
|
6
|
+
return value * 60 * 60 * 1000
|
|
7
|
+
case 'minutes':
|
|
8
|
+
return value * 60 * 1000
|
|
9
|
+
case 'seconds':
|
|
10
|
+
return value * 1000
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export const FIVE_SECONDS = toMs(5, 'seconds')
|
|
15
|
+
export const FIVE_MINUTES = toMs(5, 'minutes')
|
|
16
|
+
export const THIRTY_MINUTES = toMs(30, 'minutes')
|
|
17
|
+
export const ONE_HOUR = toMs(1, 'hours')
|