@planningcenter/chat-react-native 4.5.1-qa-staging.10 → 4.5.1-qa-1061.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/display/conversation_avatar.d.ts +1 -3
- package/build/components/display/conversation_avatar.d.ts.map +1 -1
- package/build/components/display/conversation_avatar.js +66 -77
- package/build/components/display/conversation_avatar.js.map +1 -1
- package/build/contexts/api_provider.d.ts +0 -1
- package/build/contexts/api_provider.d.ts.map +1 -1
- package/build/contexts/api_provider.js +5 -11
- package/build/contexts/api_provider.js.map +1 -1
- package/build/hooks/index.d.ts +0 -1
- package/build/hooks/index.d.ts.map +1 -1
- package/build/hooks/index.js +0 -1
- package/build/hooks/index.js.map +1 -1
- package/build/hooks/use_conversation_avatar_update.d.ts +3 -4
- package/build/hooks/use_conversation_avatar_update.d.ts.map +1 -1
- package/build/hooks/use_conversation_avatar_update.js +48 -146
- package/build/hooks/use_conversation_avatar_update.js.map +1 -1
- package/build/screens/avatar_picker/avatar_picker_screen.d.ts.map +1 -1
- package/build/screens/avatar_picker/avatar_picker_screen.js +66 -76
- package/build/screens/avatar_picker/avatar_picker_screen.js.map +1 -1
- package/build/screens/system_message_people_screen.d.ts.map +1 -1
- package/build/screens/system_message_people_screen.js +96 -33
- package/build/screens/system_message_people_screen.js.map +1 -1
- package/package.json +5 -5
- package/src/components/conversations/__tests__/conversation_preview.test.tsx +2 -2
- package/src/components/display/conversation_avatar.tsx +2 -9
- package/src/contexts/api_provider.tsx +5 -12
- package/src/hooks/index.ts +0 -1
- package/src/hooks/use_conversation_avatar_update.ts +11 -67
- package/src/screens/avatar_picker/avatar_picker_screen.tsx +1 -7
- package/src/screens/search/__tests__/search_screen.test.tsx +5 -6
- package/src/screens/search/components/__tests__/conversation_results.test.tsx +5 -14
- package/src/screens/search/components/__tests__/message_result_row.test.tsx +4 -5
- package/src/screens/search/components/__tests__/search_results_list.test.tsx +3 -4
- package/src/screens/system_message_people_screen.tsx +20 -6
- package/build/hooks/use_system_message_people.d.ts +0 -14
- package/build/hooks/use_system_message_people.d.ts.map +0 -1
- package/build/hooks/use_system_message_people.js +0 -101
- package/build/hooks/use_system_message_people.js.map +0 -1
- package/src/__utils__/render_with_query_client.tsx +0 -13
- package/src/components/display/__tests__/conversation_avatar.test.tsx +0 -94
- package/src/contexts/__tests__/configured_retry.test.ts +0 -39
- package/src/hooks/__tests__/use_conversation_avatar_update.test.tsx +0 -40
- package/src/hooks/__tests__/use_system_message_people.test.tsx +0 -79
- package/src/hooks/use_system_message_people.ts +0 -55
- package/src/screens/avatar_picker/__tests__/avatar_picker_screen.test.tsx +0 -67
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import { useSuspenseQueries } from '@tanstack/react-query'
|
|
2
|
-
import { chunk, sortBy } from 'lodash'
|
|
3
|
-
import { ApiCollection, MemberResource } from '../types'
|
|
4
|
-
import { GetRequest } from '../utils/client'
|
|
5
|
-
import { throwResponseError } from '../utils/response_error'
|
|
6
|
-
import { useApiClient } from './use_api_client'
|
|
7
|
-
import { getRequestQueryKey } from './use_suspense_api'
|
|
8
|
-
|
|
9
|
-
export const MEMBERS_PER_REQUEST = 100
|
|
10
|
-
|
|
11
|
-
type SystemMessagePeopleArgs = {
|
|
12
|
-
conversationId: number
|
|
13
|
-
personIds: number[]
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export type SystemMessagePerson = Pick<MemberResource, 'type' | 'id' | 'name' | 'avatar'>
|
|
17
|
-
|
|
18
|
-
export const systemMessagePeopleRequest = (
|
|
19
|
-
conversationId: number,
|
|
20
|
-
personIds: number[]
|
|
21
|
-
): GetRequest => ({
|
|
22
|
-
url: `/me/conversations/${conversationId}/members`,
|
|
23
|
-
data: {
|
|
24
|
-
fields: {
|
|
25
|
-
Member: ['id', 'name', 'avatar'],
|
|
26
|
-
},
|
|
27
|
-
where: {
|
|
28
|
-
id: personIds,
|
|
29
|
-
},
|
|
30
|
-
perPage: MEMBERS_PER_REQUEST,
|
|
31
|
-
},
|
|
32
|
-
})
|
|
33
|
-
|
|
34
|
-
export const useSystemMessagePeople = ({ conversationId, personIds }: SystemMessagePeopleArgs) => {
|
|
35
|
-
const apiClient = useApiClient()
|
|
36
|
-
const requests = chunk(personIds, MEMBERS_PER_REQUEST).map(ids =>
|
|
37
|
-
systemMessagePeopleRequest(conversationId, ids)
|
|
38
|
-
)
|
|
39
|
-
|
|
40
|
-
const queries = useSuspenseQueries({
|
|
41
|
-
queries: requests.map(request => ({
|
|
42
|
-
queryKey: getRequestQueryKey(request),
|
|
43
|
-
queryFn: (): Promise<ApiCollection<SystemMessagePerson>> =>
|
|
44
|
-
apiClient.chat.get<ApiCollection<SystemMessagePerson>>(request).catch(throwResponseError),
|
|
45
|
-
})),
|
|
46
|
-
})
|
|
47
|
-
|
|
48
|
-
const orderById = Object.fromEntries(personIds.map((id, index) => [id, index]))
|
|
49
|
-
const people = sortBy(
|
|
50
|
-
queries.flatMap(query => query.data.data),
|
|
51
|
-
person => orderById[person.id] ?? personIds.length
|
|
52
|
-
)
|
|
53
|
-
|
|
54
|
-
return { data: people }
|
|
55
|
-
}
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
import { HeaderHeightContext } from '@react-navigation/elements'
|
|
2
|
-
import { DefaultTheme, ThemeProvider } from '@react-navigation/native'
|
|
3
|
-
import { QueryClientProvider } from '@tanstack/react-query'
|
|
4
|
-
import { render } from '@testing-library/react-native'
|
|
5
|
-
import React from 'react'
|
|
6
|
-
import { Image } from 'react-native'
|
|
7
|
-
import { SafeAreaProvider } from 'react-native-safe-area-context'
|
|
8
|
-
import { buildTestQueryClient } from '../../../__utils__/query_client'
|
|
9
|
-
import type { AvatarUpdatePayload } from '../../../hooks/use_conversation_avatar_update'
|
|
10
|
-
import { AvatarPickerScreen } from '../avatar_picker_screen'
|
|
11
|
-
|
|
12
|
-
jest.mock('@react-navigation/native', () => ({
|
|
13
|
-
...jest.requireActual('@react-navigation/native'),
|
|
14
|
-
useNavigation: () => ({ goBack: jest.fn(), dispatch: jest.fn() }),
|
|
15
|
-
}))
|
|
16
|
-
jest.mock('../../../hooks/use_api_client', () => ({ useApiClient: () => ({}) }))
|
|
17
|
-
jest.mock('../../../hooks/use_upload_client', () => ({ useUploadClient: () => ({}) }))
|
|
18
|
-
jest.mock('../../../hooks/use_conversation', () => ({
|
|
19
|
-
...jest.requireActual('../../../hooks/use_conversation'),
|
|
20
|
-
useConversation: () => ({
|
|
21
|
-
data: { id: 7, customAvatarType: 'icon', customAvatarKey: 'star', customAvatarColor: 'cosmic' },
|
|
22
|
-
}),
|
|
23
|
-
}))
|
|
24
|
-
|
|
25
|
-
const safeAreaMetrics = {
|
|
26
|
-
frame: { x: 0, y: 0, width: 390, height: 844 },
|
|
27
|
-
insets: { top: 0, right: 0, bottom: 0, left: 0 },
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
describe('AvatarPickerScreen', () => {
|
|
31
|
-
it('opens on a photo that is still uploading instead of the cached avatar', async () => {
|
|
32
|
-
const queryClient = buildTestQueryClient()
|
|
33
|
-
const photo: AvatarUpdatePayload = {
|
|
34
|
-
kind: 'image',
|
|
35
|
-
color: 'cosmic',
|
|
36
|
-
imageAsset: { uri: 'file:///photo.jpg', width: 100, height: 100 },
|
|
37
|
-
}
|
|
38
|
-
let finishUpload = () => {}
|
|
39
|
-
const uploading = new Promise<void>(resolve => (finishUpload = resolve))
|
|
40
|
-
const upload = queryClient
|
|
41
|
-
.getMutationCache()
|
|
42
|
-
.build(queryClient, {
|
|
43
|
-
mutationKey: ['updateConversationAvatar', 7],
|
|
44
|
-
mutationFn: () => uploading,
|
|
45
|
-
networkMode: 'always',
|
|
46
|
-
})
|
|
47
|
-
.execute(photo)
|
|
48
|
-
|
|
49
|
-
const view = render(
|
|
50
|
-
<SafeAreaProvider initialMetrics={safeAreaMetrics}>
|
|
51
|
-
<ThemeProvider value={DefaultTheme}>
|
|
52
|
-
<HeaderHeightContext.Provider value={0}>
|
|
53
|
-
<QueryClientProvider client={queryClient}>
|
|
54
|
-
<AvatarPickerScreen route={{ params: { conversation_id: 7 } } as never} />
|
|
55
|
-
</QueryClientProvider>
|
|
56
|
-
</HeaderHeightContext.Provider>
|
|
57
|
-
</ThemeProvider>
|
|
58
|
-
</SafeAreaProvider>
|
|
59
|
-
)
|
|
60
|
-
|
|
61
|
-
const sources = view.UNSAFE_getAllByType(Image).map(image => image.props.source)
|
|
62
|
-
expect(sources).toContainEqual({ uri: 'file:///photo.jpg' })
|
|
63
|
-
|
|
64
|
-
finishUpload()
|
|
65
|
-
await upload
|
|
66
|
-
})
|
|
67
|
-
})
|