@planningcenter/chat-react-native 4.1.1-qa-staging.4 → 4.2.0-rc.1
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/contexts/api_provider.d.ts.map +1 -1
- package/build/contexts/api_provider.js +1 -12
- package/build/contexts/api_provider.js.map +1 -1
- package/build/hooks/use_features.d.ts +0 -16
- package/build/hooks/use_features.d.ts.map +1 -1
- package/build/hooks/use_features.js +47 -43
- package/build/hooks/use_features.js.map +1 -1
- package/build/navigation/index.d.ts +2 -2
- package/build/navigation/index.d.ts.map +1 -1
- package/build/navigation/index.js +4 -4
- package/build/navigation/index.js.map +1 -1
- package/build/screens/conversation_new/components/services_form.js +8 -9
- package/build/screens/conversation_new/components/services_form.js.map +1 -1
- 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 +2 -1
- package/build/screens/conversation_select_recipients/conversation_select_direct_message_recipients_screen.js.map +1 -1
- package/build/screens/conversations/conversations_screen.d.ts.map +1 -1
- package/build/screens/conversations/conversations_screen.js +16 -28
- package/build/screens/conversations/conversations_screen.js.map +1 -1
- package/build/utils/time.d.ts +0 -1
- package/build/utils/time.d.ts.map +1 -1
- package/build/utils/time.js +0 -1
- package/build/utils/time.js.map +1 -1
- package/package.json +3 -3
- package/src/contexts/api_provider.tsx +0 -4
- package/src/hooks/use_features.ts +14 -26
- package/src/navigation/index.tsx +4 -3
- package/src/screens/conversation_new/components/services_form.tsx +5 -5
- package/src/screens/conversation_select_recipients/conversation_select_direct_message_recipients_screen.tsx +2 -3
- package/src/screens/conversations/conversations_screen.tsx +1 -6
- package/src/utils/time.ts +0 -1
- package/build/screens/conversations/components/search_list_header_component.d.ts +0 -2
- package/build/screens/conversations/components/search_list_header_component.d.ts.map +0 -1
- package/build/screens/conversations/components/search_list_header_component.js +0 -496
- package/build/screens/conversations/components/search_list_header_component.js.map +0 -1
- package/src/__tests__/hooks/use_features.test.ts +0 -61
- package/src/__tests__/screens/conversation_new/components/services_form.test.tsx +0 -91
- package/src/screens/conversations/components/search_list_header_component.tsx +0 -291
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@planningcenter/chat-react-native",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.2.0-rc.1",
|
|
4
4
|
"description": "",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"dependencies": {
|
|
34
34
|
"@fortawesome/fontawesome-svg-core": "^7.2.0",
|
|
35
35
|
"@fortawesome/react-native-fontawesome": "^0.3.2",
|
|
36
|
-
"@planningcenter/emoji-keyboard": "4.
|
|
36
|
+
"@planningcenter/emoji-keyboard": "4.0.0",
|
|
37
37
|
"lodash-inflection": "^1.5.0"
|
|
38
38
|
},
|
|
39
39
|
"peerDependencies": {
|
|
@@ -84,5 +84,5 @@
|
|
|
84
84
|
"sf-symbols-typescript": "^2.2.0",
|
|
85
85
|
"typescript": "~6.0.3"
|
|
86
86
|
},
|
|
87
|
-
"gitHead": "
|
|
87
|
+
"gitHead": "5f3487e3e5462b3074ed2e855ade9591243c6544"
|
|
88
88
|
}
|
|
@@ -10,7 +10,6 @@ import { ViewProps } from 'react-native'
|
|
|
10
10
|
import { ApiClient, useApiClient } from '../hooks/use_api_client'
|
|
11
11
|
import { useAppState } from '../hooks/use_app_state'
|
|
12
12
|
import { appGrantsRequestArgs } from '../hooks/use_chat_permissions'
|
|
13
|
-
import { featuresQueryOptions } from '../hooks/use_features'
|
|
14
13
|
import { getRequestQueryKey, RequestQueryKey } from '../hooks/use_suspense_api'
|
|
15
14
|
import { emitAuthRefresh } from '../utils/auth_events'
|
|
16
15
|
import { ResponseError } from '../utils/response_error'
|
|
@@ -82,13 +81,10 @@ export function ApiProvider({ children }: ViewProps) {
|
|
|
82
81
|
// This needs to live in the provider so that it can access the api client
|
|
83
82
|
// and the chat query client
|
|
84
83
|
const PrefetchQueries = () => {
|
|
85
|
-
const client = useApiClient()
|
|
86
|
-
|
|
87
84
|
usePrefetchQuery({
|
|
88
85
|
queryKey: getRequestQueryKey(appGrantsRequestArgs),
|
|
89
86
|
queryFn: defaultQueryFn,
|
|
90
87
|
})
|
|
91
|
-
usePrefetchQuery(featuresQueryOptions(client))
|
|
92
88
|
|
|
93
89
|
return null
|
|
94
90
|
}
|
|
@@ -1,20 +1,26 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { useSuspenseQuery } from '@tanstack/react-query'
|
|
2
2
|
import { useCallback } from 'react'
|
|
3
3
|
import { ApiCollection } from '../types'
|
|
4
4
|
import type { FeatureResource } from '../types/resources/feature_resource'
|
|
5
5
|
import { getFeaturesRequestArgs, getFeaturesQueryKey } from '../utils/request/get_features'
|
|
6
|
-
import { FIVE_MINUTES
|
|
7
|
-
import {
|
|
6
|
+
import { FIVE_MINUTES } from '../utils/time'
|
|
7
|
+
import { useApiClient } from './use_api_client'
|
|
8
8
|
|
|
9
9
|
type FeatureName = (typeof availableFeatures)[keyof typeof availableFeatures]
|
|
10
10
|
|
|
11
|
-
type FeaturesCollection = ApiCollection<FeatureResource> & {
|
|
12
|
-
failure?: { status?: number }
|
|
13
|
-
}
|
|
14
|
-
|
|
15
11
|
export function useFeatures() {
|
|
16
12
|
const apiClient = useApiClient()
|
|
17
|
-
const
|
|
13
|
+
const requestArgs = getFeaturesRequestArgs()
|
|
14
|
+
|
|
15
|
+
const { data } = useSuspenseQuery({
|
|
16
|
+
queryKey: getFeaturesQueryKey(),
|
|
17
|
+
queryFn: () => {
|
|
18
|
+
return apiClient.chat
|
|
19
|
+
.get<ApiCollection<FeatureResource>>(requestArgs)
|
|
20
|
+
.catch(() => stableEmptyFeatures)
|
|
21
|
+
},
|
|
22
|
+
staleTime: FIVE_MINUTES,
|
|
23
|
+
})
|
|
18
24
|
|
|
19
25
|
const features = data.data
|
|
20
26
|
|
|
@@ -30,23 +36,6 @@ export function useFeatures() {
|
|
|
30
36
|
}
|
|
31
37
|
}
|
|
32
38
|
|
|
33
|
-
export const featuresQueryOptions = (apiClient: ApiClient) =>
|
|
34
|
-
queryOptions({
|
|
35
|
-
queryKey: getFeaturesQueryKey(),
|
|
36
|
-
queryFn: (): Promise<FeaturesCollection> => {
|
|
37
|
-
return apiClient.chat
|
|
38
|
-
.get<ApiCollection<FeatureResource>>(getFeaturesRequestArgs())
|
|
39
|
-
.catch(error => ({ ...stableEmptyFeatures, failure: { status: error?.status } }))
|
|
40
|
-
},
|
|
41
|
-
staleTime: query => {
|
|
42
|
-
const failure = query.state.data?.failure
|
|
43
|
-
if (!failure) return FIVE_MINUTES
|
|
44
|
-
|
|
45
|
-
return failure.status === 429 ? ONE_MINUTE : 0
|
|
46
|
-
},
|
|
47
|
-
gcTime: Infinity,
|
|
48
|
-
})
|
|
49
|
-
|
|
50
39
|
export const availableFeatures = {
|
|
51
40
|
gender_specific_conversations: 'ROLLOUT_gender_specific_conversations',
|
|
52
41
|
message_reporting: 'ROLLOUT_MOBILE_message_reporting',
|
|
@@ -55,7 +44,6 @@ export const availableFeatures = {
|
|
|
55
44
|
conversation_safety_lock: 'ROLLOUT_conversation_safety_lock',
|
|
56
45
|
video_moderation: 'ROLLOUT_MOBILE_video_moderation',
|
|
57
46
|
dm_search_clear_fix: 'ROLLOUT_MOBILE_dm_search_clear_fix',
|
|
58
|
-
search: 'ROLLOUT_search',
|
|
59
47
|
} as const satisfies Record<string, `ROLLOUT_${string}`>
|
|
60
48
|
|
|
61
49
|
const stableEmptyFeatures: ApiCollection<FeatureResource> = {
|
package/src/navigation/index.tsx
CHANGED
|
@@ -130,13 +130,14 @@ export const NewConversationStack = createNativeStackNavigator({
|
|
|
130
130
|
ConversationSelectDirectMessageRecipients: {
|
|
131
131
|
screen: ConversationSelectDirectMessageRecipientsScreen,
|
|
132
132
|
if: useDirectMessagesEligible,
|
|
133
|
-
options: ({ navigation }) =>
|
|
133
|
+
options: ({ navigation, route }) =>
|
|
134
134
|
composeOptions(
|
|
135
135
|
{
|
|
136
136
|
title: 'New conversation',
|
|
137
|
-
headerBackVisible: false,
|
|
138
137
|
},
|
|
139
|
-
withRightClose({
|
|
138
|
+
withRightClose({
|
|
139
|
+
onPress: () => navigation.popTo('Conversations', route.params),
|
|
140
|
+
})
|
|
140
141
|
),
|
|
141
142
|
},
|
|
142
143
|
ConversationFilterRecipients: {
|
|
@@ -45,7 +45,6 @@ export const ServicesForm = ({
|
|
|
45
45
|
const customAvatarsEnabled = featureEnabled(availableFeatures.custom_conversation_avatars)
|
|
46
46
|
const safetyLockEnabled = featureEnabled(availableFeatures.conversation_safety_lock)
|
|
47
47
|
const [selectedPlanId, setSelectedPlanId] = useState<number | undefined>(initialPlanId)
|
|
48
|
-
const [filterByPlan, setFilterByPlan] = useState(!!initialPlanId)
|
|
49
48
|
const initialState = useMemo(() => uniq(initialTeamIds) || [], [initialTeamIds]) // Uniq here because services can send duplicates in the teams_i_lead response.
|
|
50
49
|
const [selectedTeamIds, setSelectedTeamIds] = useState<number[]>(initialState)
|
|
51
50
|
|
|
@@ -53,7 +52,6 @@ export const ServicesForm = ({
|
|
|
53
52
|
useEffect(() => {
|
|
54
53
|
setSelectedTeamIds(initialState)
|
|
55
54
|
setSelectedPlanId(initialPlanId)
|
|
56
|
-
setFilterByPlan(!!initialPlanId)
|
|
57
55
|
}, [initialState, initialPlanId])
|
|
58
56
|
|
|
59
57
|
const removeSelection = useCallback(
|
|
@@ -63,7 +61,9 @@ export const ServicesForm = ({
|
|
|
63
61
|
[selectedTeamIds]
|
|
64
62
|
)
|
|
65
63
|
|
|
66
|
-
const
|
|
64
|
+
const [filerByPlan, setFilterByPlan] = useState(false)
|
|
65
|
+
|
|
66
|
+
const activePlanId = filerByPlan ? selectedPlanId : undefined
|
|
67
67
|
|
|
68
68
|
const { payload, isLoading: isLoadingPayload } = useServicesChatConversationPayload({
|
|
69
69
|
teamIds: selectedTeamIds,
|
|
@@ -79,7 +79,7 @@ export const ServicesForm = ({
|
|
|
79
79
|
|
|
80
80
|
const { members, isError: isMemberError } = useTeamMembersForNewConversation({
|
|
81
81
|
teamIds: selectedTeamIds,
|
|
82
|
-
planId:
|
|
82
|
+
planId: selectedPlanId,
|
|
83
83
|
})
|
|
84
84
|
const adultMembers = useMemo(() => members.filter(member => !member.child), [members])
|
|
85
85
|
|
|
@@ -118,7 +118,7 @@ export const ServicesForm = ({
|
|
|
118
118
|
removeSelection={removeSelection}
|
|
119
119
|
selectedPlanId={selectedPlanId}
|
|
120
120
|
setSelectedPlanId={setSelectedPlanId}
|
|
121
|
-
filterByPlan={
|
|
121
|
+
filterByPlan={filerByPlan}
|
|
122
122
|
setFilterByPlan={setFilterByPlan}
|
|
123
123
|
members={members}
|
|
124
124
|
isMemberError={isMemberError}
|
|
@@ -76,9 +76,8 @@ export function ConversationSelectDirectMessageRecipientsScreen({
|
|
|
76
76
|
const { warnings, validationPending } = useDirectMessageConversationValidate({ recipientIds })
|
|
77
77
|
|
|
78
78
|
const handleSuccess = (conversationId: number) => {
|
|
79
|
-
navigation
|
|
80
|
-
|
|
81
|
-
?.dispatch(StackActions.replace('Conversation', { conversation_id: conversationId }))
|
|
79
|
+
navigation.getParent()?.goBack()
|
|
80
|
+
navigation.dispatch(StackActions.push('Conversation', { conversation_id: conversationId }))
|
|
82
81
|
}
|
|
83
82
|
|
|
84
83
|
const { findOrCreateConversation, directMessageExists, isFinding, isError } =
|
|
@@ -3,12 +3,10 @@ import React from 'react'
|
|
|
3
3
|
import { StyleSheet, View } from 'react-native'
|
|
4
4
|
import { Conversations } from '../../components'
|
|
5
5
|
import { ConversationsContextProvider } from '../../contexts/conversations_context'
|
|
6
|
-
import { availableFeatures, useFeatures } from '../../hooks/use_features'
|
|
7
6
|
import { analyticsEvents, usePublishProductAnalyticsEvent } from '../../hooks/use_product_analytics'
|
|
8
7
|
import { AppName } from '../../types/resources/app_name'
|
|
9
8
|
import { GraphId } from '../../types/resources/group_resource'
|
|
10
9
|
import { ListHeaderComponent } from './components/list_header_component'
|
|
11
|
-
import { SearchListHeaderComponent } from './components/search_list_header_component'
|
|
12
10
|
|
|
13
11
|
export type ConversationsScreenProps = StaticScreenProps<{
|
|
14
12
|
title?: string
|
|
@@ -19,16 +17,13 @@ export type ConversationsScreenProps = StaticScreenProps<{
|
|
|
19
17
|
|
|
20
18
|
export function ConversationsScreen({ route }: ConversationsScreenProps) {
|
|
21
19
|
const styles = useStyles()
|
|
22
|
-
const { featureEnabled } = useFeatures()
|
|
23
|
-
const searchEnabled = featureEnabled(availableFeatures.search)
|
|
24
|
-
const Header = searchEnabled ? SearchListHeaderComponent : ListHeaderComponent
|
|
25
20
|
|
|
26
21
|
usePublishProductAnalyticsEvent(analyticsEvents.conversation_index_opened)
|
|
27
22
|
|
|
28
23
|
return (
|
|
29
24
|
<View style={styles.container}>
|
|
30
25
|
<ConversationsContextProvider args={route.params} opts={{ throwOnError: true }}>
|
|
31
|
-
<Conversations ListHeaderComponent={
|
|
26
|
+
<Conversations ListHeaderComponent={ListHeaderComponent} />
|
|
32
27
|
</ConversationsContextProvider>
|
|
33
28
|
</View>
|
|
34
29
|
)
|
package/src/utils/time.ts
CHANGED
|
@@ -12,7 +12,6 @@ export function toMs(value: number, unit: TimeUnit): number {
|
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
export const FIVE_SECONDS = toMs(5, 'seconds')
|
|
15
|
-
export const ONE_MINUTE = toMs(1, 'minutes')
|
|
16
15
|
export const FIVE_MINUTES = toMs(5, 'minutes')
|
|
17
16
|
export const THIRTY_MINUTES = toMs(30, 'minutes')
|
|
18
17
|
export const ONE_HOUR = toMs(1, 'hours')
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"search_list_header_component.d.ts","sourceRoot":"","sources":["../../../../src/screens/conversations/components/search_list_header_component.tsx"],"names":[],"mappings":"AAkCA,eAAO,MAAM,yBAAyB,+CA8MrC,CAAA"}
|