@planningcenter/chat-react-native 4.5.1-qa-staging.9 → 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 +49 -115
- 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 +12 -37
- 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 -84
- 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,7 +1,6 @@
|
|
|
1
|
-
import { act, fireEvent } from '@testing-library/react-native'
|
|
1
|
+
import { act, fireEvent, render } from '@testing-library/react-native'
|
|
2
2
|
import React from 'react'
|
|
3
3
|
import { Keyboard, ScrollView } from 'react-native'
|
|
4
|
-
import { renderWithQueryClient } from '../../../__utils__/render_with_query_client'
|
|
5
4
|
import type { useSearchResults } from '../../../hooks/use_search_results'
|
|
6
5
|
import type {
|
|
7
6
|
ConversationSearchResultResource,
|
|
@@ -72,7 +71,7 @@ const renderWithResults = () => {
|
|
|
72
71
|
hasNextPage: false,
|
|
73
72
|
isFetchingNextPage: false,
|
|
74
73
|
})
|
|
75
|
-
const view =
|
|
74
|
+
const view = render(<SearchScreen />)
|
|
76
75
|
const input = view.getByLabelText(inputLabel)
|
|
77
76
|
fireEvent.changeText(input, 'bud')
|
|
78
77
|
fireEvent.changeText(input, 'budget')
|
|
@@ -100,7 +99,7 @@ afterEach(() => jest.useRealTimers())
|
|
|
100
99
|
|
|
101
100
|
describe('SearchScreen', () => {
|
|
102
101
|
it('searches once with the trimmed term after typing settles', () => {
|
|
103
|
-
const view =
|
|
102
|
+
const view = render(<SearchScreen />)
|
|
104
103
|
const input = view.getByLabelText(inputLabel)
|
|
105
104
|
|
|
106
105
|
fireEvent.changeText(input, 'bud')
|
|
@@ -119,7 +118,7 @@ describe('SearchScreen', () => {
|
|
|
119
118
|
})
|
|
120
119
|
|
|
121
120
|
it('lets the prompt scroll while taps still reach the field', () => {
|
|
122
|
-
const view =
|
|
121
|
+
const view = render(<SearchScreen />)
|
|
123
122
|
|
|
124
123
|
const scrollView = view.UNSAFE_getByType(ScrollView)
|
|
125
124
|
expect(scrollView.props.keyboardShouldPersistTaps).toBe('handled')
|
|
@@ -128,7 +127,7 @@ describe('SearchScreen', () => {
|
|
|
128
127
|
})
|
|
129
128
|
|
|
130
129
|
it('returns to the prompt as soon as the term is cleared', () => {
|
|
131
|
-
const view =
|
|
130
|
+
const view = render(<SearchScreen />)
|
|
132
131
|
const input = view.getByLabelText(inputLabel)
|
|
133
132
|
|
|
134
133
|
fireEvent.changeText(input, 'budget')
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { fireEvent } from '@testing-library/react-native'
|
|
1
|
+
import { fireEvent, render } from '@testing-library/react-native'
|
|
2
2
|
import React from 'react'
|
|
3
|
-
import { renderWithQueryClient } from '../../../../__utils__/render_with_query_client'
|
|
4
3
|
import type { ConversationSearchResultResource } from '../../../../types'
|
|
5
4
|
import { ConversationResults } from '../conversation_results'
|
|
6
5
|
|
|
@@ -15,9 +14,7 @@ const buildResults = (count: number, prefix = 'Conversation') =>
|
|
|
15
14
|
|
|
16
15
|
describe('ConversationResults', () => {
|
|
17
16
|
it('caps at five rows until View more is pressed, then offers View less', () => {
|
|
18
|
-
const view =
|
|
19
|
-
<ConversationResults results={buildResults(6)} onSelect={jest.fn()} />
|
|
20
|
-
)
|
|
17
|
+
const view = render(<ConversationResults results={buildResults(6)} onSelect={jest.fn()} />)
|
|
21
18
|
|
|
22
19
|
expect(view.getByText('Conversation 5')).toBeTruthy()
|
|
23
20
|
expect(view.queryByText('Conversation 6')).toBeNull()
|
|
@@ -30,18 +27,14 @@ describe('ConversationResults', () => {
|
|
|
30
27
|
})
|
|
31
28
|
|
|
32
29
|
it('renders no footer for five or fewer results', () => {
|
|
33
|
-
const view =
|
|
34
|
-
<ConversationResults results={buildResults(4)} onSelect={jest.fn()} />
|
|
35
|
-
)
|
|
30
|
+
const view = render(<ConversationResults results={buildResults(4)} onSelect={jest.fn()} />)
|
|
36
31
|
|
|
37
32
|
expect(view.getByText('Conversation 4')).toBeTruthy()
|
|
38
33
|
expect(view.queryByText('View more')).toBeNull()
|
|
39
34
|
})
|
|
40
35
|
|
|
41
36
|
it('stays expanded when the parent re-renders with a new results array', () => {
|
|
42
|
-
const view =
|
|
43
|
-
<ConversationResults results={buildResults(6)} onSelect={jest.fn()} />
|
|
44
|
-
)
|
|
37
|
+
const view = render(<ConversationResults results={buildResults(6)} onSelect={jest.fn()} />)
|
|
45
38
|
fireEvent.press(view.getByText('View more'))
|
|
46
39
|
|
|
47
40
|
view.rerender(<ConversationResults results={buildResults(6)} onSelect={jest.fn()} />)
|
|
@@ -53,9 +46,7 @@ describe('ConversationResults', () => {
|
|
|
53
46
|
it('passes the pressed result and its position to onSelect', () => {
|
|
54
47
|
const onSelect = jest.fn()
|
|
55
48
|
const results = buildResults(2)
|
|
56
|
-
const view =
|
|
57
|
-
<ConversationResults results={results} onSelect={onSelect} />
|
|
58
|
-
)
|
|
49
|
+
const view = render(<ConversationResults results={results} onSelect={onSelect} />)
|
|
59
50
|
|
|
60
51
|
fireEvent.press(view.getByText('Conversation 2'))
|
|
61
52
|
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { fireEvent } from '@testing-library/react-native'
|
|
1
|
+
import { fireEvent, render } from '@testing-library/react-native'
|
|
2
2
|
import React from 'react'
|
|
3
|
-
import { renderWithQueryClient } from '../../../../__utils__/render_with_query_client'
|
|
4
3
|
import type { MessageSearchResultResource } from '../../../../types/resources/search_result'
|
|
5
4
|
import { formatDatePreview } from '../../../../utils/date'
|
|
6
5
|
import { defaultTheme } from '../../../../utils/theme'
|
|
@@ -34,7 +33,7 @@ const interactionColor = defaultTheme('light').colors.interaction
|
|
|
34
33
|
|
|
35
34
|
describe('MessageResultRow', () => {
|
|
36
35
|
it('renders the title, author, snippet, and date', () => {
|
|
37
|
-
const view =
|
|
36
|
+
const view = render(<MessageResultRow result={result} onPress={jest.fn()} />)
|
|
38
37
|
|
|
39
38
|
expect(view.getByText('Worship Team')).toBeTruthy()
|
|
40
39
|
expect(view.getByText('Ada Lovelace:', { exact: false })).toBeTruthy()
|
|
@@ -45,7 +44,7 @@ describe('MessageResultRow', () => {
|
|
|
45
44
|
})
|
|
46
45
|
|
|
47
46
|
it('colors matched segments with the interaction color', () => {
|
|
48
|
-
const view =
|
|
47
|
+
const view = render(<MessageResultRow result={result} onPress={jest.fn()} />)
|
|
49
48
|
|
|
50
49
|
expect(view.getByText('budget')).toHaveStyle({ color: interactionColor })
|
|
51
50
|
expect(view.getByText('…planning the ')).not.toHaveStyle({ color: interactionColor })
|
|
@@ -54,7 +53,7 @@ describe('MessageResultRow', () => {
|
|
|
54
53
|
it('exposes the row as a button with a composed label and reports presses', () => {
|
|
55
54
|
const onPress = jest.fn()
|
|
56
55
|
const date = formatDatePreview(result.extra.createdAt)
|
|
57
|
-
const view =
|
|
56
|
+
const view = render(<MessageResultRow result={result} onPress={onPress} />)
|
|
58
57
|
|
|
59
58
|
const row = view.getByRole('button', {
|
|
60
59
|
name: `Worship Team, Ada Lovelace: …planning the budget meeting for next week, ${date}`,
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { fireEvent } from '@testing-library/react-native'
|
|
1
|
+
import { fireEvent, render } from '@testing-library/react-native'
|
|
2
2
|
import React from 'react'
|
|
3
3
|
import { FlatList } from 'react-native'
|
|
4
|
-
import { renderWithQueryClient } from '../../../../__utils__/render_with_query_client'
|
|
5
4
|
import type { useSearchResults } from '../../../../hooks/use_search_results'
|
|
6
5
|
import type {
|
|
7
6
|
ConversationSearchResultResource,
|
|
@@ -57,7 +56,7 @@ const renderList = (state: Partial<SearchState>, onSettled = jest.fn()) => {
|
|
|
57
56
|
const list = () => (
|
|
58
57
|
<SearchResultsList term="potluck" onSelect={jest.fn()} onSettled={onSettled} {...slots} />
|
|
59
58
|
)
|
|
60
|
-
const view =
|
|
59
|
+
const view = render(list())
|
|
61
60
|
const rerenderWith = (next: Partial<SearchState>) => {
|
|
62
61
|
mockUseSearchResults.mockReturnValue(searchState(next))
|
|
63
62
|
view.rerender(list())
|
|
@@ -134,7 +133,7 @@ describe('SearchResultsList', () => {
|
|
|
134
133
|
const onSelect = jest.fn()
|
|
135
134
|
const results = [conversationResult('1'), messageResult('1'), messageResult('2')]
|
|
136
135
|
mockUseSearchResults.mockReturnValue(searchState({ results }))
|
|
137
|
-
const view =
|
|
136
|
+
const view = render(
|
|
138
137
|
<SearchResultsList term="potluck" onSelect={onSelect} onSettled={jest.fn()} {...slots} />
|
|
139
138
|
)
|
|
140
139
|
|
|
@@ -5,7 +5,8 @@ import { FlatList } from 'react-native-gesture-handler'
|
|
|
5
5
|
import { useSafeAreaInsets } from 'react-native-safe-area-context'
|
|
6
6
|
import { Avatar, Text } from '../components'
|
|
7
7
|
import FormSheet, { getFormSheetScreenOptions } from '../components/primitive/form_sheet'
|
|
8
|
-
import {
|
|
8
|
+
import { useSuspenseGet } from '../hooks'
|
|
9
|
+
import { MemberResource } from '../types'
|
|
9
10
|
|
|
10
11
|
export const SystemMessagePeopleScreenOptions = getFormSheetScreenOptions({
|
|
11
12
|
sheetAllowedDetents: Platform.select({
|
|
@@ -24,15 +25,26 @@ export function SystemMessagePeopleScreen({ route }: SystemMessagePeopleScreenPr
|
|
|
24
25
|
const { conversation_id, person_ids } = route.params
|
|
25
26
|
const styles = useStyles()
|
|
26
27
|
|
|
27
|
-
const { data:
|
|
28
|
-
|
|
29
|
-
|
|
28
|
+
const { data: members } = useSuspenseGet<MemberResource[]>({
|
|
29
|
+
url: `/me/conversations/${conversation_id}/members`,
|
|
30
|
+
data: {
|
|
31
|
+
fields: {
|
|
32
|
+
Member: ['id', 'name', 'avatar'],
|
|
33
|
+
},
|
|
34
|
+
where: {
|
|
35
|
+
id: person_ids,
|
|
36
|
+
},
|
|
37
|
+
limit: person_ids.length,
|
|
38
|
+
},
|
|
30
39
|
})
|
|
31
40
|
|
|
41
|
+
const orderById = Object.fromEntries(person_ids.map((id, i) => [id, i]))
|
|
42
|
+
const sortedMembers = [...members].sort((a, b) => (orderById[a.id] ?? 0) - (orderById[b.id] ?? 0))
|
|
43
|
+
|
|
32
44
|
return (
|
|
33
45
|
<FormSheet.Root contentStyle={styles.formSheetContent}>
|
|
34
46
|
<FlatList
|
|
35
|
-
data={
|
|
47
|
+
data={sortedMembers}
|
|
36
48
|
contentContainerStyle={styles.contentContainer}
|
|
37
49
|
keyExtractor={item => item.id.toString()}
|
|
38
50
|
renderItem={({ item }) => <Person person={item} />}
|
|
@@ -41,7 +53,9 @@ export function SystemMessagePeopleScreen({ route }: SystemMessagePeopleScreenPr
|
|
|
41
53
|
)
|
|
42
54
|
}
|
|
43
55
|
|
|
44
|
-
|
|
56
|
+
type PersonProps = Pick<MemberResource, 'id' | 'name' | 'avatar'>
|
|
57
|
+
|
|
58
|
+
const Person = memo(({ person }: { person: PersonProps }) => {
|
|
45
59
|
const styles = useStyles()
|
|
46
60
|
|
|
47
61
|
return (
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { MemberResource } from '../types';
|
|
2
|
-
import { GetRequest } from '../utils/client';
|
|
3
|
-
export declare const MEMBERS_PER_REQUEST = 100;
|
|
4
|
-
type SystemMessagePeopleArgs = {
|
|
5
|
-
conversationId: number;
|
|
6
|
-
personIds: number[];
|
|
7
|
-
};
|
|
8
|
-
export type SystemMessagePerson = Pick<MemberResource, 'type' | 'id' | 'name' | 'avatar'>;
|
|
9
|
-
export declare const systemMessagePeopleRequest: (conversationId: number, personIds: number[]) => GetRequest;
|
|
10
|
-
export declare const useSystemMessagePeople: ({ conversationId, personIds }: SystemMessagePeopleArgs) => {
|
|
11
|
-
data: SystemMessagePerson[];
|
|
12
|
-
};
|
|
13
|
-
export {};
|
|
14
|
-
//# sourceMappingURL=use_system_message_people.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"use_system_message_people.d.ts","sourceRoot":"","sources":["../../src/hooks/use_system_message_people.ts"],"names":[],"mappings":"AAEA,OAAO,EAAiB,cAAc,EAAE,MAAM,UAAU,CAAA;AACxD,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAK5C,eAAO,MAAM,mBAAmB,MAAM,CAAA;AAEtC,KAAK,uBAAuB,GAAG;IAC7B,cAAc,EAAE,MAAM,CAAA;IACtB,SAAS,EAAE,MAAM,EAAE,CAAA;CACpB,CAAA;AAED,MAAM,MAAM,mBAAmB,GAAG,IAAI,CAAC,cAAc,EAAE,MAAM,GAAG,IAAI,GAAG,MAAM,GAAG,QAAQ,CAAC,CAAA;AAEzF,eAAO,MAAM,0BAA0B,GACrC,gBAAgB,MAAM,EACtB,WAAW,MAAM,EAAE,KAClB,UAWD,CAAA;AAEF,eAAO,MAAM,sBAAsB,GAAI,+BAA+B,uBAAuB;;CAqB5F,CAAA"}
|
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
import { c as _c } from "react/compiler-runtime";
|
|
2
|
-
import { useSuspenseQueries } from '@tanstack/react-query';
|
|
3
|
-
import { chunk, sortBy } from 'lodash';
|
|
4
|
-
import { throwResponseError } from '../utils/response_error';
|
|
5
|
-
import { useApiClient } from './use_api_client';
|
|
6
|
-
import { getRequestQueryKey } from './use_suspense_api';
|
|
7
|
-
export const MEMBERS_PER_REQUEST = 100;
|
|
8
|
-
export const systemMessagePeopleRequest = (conversationId, personIds) => ({
|
|
9
|
-
url: `/me/conversations/${conversationId}/members`,
|
|
10
|
-
data: {
|
|
11
|
-
fields: {
|
|
12
|
-
Member: ['id', 'name', 'avatar']
|
|
13
|
-
},
|
|
14
|
-
where: {
|
|
15
|
-
id: personIds
|
|
16
|
-
},
|
|
17
|
-
perPage: MEMBERS_PER_REQUEST
|
|
18
|
-
}
|
|
19
|
-
});
|
|
20
|
-
export const useSystemMessagePeople = t0 => {
|
|
21
|
-
const $ = _c(16);
|
|
22
|
-
const {
|
|
23
|
-
conversationId,
|
|
24
|
-
personIds
|
|
25
|
-
} = t0;
|
|
26
|
-
const apiClient = useApiClient();
|
|
27
|
-
let t1;
|
|
28
|
-
let t2;
|
|
29
|
-
if ($[0] !== apiClient || $[1] !== conversationId || $[2] !== personIds) {
|
|
30
|
-
let t3;
|
|
31
|
-
if ($[5] !== conversationId) {
|
|
32
|
-
t3 = ids => systemMessagePeopleRequest(conversationId, ids);
|
|
33
|
-
$[5] = conversationId;
|
|
34
|
-
$[6] = t3;
|
|
35
|
-
} else {
|
|
36
|
-
t3 = $[6];
|
|
37
|
-
}
|
|
38
|
-
const requests = chunk(personIds, MEMBERS_PER_REQUEST).map(t3);
|
|
39
|
-
t2 = useSuspenseQueries;
|
|
40
|
-
let t4;
|
|
41
|
-
if ($[7] !== apiClient) {
|
|
42
|
-
t4 = request => ({
|
|
43
|
-
queryKey: getRequestQueryKey(request),
|
|
44
|
-
queryFn: () => apiClient.chat.get(request).catch(throwResponseError)
|
|
45
|
-
});
|
|
46
|
-
$[7] = apiClient;
|
|
47
|
-
$[8] = t4;
|
|
48
|
-
} else {
|
|
49
|
-
t4 = $[8];
|
|
50
|
-
}
|
|
51
|
-
t1 = requests.map(t4);
|
|
52
|
-
$[0] = apiClient;
|
|
53
|
-
$[1] = conversationId;
|
|
54
|
-
$[2] = personIds;
|
|
55
|
-
$[3] = t1;
|
|
56
|
-
$[4] = t2;
|
|
57
|
-
} else {
|
|
58
|
-
t1 = $[3];
|
|
59
|
-
t2 = $[4];
|
|
60
|
-
}
|
|
61
|
-
let t3;
|
|
62
|
-
if ($[9] !== t1) {
|
|
63
|
-
t3 = {
|
|
64
|
-
queries: t1
|
|
65
|
-
};
|
|
66
|
-
$[9] = t1;
|
|
67
|
-
$[10] = t3;
|
|
68
|
-
} else {
|
|
69
|
-
t3 = $[10];
|
|
70
|
-
}
|
|
71
|
-
const queries = t2(t3);
|
|
72
|
-
let t4;
|
|
73
|
-
if ($[11] !== personIds || $[12] !== queries) {
|
|
74
|
-
const orderById = Object.fromEntries(personIds.map(_temp));
|
|
75
|
-
t4 = sortBy(queries.flatMap(_temp2), person => orderById[person.id] ?? personIds.length);
|
|
76
|
-
$[11] = personIds;
|
|
77
|
-
$[12] = queries;
|
|
78
|
-
$[13] = t4;
|
|
79
|
-
} else {
|
|
80
|
-
t4 = $[13];
|
|
81
|
-
}
|
|
82
|
-
const people = t4;
|
|
83
|
-
let t5;
|
|
84
|
-
if ($[14] !== people) {
|
|
85
|
-
t5 = {
|
|
86
|
-
data: people
|
|
87
|
-
};
|
|
88
|
-
$[14] = people;
|
|
89
|
-
$[15] = t5;
|
|
90
|
-
} else {
|
|
91
|
-
t5 = $[15];
|
|
92
|
-
}
|
|
93
|
-
return t5;
|
|
94
|
-
};
|
|
95
|
-
function _temp(id, index) {
|
|
96
|
-
return [id, index];
|
|
97
|
-
}
|
|
98
|
-
function _temp2(query) {
|
|
99
|
-
return query.data.data;
|
|
100
|
-
}
|
|
101
|
-
//# sourceMappingURL=use_system_message_people.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"use_system_message_people.js","names":["useSuspenseQueries","chunk","sortBy","throwResponseError","useApiClient","getRequestQueryKey","MEMBERS_PER_REQUEST","systemMessagePeopleRequest","conversationId","personIds","url","data","fields","Member","where","id","perPage","useSystemMessagePeople","t0","$","_c","apiClient","t1","t2","t3","ids","requests","map","t4","request","queryKey","queryFn","chat","get","catch","queries","orderById","Object","fromEntries","_temp","flatMap","_temp2","person","length","people","t5","index","query"],"sources":["../../src/hooks/use_system_message_people.ts"],"sourcesContent":["import { useSuspenseQueries } from '@tanstack/react-query'\nimport { chunk, sortBy } from 'lodash'\nimport { ApiCollection, MemberResource } from '../types'\nimport { GetRequest } from '../utils/client'\nimport { throwResponseError } from '../utils/response_error'\nimport { useApiClient } from './use_api_client'\nimport { getRequestQueryKey } from './use_suspense_api'\n\nexport const MEMBERS_PER_REQUEST = 100\n\ntype SystemMessagePeopleArgs = {\n conversationId: number\n personIds: number[]\n}\n\nexport type SystemMessagePerson = Pick<MemberResource, 'type' | 'id' | 'name' | 'avatar'>\n\nexport const systemMessagePeopleRequest = (\n conversationId: number,\n personIds: number[]\n): GetRequest => ({\n url: `/me/conversations/${conversationId}/members`,\n data: {\n fields: {\n Member: ['id', 'name', 'avatar'],\n },\n where: {\n id: personIds,\n },\n perPage: MEMBERS_PER_REQUEST,\n },\n})\n\nexport const useSystemMessagePeople = ({ conversationId, personIds }: SystemMessagePeopleArgs) => {\n const apiClient = useApiClient()\n const requests = chunk(personIds, MEMBERS_PER_REQUEST).map(ids =>\n systemMessagePeopleRequest(conversationId, ids)\n )\n\n const queries = useSuspenseQueries({\n queries: requests.map(request => ({\n queryKey: getRequestQueryKey(request),\n queryFn: (): Promise<ApiCollection<SystemMessagePerson>> =>\n apiClient.chat.get<ApiCollection<SystemMessagePerson>>(request).catch(throwResponseError),\n })),\n })\n\n const orderById = Object.fromEntries(personIds.map((id, index) => [id, index]))\n const people = sortBy(\n queries.flatMap(query => query.data.data),\n person => orderById[person.id] ?? personIds.length\n )\n\n return { data: people }\n}\n"],"mappings":"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","ignoreList":[]}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { QueryClientProvider } from '@tanstack/react-query'
|
|
2
|
-
import { render, type RenderOptions } from '@testing-library/react-native'
|
|
3
|
-
import React from 'react'
|
|
4
|
-
import { buildTestQueryClient } from './query_client'
|
|
5
|
-
|
|
6
|
-
export const renderWithQueryClient = (ui: React.ReactElement, options: RenderOptions = {}) => {
|
|
7
|
-
const queryClient = buildTestQueryClient()
|
|
8
|
-
const wrapper = ({ children }: { children: React.ReactNode }) => (
|
|
9
|
-
<QueryClientProvider client={queryClient}>{children}</QueryClientProvider>
|
|
10
|
-
)
|
|
11
|
-
|
|
12
|
-
return render(ui, { wrapper, ...options })
|
|
13
|
-
}
|
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
|
|
2
|
-
import { render, waitFor } from '@testing-library/react-native'
|
|
3
|
-
import React from 'react'
|
|
4
|
-
import { Image } from 'react-native'
|
|
5
|
-
import { buildTestQueryClient } from '../../../__utils__/query_client'
|
|
6
|
-
import type { AvatarUpdatePayload } from '../../../hooks/use_conversation_avatar_update'
|
|
7
|
-
import { ConversationAvatar } from '../conversation_avatar'
|
|
8
|
-
|
|
9
|
-
const conversation = {
|
|
10
|
-
id: 7,
|
|
11
|
-
customAvatarType: 'emoji' as const,
|
|
12
|
-
customAvatarKey: '🎉',
|
|
13
|
-
customAvatarColor: 'cosmic',
|
|
14
|
-
customAvatarImageUrl: null,
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
const imagePayload: AvatarUpdatePayload = {
|
|
18
|
-
kind: 'image',
|
|
19
|
-
color: 'cosmic',
|
|
20
|
-
imageAsset: { uri: 'file:///photo.jpg', width: 100, height: 100 },
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
let queryClient: QueryClient
|
|
24
|
-
let inFlight: { settle: () => void; done: Promise<unknown> }[]
|
|
25
|
-
|
|
26
|
-
beforeEach(() => {
|
|
27
|
-
queryClient = buildTestQueryClient({ defaultOptions: { mutations: { gcTime: Infinity } } })
|
|
28
|
-
inFlight = []
|
|
29
|
-
})
|
|
30
|
-
|
|
31
|
-
afterEach(async () => {
|
|
32
|
-
inFlight.forEach(({ settle }) => settle())
|
|
33
|
-
await Promise.all(inFlight.map(({ done }) => done))
|
|
34
|
-
queryClient.clear()
|
|
35
|
-
})
|
|
36
|
-
|
|
37
|
-
function startAvatarUpdate(conversationId: number) {
|
|
38
|
-
let settle = () => {}
|
|
39
|
-
const upload = new Promise<void>(resolve => (settle = resolve))
|
|
40
|
-
const mutation = queryClient.getMutationCache().build(queryClient, {
|
|
41
|
-
mutationKey: ['updateConversationAvatar', conversationId],
|
|
42
|
-
mutationFn: () => upload,
|
|
43
|
-
networkMode: 'always',
|
|
44
|
-
})
|
|
45
|
-
const done = mutation.execute(imagePayload)
|
|
46
|
-
inFlight.push({ settle, done })
|
|
47
|
-
return settle
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
function renderAvatar() {
|
|
51
|
-
return render(
|
|
52
|
-
<QueryClientProvider client={queryClient}>
|
|
53
|
-
<ConversationAvatar conversation={conversation} />
|
|
54
|
-
</QueryClientProvider>
|
|
55
|
-
)
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
describe('ConversationAvatar', () => {
|
|
59
|
-
it('renders the pending avatar update over the cached conversation data', () => {
|
|
60
|
-
startAvatarUpdate(conversation.id)
|
|
61
|
-
|
|
62
|
-
const view = renderAvatar()
|
|
63
|
-
|
|
64
|
-
expect(view.UNSAFE_getByType(Image).props.source).toEqual({ uri: 'file:///photo.jpg' })
|
|
65
|
-
expect(view.queryByText('🎉')).toBeNull()
|
|
66
|
-
})
|
|
67
|
-
|
|
68
|
-
it('ignores pending avatar updates for other conversations', () => {
|
|
69
|
-
startAvatarUpdate(conversation.id + 1)
|
|
70
|
-
|
|
71
|
-
const view = renderAvatar()
|
|
72
|
-
|
|
73
|
-
expect(view.getByText('🎉')).toBeTruthy()
|
|
74
|
-
})
|
|
75
|
-
|
|
76
|
-
it('returns to the cached conversation data once the update settles', async () => {
|
|
77
|
-
const settle = startAvatarUpdate(conversation.id)
|
|
78
|
-
const view = renderAvatar()
|
|
79
|
-
|
|
80
|
-
settle()
|
|
81
|
-
|
|
82
|
-
await waitFor(() => expect(view.getByText('🎉')).toBeTruthy())
|
|
83
|
-
})
|
|
84
|
-
})
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import { ResponseError } from '../../utils/response_error'
|
|
2
|
-
import { configuredRetry } from '../api_provider'
|
|
3
|
-
|
|
4
|
-
jest.mock('../../hooks/use_api_client')
|
|
5
|
-
|
|
6
|
-
const responseWithStatus = (status: number) =>
|
|
7
|
-
({
|
|
8
|
-
status,
|
|
9
|
-
statusText: 'Error',
|
|
10
|
-
ok: false,
|
|
11
|
-
url: 'https://api.pco.test/chat/v2/me',
|
|
12
|
-
headers: {},
|
|
13
|
-
clone: () => ({}),
|
|
14
|
-
json: () => Promise.resolve({}),
|
|
15
|
-
text: () => Promise.resolve(''),
|
|
16
|
-
arrayBuffer: () => Promise.resolve(new ArrayBuffer(0)),
|
|
17
|
-
errors: [],
|
|
18
|
-
}) as unknown as Response
|
|
19
|
-
|
|
20
|
-
describe('configuredRetry', () => {
|
|
21
|
-
it('does not retry client errors', () => {
|
|
22
|
-
;[400, 404, 414, 422, 429].forEach(status => {
|
|
23
|
-
expect(configuredRetry(0, new ResponseError(responseWithStatus(status) as any))).toBe(false)
|
|
24
|
-
expect(configuredRetry(0, responseWithStatus(status))).toBe(false)
|
|
25
|
-
})
|
|
26
|
-
})
|
|
27
|
-
|
|
28
|
-
it('retries server errors up to three times', () => {
|
|
29
|
-
const error = new ResponseError(responseWithStatus(503) as any)
|
|
30
|
-
|
|
31
|
-
expect(configuredRetry(0, error)).toBe(true)
|
|
32
|
-
expect(configuredRetry(2, error)).toBe(true)
|
|
33
|
-
expect(configuredRetry(3, error)).toBe(false)
|
|
34
|
-
})
|
|
35
|
-
|
|
36
|
-
it('retries network failures', () => {
|
|
37
|
-
expect(configuredRetry(0, new TypeError('Network request failed'))).toBe(true)
|
|
38
|
-
})
|
|
39
|
-
})
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import { QueryClientProvider } from '@tanstack/react-query'
|
|
2
|
-
import { act, renderHook } from '@testing-library/react-native'
|
|
3
|
-
import React from 'react'
|
|
4
|
-
import { buildTestQueryClient } from '../../__utils__/query_client'
|
|
5
|
-
import { useConversationAvatarUpdate } from '../use_conversation_avatar_update'
|
|
6
|
-
|
|
7
|
-
const mockPatch = jest.fn().mockResolvedValue({ data: { id: 7 } })
|
|
8
|
-
let finishUpload = () => {}
|
|
9
|
-
jest.mock('../use_api_client', () => ({ useApiClient: () => ({ chat: { patch: mockPatch } }) }))
|
|
10
|
-
jest.mock('../use_upload_client', () => ({
|
|
11
|
-
useUploadClient: () => ({
|
|
12
|
-
uploadFile: () => new Promise(resolve => (finishUpload = () => resolve({ id: 'upload-1' }))),
|
|
13
|
-
}),
|
|
14
|
-
}))
|
|
15
|
-
|
|
16
|
-
describe('useConversationAvatarUpdate', () => {
|
|
17
|
-
it('saves only the newest pick when an icon is chosen during a photo upload', async () => {
|
|
18
|
-
const queryClient = buildTestQueryClient({
|
|
19
|
-
defaultOptions: { mutations: { gcTime: Infinity } },
|
|
20
|
-
})
|
|
21
|
-
const wrapper = ({ children }: { children: React.ReactNode }) => (
|
|
22
|
-
<QueryClientProvider client={queryClient}>{children}</QueryClientProvider>
|
|
23
|
-
)
|
|
24
|
-
const { result } = renderHook(() => useConversationAvatarUpdate({ conversationId: 7 }), {
|
|
25
|
-
wrapper,
|
|
26
|
-
})
|
|
27
|
-
|
|
28
|
-
const photoSave = result.current.mutateAsync({
|
|
29
|
-
kind: 'image',
|
|
30
|
-
color: 'cosmic',
|
|
31
|
-
imageAsset: { uri: 'file:///photo.jpg', width: 100, height: 100 },
|
|
32
|
-
})
|
|
33
|
-
await act(() => result.current.mutateAsync({ kind: 'icon', key: 'star', color: 'cosmic' }))
|
|
34
|
-
finishUpload()
|
|
35
|
-
await act(() => photoSave)
|
|
36
|
-
|
|
37
|
-
expect(mockPatch).toHaveBeenCalledTimes(1)
|
|
38
|
-
expect(mockPatch.mock.calls[0][0].data.data.attributes.custom_avatar_type).toBe('icon')
|
|
39
|
-
})
|
|
40
|
-
})
|
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
import { notifyManager, QueryClient, QueryClientProvider } from '@tanstack/react-query'
|
|
2
|
-
import { act, renderHook, waitFor } from '@testing-library/react-native'
|
|
3
|
-
import React, { Suspense } from 'react'
|
|
4
|
-
import { MEMBERS_PER_REQUEST, useSystemMessagePeople } from '../use_system_message_people'
|
|
5
|
-
|
|
6
|
-
const mockGet = jest.fn()
|
|
7
|
-
jest.mock('../use_api_client', () => ({
|
|
8
|
-
useApiClient: () => ({ chat: { get: mockGet } }),
|
|
9
|
-
}))
|
|
10
|
-
|
|
11
|
-
notifyManager.setNotifyFunction(fn => act(fn))
|
|
12
|
-
|
|
13
|
-
const conversationId = 7
|
|
14
|
-
|
|
15
|
-
const member = (id: number) => ({ type: 'Member', id, name: `Person ${id}`, avatar: '' })
|
|
16
|
-
|
|
17
|
-
const membersPage = (ids: number[]) => ({
|
|
18
|
-
data: ids.map(member),
|
|
19
|
-
links: {},
|
|
20
|
-
meta: { count: ids.length, totalCount: ids.length },
|
|
21
|
-
})
|
|
22
|
-
|
|
23
|
-
const requestedIds = () => mockGet.mock.calls.map(([request]) => request.data.where.id as number[])
|
|
24
|
-
|
|
25
|
-
const render = (personIds: number[]) => {
|
|
26
|
-
const queryClient = new QueryClient({
|
|
27
|
-
defaultOptions: { queries: { retry: false, gcTime: 0 } },
|
|
28
|
-
})
|
|
29
|
-
const wrapper = ({ children }: { children: React.ReactNode }) => (
|
|
30
|
-
<QueryClientProvider client={queryClient}>
|
|
31
|
-
<Suspense fallback={null}>{children}</Suspense>
|
|
32
|
-
</QueryClientProvider>
|
|
33
|
-
)
|
|
34
|
-
|
|
35
|
-
return renderHook(() => useSystemMessagePeople({ conversationId, personIds }), { wrapper })
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
beforeEach(() => {
|
|
39
|
-
mockGet.mockReset()
|
|
40
|
-
mockGet.mockImplementation(({ data }) =>
|
|
41
|
-
Promise.resolve(membersPage([...(data.where.id as number[])].reverse()))
|
|
42
|
-
)
|
|
43
|
-
})
|
|
44
|
-
|
|
45
|
-
describe('useSystemMessagePeople', () => {
|
|
46
|
-
it('requests members in batches no larger than a page', async () => {
|
|
47
|
-
const personIds = Array.from({ length: 250 }, (_, i) => i + 1)
|
|
48
|
-
|
|
49
|
-
render(personIds)
|
|
50
|
-
|
|
51
|
-
await waitFor(() => expect(mockGet).toHaveBeenCalledTimes(3))
|
|
52
|
-
|
|
53
|
-
expect(requestedIds().map(ids => ids.length)).toEqual([100, 100, 50])
|
|
54
|
-
expect(requestedIds().flat()).toEqual(personIds)
|
|
55
|
-
mockGet.mock.calls.forEach(([request]) => {
|
|
56
|
-
expect(request.url).toEqual(`/me/conversations/${conversationId}/members`)
|
|
57
|
-
expect(request.data.perPage).toEqual(MEMBERS_PER_REQUEST)
|
|
58
|
-
})
|
|
59
|
-
})
|
|
60
|
-
|
|
61
|
-
it('returns everyone in the order of the system message', async () => {
|
|
62
|
-
const personIds = Array.from({ length: 150 }, (_, i) => 1000 - i)
|
|
63
|
-
|
|
64
|
-
const { result } = render(personIds)
|
|
65
|
-
|
|
66
|
-
await waitFor(() => expect(result.current?.data).toHaveLength(150))
|
|
67
|
-
|
|
68
|
-
expect(result.current.data.map(({ id }) => id)).toEqual(personIds)
|
|
69
|
-
})
|
|
70
|
-
|
|
71
|
-
it('makes a single request for a small list', async () => {
|
|
72
|
-
const { result } = render([3, 1, 2])
|
|
73
|
-
|
|
74
|
-
await waitFor(() => expect(result.current?.data).toHaveLength(3))
|
|
75
|
-
|
|
76
|
-
expect(mockGet).toHaveBeenCalledTimes(1)
|
|
77
|
-
expect(result.current.data.map(({ id }) => id)).toEqual([3, 1, 2])
|
|
78
|
-
})
|
|
79
|
-
})
|
|
@@ -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
|
-
}
|