@planningcenter/chat-react-native 4.3.0-rc.9 → 4.3.1-rc.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/conversation/message_form.js +1 -1
- package/build/components/conversation/message_form.js.map +1 -1
- package/build/hooks/use_debounced_search_term.d.ts +2 -0
- package/build/hooks/use_debounced_search_term.d.ts.map +1 -0
- package/build/hooks/use_debounced_search_term.js +40 -0
- package/build/hooks/use_debounced_search_term.js.map +1 -0
- package/build/hooks/use_search_results.d.ts +19 -0
- package/build/hooks/use_search_results.d.ts.map +1 -0
- package/build/hooks/use_search_results.js +153 -0
- package/build/hooks/use_search_results.js.map +1 -0
- 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/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 +142 -158
- package/build/screens/conversation_select_recipients/conversation_select_direct_message_recipients_screen.js.map +1 -1
- package/build/screens/message_actions_screen.js +6 -2
- package/build/screens/message_actions_screen.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/search_results_list.d.ts +8 -0
- package/build/screens/search/components/search_results_list.d.ts.map +1 -0
- package/build/screens/search/components/search_results_list.js +314 -0
- package/build/screens/search/components/search_results_list.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/screens/search/search_screen.d.ts.map +1 -1
- package/build/screens/search/search_screen.js +18 -9
- package/build/screens/search/search_screen.js.map +1 -1
- package/build/utils/client/request_helpers.js +1 -1
- package/build/utils/client/request_helpers.js.map +1 -1
- package/package.json +3 -3
- package/src/__tests__/screens/message_actions_screen.test.tsx +136 -0
- package/src/__tests__/utils/client.ts +3 -4
- package/src/components/conversation/__tests__/message_form.test.tsx +83 -0
- package/src/components/conversation/message_form.tsx +1 -1
- package/src/hooks/__tests__/use_debounced_search_term.test.tsx +38 -0
- package/src/hooks/__tests__/use_search_results.test.tsx +88 -0
- package/src/hooks/use_debounced_search_term.ts +20 -0
- package/src/hooks/use_search_results.ts +78 -0
- package/src/screens/conversation_select_recipients/components/view_more_link_row.tsx +12 -3
- package/src/screens/conversation_select_recipients/conversation_select_direct_message_recipients_screen.tsx +3 -8
- package/src/screens/message_actions_screen.tsx +6 -2
- package/src/screens/search/__tests__/search_screen.test.tsx +64 -0
- 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/__tests__/search_results_list.test.tsx +135 -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/search_results_list.tsx +147 -0
- package/src/screens/search/components/snippet.tsx +37 -0
- package/src/screens/search/search_screen.tsx +9 -1
- 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
|
+
}
|
|
@@ -3,6 +3,7 @@ import {
|
|
|
3
3
|
NativeStackNavigationOptions,
|
|
4
4
|
NativeStackScreenProps,
|
|
5
5
|
} from '@react-navigation/native-stack'
|
|
6
|
+
import { noop } from 'lodash'
|
|
6
7
|
import React, { useState } from 'react'
|
|
7
8
|
import { StyleSheet, View } from 'react-native'
|
|
8
9
|
import { KeyboardView } from '../../components'
|
|
@@ -10,8 +11,10 @@ import {
|
|
|
10
11
|
composeOptions,
|
|
11
12
|
withMinimalBack,
|
|
12
13
|
} from '../../components/display/platform_modal_header_buttons'
|
|
14
|
+
import { useDebouncedSearchTerm } from '../../hooks/use_debounced_search_term'
|
|
13
15
|
import { SearchPromptBlankState } from './components/search_blank_states'
|
|
14
16
|
import { SearchField } from './components/search_field'
|
|
17
|
+
import { SearchResultsList } from './components/search_results_list'
|
|
15
18
|
|
|
16
19
|
export const SearchScreenOptions = ({
|
|
17
20
|
navigation,
|
|
@@ -23,12 +26,17 @@ export const SearchScreenOptions = ({
|
|
|
23
26
|
|
|
24
27
|
export function SearchScreen() {
|
|
25
28
|
const [term, setTerm] = useState('')
|
|
29
|
+
const debouncedTerm = useDebouncedSearchTerm(term)
|
|
26
30
|
|
|
27
31
|
return (
|
|
28
32
|
<KeyboardView>
|
|
29
33
|
<View style={styles.container} testID="search-screen">
|
|
30
34
|
<SearchField term={term} onChange={setTerm} />
|
|
31
|
-
|
|
35
|
+
{debouncedTerm.length > 0 ? (
|
|
36
|
+
<SearchResultsList key={debouncedTerm} term={debouncedTerm} onSelect={noop} />
|
|
37
|
+
) : (
|
|
38
|
+
<SearchPromptBlankState />
|
|
39
|
+
)}
|
|
32
40
|
</View>
|
|
33
41
|
</KeyboardView>
|
|
34
42
|
)
|
|
@@ -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,
|