@planningcenter/chat-react-native 4.3.0-rc.10 → 4.3.0-rc.12
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/screens/conversation_select_recipients/components/view_more_link_row.d.ts +2 -1
- package/build/screens/conversation_select_recipients/components/view_more_link_row.d.ts.map +1 -1
- package/build/screens/conversation_select_recipients/components/view_more_link_row.js +39 -24
- package/build/screens/conversation_select_recipients/components/view_more_link_row.js.map +1 -1
- package/build/screens/search/components/conversation_result_row.d.ts +8 -0
- package/build/screens/search/components/conversation_result_row.d.ts.map +1 -0
- package/build/screens/search/components/conversation_result_row.js +80 -0
- package/build/screens/search/components/conversation_result_row.js.map +1 -0
- package/build/screens/search/components/conversation_results.d.ts +8 -0
- package/build/screens/search/components/conversation_results.d.ts.map +1 -0
- package/build/screens/search/components/conversation_results.js +77 -0
- package/build/screens/search/components/conversation_results.js.map +1 -0
- package/build/screens/search/components/message_result_row.d.ts +8 -0
- package/build/screens/search/components/message_result_row.d.ts.map +1 -0
- package/build/screens/search/components/message_result_row.js +152 -0
- package/build/screens/search/components/message_result_row.js.map +1 -0
- package/build/screens/search/components/result_row.d.ts +10 -0
- package/build/screens/search/components/result_row.d.ts.map +1 -0
- package/build/screens/search/components/result_row.js +102 -0
- package/build/screens/search/components/result_row.js.map +1 -0
- package/build/screens/search/components/results_section.d.ts +9 -0
- package/build/screens/search/components/results_section.d.ts.map +1 -0
- package/build/screens/search/components/results_section.js +51 -0
- package/build/screens/search/components/results_section.js.map +1 -0
- package/build/screens/search/components/snippet.d.ts +8 -0
- package/build/screens/search/components/snippet.d.ts.map +1 -0
- package/build/screens/search/components/snippet.js +68 -0
- package/build/screens/search/components/snippet.js.map +1 -0
- package/build/utils/client/request_helpers.js +1 -1
- package/build/utils/client/request_helpers.js.map +1 -1
- package/package.json +2 -2
- package/src/__tests__/utils/client.ts +3 -4
- package/src/screens/conversation_select_recipients/components/view_more_link_row.tsx +12 -3
- package/src/screens/search/components/__tests__/conversation_results.test.tsx +55 -0
- package/src/screens/search/components/__tests__/message_result_row.test.tsx +65 -0
- package/src/screens/search/components/__tests__/result_row.test.tsx +33 -0
- package/src/screens/search/components/conversation_result_row.tsx +36 -0
- package/src/screens/search/components/conversation_results.tsx +39 -0
- package/src/screens/search/components/message_result_row.tsx +48 -0
- package/src/screens/search/components/result_row.tsx +58 -0
- package/src/screens/search/components/results_section.tsx +34 -0
- package/src/screens/search/components/snippet.tsx +37 -0
- package/src/utils/client/__tests__/request_helpers.test.ts +40 -0
- package/src/utils/client/request_helpers.ts +1 -1
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import { StyleSheet } from 'react-native'
|
|
3
|
+
import { Text } from '../../../components/display'
|
|
4
|
+
import { useTheme } from '../../../hooks'
|
|
5
|
+
import type { SnippetSegment } from '../../../types/resources/search_result'
|
|
6
|
+
|
|
7
|
+
interface SnippetProps {
|
|
8
|
+
segments: SnippetSegment[]
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export function Snippet({ segments }: SnippetProps) {
|
|
12
|
+
const styles = useStyles()
|
|
13
|
+
|
|
14
|
+
return (
|
|
15
|
+
<>
|
|
16
|
+
{segments.map((segment, index) => (
|
|
17
|
+
<Text key={index} variant="tertiary" style={segment.match && styles.match}>
|
|
18
|
+
{segment.text}
|
|
19
|
+
</Text>
|
|
20
|
+
))}
|
|
21
|
+
</>
|
|
22
|
+
)
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export function plainSnippetText(segments: SnippetSegment[]) {
|
|
26
|
+
return segments.map(segment => segment.text).join('')
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const useStyles = () => {
|
|
30
|
+
const { colors } = useTheme()
|
|
31
|
+
|
|
32
|
+
return StyleSheet.create({
|
|
33
|
+
match: {
|
|
34
|
+
color: colors.interaction,
|
|
35
|
+
},
|
|
36
|
+
})
|
|
37
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { instrumentedFetch } from '../instrumented_fetch'
|
|
2
|
+
import { makeRequest } from '../request_helpers'
|
|
3
|
+
|
|
4
|
+
jest.mock('../instrumented_fetch', () => ({ instrumentedFetch: jest.fn() }))
|
|
5
|
+
|
|
6
|
+
const mockFetch = jest.mocked(instrumentedFetch)
|
|
7
|
+
|
|
8
|
+
const fetchedUrl = () => new URL(mockFetch.mock.calls[0][0])
|
|
9
|
+
|
|
10
|
+
const get = (data: Record<string, unknown>) =>
|
|
11
|
+
makeRequest({ action: 'GET', url: 'https://api.example.com/search_results', data, headers: {} })
|
|
12
|
+
|
|
13
|
+
describe('makeRequest', () => {
|
|
14
|
+
beforeEach(() => {
|
|
15
|
+
mockFetch.mockResolvedValue(new Response('{}', { status: 200 }))
|
|
16
|
+
})
|
|
17
|
+
|
|
18
|
+
afterEach(() => {
|
|
19
|
+
mockFetch.mockReset()
|
|
20
|
+
})
|
|
21
|
+
|
|
22
|
+
it('serializes data as snake_case query params', async () => {
|
|
23
|
+
await get({ q: 'potluck', perPage: 20 })
|
|
24
|
+
|
|
25
|
+
const { searchParams } = fetchedUrl()
|
|
26
|
+
expect(searchParams.get('q')).toBe('potluck')
|
|
27
|
+
expect(searchParams.get('per_page')).toBe('20')
|
|
28
|
+
})
|
|
29
|
+
|
|
30
|
+
it.each(['Pastor Bob', 'café', '#potluck', 'Q&A', '100%'])(
|
|
31
|
+
'sends %p so the server reads it back unchanged',
|
|
32
|
+
async term => {
|
|
33
|
+
await get({ q: term })
|
|
34
|
+
|
|
35
|
+
const { search, searchParams } = fetchedUrl()
|
|
36
|
+
expect(searchParams.get('q')).toBe(term)
|
|
37
|
+
expect(() => decodeURIComponent(search)).not.toThrow()
|
|
38
|
+
}
|
|
39
|
+
)
|
|
40
|
+
})
|
|
@@ -33,7 +33,7 @@ export const makeRequest = ({ action = 'GET', url, data = {}, headers = {} }: Ma
|
|
|
33
33
|
|
|
34
34
|
const body = ['POST', 'PATCH'].includes(action) ? JSON.stringify(data) : undefined
|
|
35
35
|
|
|
36
|
-
return instrumentedFetch(
|
|
36
|
+
return instrumentedFetch(uri.toString(), {
|
|
37
37
|
method: action,
|
|
38
38
|
headers,
|
|
39
39
|
body,
|