@planningcenter/chat-react-native 4.2.1-qa-staging.11 → 4.2.1-qa-staging.13
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/attachments/giphy_attachment.d.ts.map +1 -1
- package/build/components/conversation/attachments/giphy_attachment.js +2 -2
- package/build/components/conversation/attachments/giphy_attachment.js.map +1 -1
- package/build/components/conversation/message_form.d.ts.map +1 -1
- package/build/components/conversation/message_form.js +2 -2
- package/build/components/conversation/message_form.js.map +1 -1
- package/build/components/display/conversation_avatar.d.ts +1 -2
- package/build/components/display/conversation_avatar.d.ts.map +1 -1
- package/build/components/display/conversation_avatar.js.map +1 -1
- package/build/navigation/index.d.ts +5 -0
- package/build/navigation/index.d.ts.map +1 -1
- package/build/navigation/index.js +5 -0
- package/build/navigation/index.js.map +1 -1
- package/build/screens/age_check/age_check_underage_screen.d.ts.map +1 -1
- package/build/screens/age_check/age_check_underage_screen.js +3 -2
- package/build/screens/age_check/age_check_underage_screen.js.map +1 -1
- package/build/screens/bug_report_screen.d.ts.map +1 -1
- package/build/screens/bug_report_screen.js +2 -2
- package/build/screens/bug_report_screen.js.map +1 -1
- package/build/screens/conversations/components/search_list_header_component.d.ts.map +1 -1
- package/build/screens/conversations/components/search_list_header_component.js +159 -133
- package/build/screens/conversations/components/search_list_header_component.js.map +1 -1
- package/build/screens/get_help_screen.js +4 -4
- package/build/screens/get_help_screen.js.map +1 -1
- package/build/screens/message_actions_screen.js +7 -9
- package/build/screens/message_actions_screen.js.map +1 -1
- package/build/screens/search/components/search_field.d.ts +7 -0
- package/build/screens/search/components/search_field.d.ts.map +1 -0
- package/build/screens/search/components/search_field.js +152 -0
- package/build/screens/search/components/search_field.js.map +1 -0
- package/build/screens/search/search_screen.d.ts +5 -0
- package/build/screens/search/search_screen.d.ts.map +1 -0
- package/build/screens/search/search_screen.js +43 -0
- package/build/screens/search/search_screen.js.map +1 -0
- package/build/types/resources/conversation.d.ts +1 -0
- package/build/types/resources/conversation.d.ts.map +1 -1
- package/build/types/resources/conversation.js.map +1 -1
- package/build/types/resources/index.d.ts +1 -0
- package/build/types/resources/index.d.ts.map +1 -1
- package/build/types/resources/index.js +1 -0
- package/build/types/resources/index.js.map +1 -1
- package/build/types/resources/search_result.d.ts +29 -0
- package/build/types/resources/search_result.d.ts.map +1 -0
- package/build/types/resources/search_result.js +2 -0
- package/build/types/resources/search_result.js.map +1 -0
- package/build/utils/request/get_search_results.d.ts +13 -0
- package/build/utils/request/get_search_results.d.ts.map +1 -0
- package/build/utils/request/get_search_results.js +20 -0
- package/build/utils/request/get_search_results.js.map +1 -0
- package/package.json +3 -3
- package/src/__tests__/components/conversation/attachments/giphy_attachment.test.tsx +76 -0
- package/src/__tests__/screens/get_help_screen.test.ts +40 -0
- package/src/__tests__/screens/message_actions_screen.test.tsx +8 -3
- package/src/components/conversation/attachments/giphy_attachment.tsx +2 -3
- package/src/components/conversation/message_form.tsx +1 -1
- package/src/components/display/conversation_avatar.tsx +1 -10
- package/src/navigation/index.tsx +5 -0
- package/src/screens/age_check/age_check_underage_screen.tsx +3 -2
- package/src/screens/bug_report_screen.tsx +2 -10
- package/src/screens/conversations/components/__tests__/search_list_header_component.test.tsx +62 -0
- package/src/screens/conversations/components/search_list_header_component.tsx +11 -0
- package/src/screens/get_help_screen.tsx +4 -4
- package/src/screens/message_actions_screen.tsx +3 -4
- package/src/screens/search/components/__tests__/search_field.test.tsx +29 -0
- package/src/screens/search/components/search_field.tsx +81 -0
- package/src/screens/search/search_screen.tsx +39 -0
- package/src/types/resources/conversation.ts +9 -0
- package/src/types/resources/index.ts +1 -0
- package/src/types/resources/search_result.ts +32 -0
- package/src/utils/__tests__/get_search_results.test.ts +24 -0
- package/src/utils/request/get_search_results.ts +23 -0
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { ConversationAvatarData } from './conversation';
|
|
2
|
+
interface BaseSearchResultResource {
|
|
3
|
+
id: string;
|
|
4
|
+
title: string;
|
|
5
|
+
url: string;
|
|
6
|
+
}
|
|
7
|
+
export interface SnippetSegment {
|
|
8
|
+
text: string;
|
|
9
|
+
match: boolean;
|
|
10
|
+
}
|
|
11
|
+
export interface ConversationSearchResultResource extends BaseSearchResultResource {
|
|
12
|
+
type: 'conversation';
|
|
13
|
+
extra: {
|
|
14
|
+
avatar: ConversationAvatarData;
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
export interface MessageSearchResultResource extends BaseSearchResultResource {
|
|
18
|
+
type: 'message';
|
|
19
|
+
extra: {
|
|
20
|
+
conversationId: number;
|
|
21
|
+
authorName: string;
|
|
22
|
+
snippet: SnippetSegment[];
|
|
23
|
+
createdAt: string;
|
|
24
|
+
avatar: ConversationAvatarData;
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
export type SearchResultResource = ConversationSearchResultResource | MessageSearchResultResource;
|
|
28
|
+
export {};
|
|
29
|
+
//# sourceMappingURL=search_result.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"search_result.d.ts","sourceRoot":"","sources":["../../../src/types/resources/search_result.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,gBAAgB,CAAA;AAE5D,UAAU,wBAAwB;IAChC,EAAE,EAAE,MAAM,CAAA;IACV,KAAK,EAAE,MAAM,CAAA;IACb,GAAG,EAAE,MAAM,CAAA;CACZ;AAED,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,EAAE,OAAO,CAAA;CACf;AAED,MAAM,WAAW,gCAAiC,SAAQ,wBAAwB;IAChF,IAAI,EAAE,cAAc,CAAA;IACpB,KAAK,EAAE;QACL,MAAM,EAAE,sBAAsB,CAAA;KAC/B,CAAA;CACF;AAED,MAAM,WAAW,2BAA4B,SAAQ,wBAAwB;IAC3E,IAAI,EAAE,SAAS,CAAA;IACf,KAAK,EAAE;QACL,cAAc,EAAE,MAAM,CAAA;QACtB,UAAU,EAAE,MAAM,CAAA;QAClB,OAAO,EAAE,cAAc,EAAE,CAAA;QACzB,SAAS,EAAE,MAAM,CAAA;QACjB,MAAM,EAAE,sBAAsB,CAAA;KAC/B,CAAA;CACF;AAED,MAAM,MAAM,oBAAoB,GAAG,gCAAgC,GAAG,2BAA2B,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"search_result.js","names":[],"sources":["../../../src/types/resources/search_result.ts"],"sourcesContent":["import type { ConversationAvatarData } from './conversation'\n\ninterface BaseSearchResultResource {\n id: string\n title: string\n url: string\n}\n\nexport interface SnippetSegment {\n text: string\n match: boolean\n}\n\nexport interface ConversationSearchResultResource extends BaseSearchResultResource {\n type: 'conversation'\n extra: {\n avatar: ConversationAvatarData\n }\n}\n\nexport interface MessageSearchResultResource extends BaseSearchResultResource {\n type: 'message'\n extra: {\n conversationId: number\n authorName: string\n snippet: SnippetSegment[]\n createdAt: string\n avatar: ConversationAvatarData\n }\n}\n\nexport type SearchResultResource = ConversationSearchResultResource | MessageSearchResultResource\n"],"mappings":"","ignoreList":[]}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export declare const SEARCH_RESULTS_PAGE_SIZE = 20;
|
|
2
|
+
export declare const getSearchResultsRequestArgs: (term: string) => {
|
|
3
|
+
url: string;
|
|
4
|
+
data: {
|
|
5
|
+
q: string;
|
|
6
|
+
perPage: number;
|
|
7
|
+
fields: {
|
|
8
|
+
SearchResult: string[];
|
|
9
|
+
};
|
|
10
|
+
};
|
|
11
|
+
};
|
|
12
|
+
export declare const getSearchResultsQueryKey: (term: string) => import("../..").RequestQueryKey;
|
|
13
|
+
//# sourceMappingURL=get_search_results.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get_search_results.d.ts","sourceRoot":"","sources":["../../../src/utils/request/get_search_results.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,wBAAwB,KAAK,CAAA;AAE1C,eAAO,MAAM,2BAA2B,GAAI,MAAM,MAAM;;;;;;;;;CAavD,CAAA;AAED,eAAO,MAAM,wBAAwB,GAAI,MAAM,MAAM,oCAGpD,CAAA"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { getRequestQueryKey } from '../../hooks/use_suspense_api';
|
|
2
|
+
export const SEARCH_RESULTS_PAGE_SIZE = 20;
|
|
3
|
+
export const getSearchResultsRequestArgs = term => {
|
|
4
|
+
const url = '/search_results';
|
|
5
|
+
return {
|
|
6
|
+
url,
|
|
7
|
+
data: {
|
|
8
|
+
q: term,
|
|
9
|
+
perPage: SEARCH_RESULTS_PAGE_SIZE,
|
|
10
|
+
fields: {
|
|
11
|
+
SearchResult: ['type', 'title', 'url', 'extra']
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
export const getSearchResultsQueryKey = term => {
|
|
17
|
+
const requestArgs = getSearchResultsRequestArgs(term);
|
|
18
|
+
return getRequestQueryKey(requestArgs);
|
|
19
|
+
};
|
|
20
|
+
//# sourceMappingURL=get_search_results.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get_search_results.js","names":["getRequestQueryKey","SEARCH_RESULTS_PAGE_SIZE","getSearchResultsRequestArgs","term","url","data","q","perPage","fields","SearchResult","getSearchResultsQueryKey","requestArgs"],"sources":["../../../src/utils/request/get_search_results.ts"],"sourcesContent":["import { getRequestQueryKey } from '../../hooks/use_suspense_api'\n\nexport const SEARCH_RESULTS_PAGE_SIZE = 20\n\nexport const getSearchResultsRequestArgs = (term: string) => {\n const url = '/search_results'\n\n return {\n url,\n data: {\n q: term,\n perPage: SEARCH_RESULTS_PAGE_SIZE,\n fields: {\n SearchResult: ['type', 'title', 'url', 'extra'],\n },\n },\n }\n}\n\nexport const getSearchResultsQueryKey = (term: string) => {\n const requestArgs = getSearchResultsRequestArgs(term)\n return getRequestQueryKey(requestArgs)\n}\n"],"mappings":"AAAA,SAASA,kBAAkB,QAAQ,8BAA8B;AAEjE,OAAO,MAAMC,wBAAwB,GAAG,EAAE;AAE1C,OAAO,MAAMC,2BAA2B,GAAIC,IAAY,IAAK;EAC3D,MAAMC,GAAG,GAAG,iBAAiB;EAE7B,OAAO;IACLA,GAAG;IACHC,IAAI,EAAE;MACJC,CAAC,EAAEH,IAAI;MACPI,OAAO,EAAEN,wBAAwB;MACjCO,MAAM,EAAE;QACNC,YAAY,EAAE,CAAC,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO;MAChD;IACF;EACF,CAAC;AACH,CAAC;AAED,OAAO,MAAMC,wBAAwB,GAAIP,IAAY,IAAK;EACxD,MAAMQ,WAAW,GAAGT,2BAA2B,CAACC,IAAI,CAAC;EACrD,OAAOH,kBAAkB,CAACW,WAAW,CAAC;AACxC,CAAC","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@planningcenter/chat-react-native",
|
|
3
|
-
"version": "4.2.1-qa-staging.
|
|
3
|
+
"version": "4.2.1-qa-staging.13",
|
|
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.2.1-qa-staging.
|
|
36
|
+
"@planningcenter/emoji-keyboard": "4.2.1-qa-staging.13",
|
|
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": "503582608c2c4f65a91fea304ee8d7fdcbf2764f"
|
|
88
88
|
}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { DefaultTheme, ThemeProvider } from '@react-navigation/native'
|
|
2
|
+
import { fireEvent, render } from '@testing-library/react-native'
|
|
3
|
+
import React from 'react'
|
|
4
|
+
import { Linking as RNLinking } from 'react-native'
|
|
5
|
+
import { GiphyAttachment } from '../../../../components/conversation/attachments/giphy_attachment'
|
|
6
|
+
import {
|
|
7
|
+
DenormalizedGiphyAttachmentResource,
|
|
8
|
+
GiphyAttachmentVariant,
|
|
9
|
+
} from '../../../../types/resources/denormalized_attachment_resource'
|
|
10
|
+
import {
|
|
11
|
+
AudioAdapter,
|
|
12
|
+
ChatAdapters,
|
|
13
|
+
ClipboardAdapter,
|
|
14
|
+
ImagePickerAdapter,
|
|
15
|
+
LinkingAdapter,
|
|
16
|
+
VideoAdapter,
|
|
17
|
+
} from '../../../../utils/native_adapters'
|
|
18
|
+
|
|
19
|
+
const variant: GiphyAttachmentVariant = {
|
|
20
|
+
url: 'https://media.giphy.com/cat.gif',
|
|
21
|
+
width: '200',
|
|
22
|
+
height: '100',
|
|
23
|
+
size: '1',
|
|
24
|
+
frames: '1',
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const attachment: DenormalizedGiphyAttachmentResource = {
|
|
28
|
+
type: 'giphy',
|
|
29
|
+
id: '1',
|
|
30
|
+
title: 'cat',
|
|
31
|
+
titleLink: 'https://giphy.com/gifs/cat',
|
|
32
|
+
thumbUrl: variant.url,
|
|
33
|
+
giphy: {
|
|
34
|
+
original: variant,
|
|
35
|
+
fixedHeight: variant,
|
|
36
|
+
fixedHeightStill: variant,
|
|
37
|
+
fixedHeightDownsampled: variant,
|
|
38
|
+
fixedWidth: variant,
|
|
39
|
+
fixedWidthStill: variant,
|
|
40
|
+
fixedWidthDownsampled: variant,
|
|
41
|
+
},
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const hostOpenURL = jest.fn(async (_: string) => {})
|
|
45
|
+
|
|
46
|
+
describe('GiphyAttachment', () => {
|
|
47
|
+
beforeAll(() => {
|
|
48
|
+
ChatAdapters.configure({
|
|
49
|
+
clipboard: new ClipboardAdapter({
|
|
50
|
+
getStringAsync: async () => '',
|
|
51
|
+
setStringAsync: async () => {},
|
|
52
|
+
}),
|
|
53
|
+
audio: new AudioAdapter({ useAudio: () => ({}) as any }),
|
|
54
|
+
video: new VideoAdapter({ Player: React.forwardRef(() => null) }),
|
|
55
|
+
imagePicker: new ImagePickerAdapter({
|
|
56
|
+
openCameraAsync: async () => ({ canceled: true, assets: null }),
|
|
57
|
+
openImageLibraryAsync: async () => ({ canceled: true, assets: null }),
|
|
58
|
+
}),
|
|
59
|
+
linking: new LinkingAdapter({ openURL: hostOpenURL, canOpenURL: async () => true }),
|
|
60
|
+
})
|
|
61
|
+
})
|
|
62
|
+
|
|
63
|
+
it("opens the Giphy link through the host app's linking adapter", () => {
|
|
64
|
+
const rnOpenURL = jest.spyOn(RNLinking, 'openURL')
|
|
65
|
+
const { getByText } = render(
|
|
66
|
+
<ThemeProvider value={DefaultTheme}>
|
|
67
|
+
<GiphyAttachment attachment={attachment} onMessageLongPress={jest.fn()} />
|
|
68
|
+
</ThemeProvider>
|
|
69
|
+
)
|
|
70
|
+
|
|
71
|
+
fireEvent.press(getByText('/giphy'))
|
|
72
|
+
|
|
73
|
+
expect(hostOpenURL).toHaveBeenCalledWith('https://giphy.com/gifs/cat')
|
|
74
|
+
expect(rnOpenURL).not.toHaveBeenCalled()
|
|
75
|
+
})
|
|
76
|
+
})
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import { Linking as RNLinking } from 'react-native'
|
|
3
|
+
import { sendEmail } from '../../screens/get_help_screen'
|
|
4
|
+
import {
|
|
5
|
+
AudioAdapter,
|
|
6
|
+
ChatAdapters,
|
|
7
|
+
ClipboardAdapter,
|
|
8
|
+
ImagePickerAdapter,
|
|
9
|
+
LinkingAdapter,
|
|
10
|
+
VideoAdapter,
|
|
11
|
+
} from '../../utils/native_adapters'
|
|
12
|
+
|
|
13
|
+
const hostOpenURL = jest.fn(async (_: string) => {})
|
|
14
|
+
|
|
15
|
+
describe('sendEmail', () => {
|
|
16
|
+
beforeAll(() => {
|
|
17
|
+
ChatAdapters.configure({
|
|
18
|
+
clipboard: new ClipboardAdapter({
|
|
19
|
+
getStringAsync: async () => '',
|
|
20
|
+
setStringAsync: async () => {},
|
|
21
|
+
}),
|
|
22
|
+
audio: new AudioAdapter({ useAudio: () => ({}) as any }),
|
|
23
|
+
video: new VideoAdapter({ Player: React.forwardRef(() => null) }),
|
|
24
|
+
imagePicker: new ImagePickerAdapter({
|
|
25
|
+
openCameraAsync: async () => ({ canceled: true, assets: null }),
|
|
26
|
+
openImageLibraryAsync: async () => ({ canceled: true, assets: null }),
|
|
27
|
+
}),
|
|
28
|
+
linking: new LinkingAdapter({ openURL: hostOpenURL, canOpenURL: async () => true }),
|
|
29
|
+
})
|
|
30
|
+
})
|
|
31
|
+
|
|
32
|
+
it("opens mailto with the system, not the host app's linking adapter", () => {
|
|
33
|
+
const rnOpenURL = jest.spyOn(RNLinking, 'openURL').mockResolvedValue(undefined)
|
|
34
|
+
|
|
35
|
+
sendEmail('help@example.com')
|
|
36
|
+
|
|
37
|
+
expect(rnOpenURL).toHaveBeenCalledWith('mailto:help@example.com')
|
|
38
|
+
expect(hostOpenURL).not.toHaveBeenCalled()
|
|
39
|
+
})
|
|
40
|
+
})
|
|
@@ -36,9 +36,10 @@ const mockMessage: MessageResource = {
|
|
|
36
36
|
messageType: 'user',
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
+
const mockGoBack = jest.fn()
|
|
39
40
|
jest.mock('@react-navigation/native', () => ({
|
|
40
41
|
...jest.requireActual('@react-navigation/native'),
|
|
41
|
-
useNavigation: () => ({ navigate: jest.fn(), dispatch: jest.fn(), goBack:
|
|
42
|
+
useNavigation: () => ({ navigate: jest.fn(), dispatch: jest.fn(), goBack: mockGoBack }),
|
|
42
43
|
}))
|
|
43
44
|
jest.mock('../../hooks/use_api_client', () => ({ useApiClient: () => ({}) }))
|
|
44
45
|
jest.mock('../../hooks/use_features', () => ({
|
|
@@ -106,12 +107,16 @@ describe('MessageActionsScreen', () => {
|
|
|
106
107
|
jest.clearAllMocks()
|
|
107
108
|
})
|
|
108
109
|
|
|
109
|
-
it('copies the message text and gives success haptic feedback', async () => {
|
|
110
|
+
it('copies the message text and gives success haptic feedback before closing', async () => {
|
|
110
111
|
const { getByText } = renderScreen()
|
|
111
112
|
|
|
112
113
|
fireEvent.press(getByText('Copy text'))
|
|
113
114
|
|
|
114
115
|
expect(setStringAsync).toHaveBeenCalledWith('Copy me')
|
|
115
|
-
await waitFor(() => expect(
|
|
116
|
+
await waitFor(() => expect(mockGoBack).toHaveBeenCalledTimes(1))
|
|
117
|
+
expect(notificationSuccess).toHaveBeenCalledTimes(1)
|
|
118
|
+
expect(notificationSuccess.mock.invocationCallOrder[0]).toBeLessThan(
|
|
119
|
+
mockGoBack.mock.invocationCallOrder[0]
|
|
120
|
+
)
|
|
116
121
|
})
|
|
117
122
|
})
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { PlatformPressable } from '@react-navigation/elements'
|
|
2
2
|
import React from 'react'
|
|
3
|
-
import { Text, StyleSheet
|
|
3
|
+
import { Text, StyleSheet } from 'react-native'
|
|
4
4
|
import { useTheme } from '../../../hooks'
|
|
5
5
|
import { DenormalizedGiphyAttachmentResource } from '../../../types/resources/denormalized_attachment_resource'
|
|
6
|
-
import { assertKeysAreNumbers } from '../../../utils'
|
|
6
|
+
import { assertKeysAreNumbers, Linking } from '../../../utils'
|
|
7
7
|
import { tokens } from '../../../vendor/tapestry/tokens'
|
|
8
8
|
import { Image } from '../../display'
|
|
9
9
|
|
|
@@ -22,7 +22,6 @@ export function GiphyAttachment({
|
|
|
22
22
|
|
|
23
23
|
function handlePress() {
|
|
24
24
|
if (titleLink) {
|
|
25
|
-
// Open Giphy link in the default web browser
|
|
26
25
|
Linking.openURL(titleLink)
|
|
27
26
|
}
|
|
28
27
|
}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { useNavigation, useTheme as useNavigationTheme, useRoute } from '@react-navigation/native'
|
|
2
2
|
import React, { useCallback, useContext, useEffect, useRef, useState } from 'react'
|
|
3
3
|
import {
|
|
4
|
-
Linking,
|
|
5
4
|
Platform,
|
|
6
5
|
Pressable,
|
|
7
6
|
ScrollView,
|
|
@@ -34,6 +33,7 @@ import {
|
|
|
34
33
|
FileAttachment,
|
|
35
34
|
} from '../../types/resources/denormalized_attachment_resource_for_create'
|
|
36
35
|
import {
|
|
36
|
+
Linking,
|
|
37
37
|
Log,
|
|
38
38
|
MAX_FONT_SIZE_MULTIPLIER_LANDMARK,
|
|
39
39
|
platformFontWeightMedium,
|
|
@@ -1,21 +1,12 @@
|
|
|
1
1
|
import React from 'react'
|
|
2
2
|
import type { ViewStyle } from 'react-native'
|
|
3
|
-
import type {
|
|
3
|
+
import type { ConversationAvatarData } from '../../types'
|
|
4
4
|
import AvatarPrimitive, { type AvatarRootProps } from '../primitive/avatar_primitive'
|
|
5
5
|
import { AvatarGroup } from './avatar_group'
|
|
6
6
|
import { EmojiAvatar } from './emoji_avatar'
|
|
7
7
|
import { type IconString } from './icon'
|
|
8
8
|
import { IconAvatar } from './icon_avatar'
|
|
9
9
|
|
|
10
|
-
type ConversationAvatarData = Pick<
|
|
11
|
-
ConversationResource,
|
|
12
|
-
| 'customAvatarType'
|
|
13
|
-
| 'customAvatarKey'
|
|
14
|
-
| 'customAvatarColor'
|
|
15
|
-
| 'customAvatarImageUrl'
|
|
16
|
-
| 'previewAvatarUrls'
|
|
17
|
-
>
|
|
18
|
-
|
|
19
10
|
type ResolvedAvatar =
|
|
20
11
|
| { kind: 'image'; url: string }
|
|
21
12
|
| { kind: 'icon'; iconKey: string; color: string | null }
|
package/src/navigation/index.tsx
CHANGED
|
@@ -72,6 +72,7 @@ import { NotFound } from '../screens/not_found'
|
|
|
72
72
|
import { NotificationSettingsScreen } from '../screens/notification_settings_screen'
|
|
73
73
|
import { PreferredAppSelectionScreen } from '../screens/preferred_app_selection_screen'
|
|
74
74
|
import { ReactionsScreen, ReactionsScreenOptions } from '../screens/reactions_screen'
|
|
75
|
+
import { SearchScreen, SearchScreenOptions } from '../screens/search/search_screen'
|
|
75
76
|
import { SendGiphyScreen, SendGiphyScreenOptions } from '../screens/send_giphy_screen'
|
|
76
77
|
import { SettingsScreen } from '../screens/settings_screen'
|
|
77
78
|
import {
|
|
@@ -186,6 +187,10 @@ export const ChatStack = createNativeStackNavigator({
|
|
|
186
187
|
screen: ConversationFiltersScreen,
|
|
187
188
|
options: ConversationFiltersScreenOptions,
|
|
188
189
|
},
|
|
190
|
+
Search: {
|
|
191
|
+
screen: SearchScreen,
|
|
192
|
+
options: SearchScreenOptions,
|
|
193
|
+
},
|
|
189
194
|
Conversation: {
|
|
190
195
|
screen: ConversationScreen,
|
|
191
196
|
options: ({ route, navigation }) =>
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { useRoute, RouteProp } from '@react-navigation/native'
|
|
2
2
|
import React from 'react'
|
|
3
|
-
import { Linking, StyleSheet, View, ScrollView } from 'react-native'
|
|
3
|
+
import { Linking as RNLinking, StyleSheet, View, ScrollView } from 'react-native'
|
|
4
4
|
import { Heading } from '../../components'
|
|
5
5
|
import { Icon, Text, TextInlineButton } from '../../components/display'
|
|
6
6
|
import { useTheme } from '../../hooks'
|
|
7
|
+
import { Linking } from '../../utils'
|
|
7
8
|
import type { AgeCheckParams } from './screen_props'
|
|
8
9
|
|
|
9
10
|
export interface AgeCheckUnderageScreenProps {
|
|
@@ -18,7 +19,7 @@ export function AgeCheckUnderageScreen({ contactEmail }: AgeCheckUnderageScreenP
|
|
|
18
19
|
|
|
19
20
|
const openChurchAdminHelp = () => {
|
|
20
21
|
if (!email) return
|
|
21
|
-
|
|
22
|
+
RNLinking.openURL(`mailto:${email}`)
|
|
22
23
|
}
|
|
23
24
|
|
|
24
25
|
const openTerms = () => {
|
|
@@ -5,15 +5,7 @@ import type {
|
|
|
5
5
|
} from '@react-navigation/native-stack'
|
|
6
6
|
import { startsWith } from 'lodash'
|
|
7
7
|
import React, { useCallback, useState } from 'react'
|
|
8
|
-
import {
|
|
9
|
-
View,
|
|
10
|
-
StyleSheet,
|
|
11
|
-
TextInput,
|
|
12
|
-
Linking,
|
|
13
|
-
ScrollView,
|
|
14
|
-
TouchableOpacity,
|
|
15
|
-
Platform,
|
|
16
|
-
} from 'react-native'
|
|
8
|
+
import { View, StyleSheet, TextInput, ScrollView, TouchableOpacity, Platform } from 'react-native'
|
|
17
9
|
import { useSafeAreaInsets } from 'react-native-safe-area-context'
|
|
18
10
|
import {
|
|
19
11
|
Button,
|
|
@@ -38,7 +30,7 @@ import { useTheme } from '../hooks'
|
|
|
38
30
|
import { useAppName } from '../hooks/use_app_name'
|
|
39
31
|
import { useReportBugAction } from '../hooks/use_report_bug_action'
|
|
40
32
|
import { useUploadClient } from '../hooks/use_upload_client'
|
|
41
|
-
import { ImagePicker, ImagePickerResult, platformFontWeightBold } from '../utils'
|
|
33
|
+
import { ImagePicker, ImagePickerResult, Linking, platformFontWeightBold } from '../utils'
|
|
42
34
|
|
|
43
35
|
const MAX_DESCRIPTION_LENGTH = 2000
|
|
44
36
|
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { fireEvent, render } from '@testing-library/react-native'
|
|
2
|
+
import React from 'react'
|
|
3
|
+
import { SearchListHeaderComponent } from '../search_list_header_component'
|
|
4
|
+
|
|
5
|
+
const mockNavigate = jest.fn()
|
|
6
|
+
|
|
7
|
+
jest.mock('@react-navigation/native', () => ({
|
|
8
|
+
...jest.requireActual('@react-navigation/native'),
|
|
9
|
+
useNavigation: () => ({ setParams: jest.fn(), navigate: mockNavigate }),
|
|
10
|
+
useRoute: () => ({ params: {} }),
|
|
11
|
+
}))
|
|
12
|
+
|
|
13
|
+
jest.mock('../../../../hooks/use_groups', () => ({
|
|
14
|
+
useCanDisplayGroups: () => true,
|
|
15
|
+
}))
|
|
16
|
+
jest.mock('../../../../hooks/use_direct_messages_eligible', () => ({
|
|
17
|
+
useDirectMessagesEligible: () => true,
|
|
18
|
+
}))
|
|
19
|
+
jest.mock('../../../../hooks/use_has_direct_messages', () => ({
|
|
20
|
+
useHasDirectMessages: () => true,
|
|
21
|
+
}))
|
|
22
|
+
jest.mock('../../../../hooks/use_chat_permissions', () => ({
|
|
23
|
+
useCanCreateConversations: () => true,
|
|
24
|
+
}))
|
|
25
|
+
jest.mock('../../../../hooks/use_new_conversation_entry', () => ({
|
|
26
|
+
useNewConversationEntry: () => 'select_type',
|
|
27
|
+
}))
|
|
28
|
+
jest.mock('../../../../hooks/use_current_person', () => ({
|
|
29
|
+
useCurrentPersonCache: () => ({ update: jest.fn() }),
|
|
30
|
+
}))
|
|
31
|
+
jest.mock('../../../../hooks/use_conversations_actions', () => ({
|
|
32
|
+
useMarkAllRead: () => ({ markAllRead: jest.fn(), isPending: false }),
|
|
33
|
+
}))
|
|
34
|
+
jest.mock('../../../../hooks/use_new_conversation_from_filter', () => ({
|
|
35
|
+
useNewConversationFromFilter: () => undefined,
|
|
36
|
+
}))
|
|
37
|
+
jest.mock('../../../../hooks/use_api', () => ({
|
|
38
|
+
useApiGet: () => ({ data: undefined }),
|
|
39
|
+
}))
|
|
40
|
+
|
|
41
|
+
describe('SearchListHeaderComponent search button', () => {
|
|
42
|
+
beforeEach(() => mockNavigate.mockClear())
|
|
43
|
+
|
|
44
|
+
it('navigates to Search on press', () => {
|
|
45
|
+
const view = render(<SearchListHeaderComponent />)
|
|
46
|
+
|
|
47
|
+
fireEvent.press(view.getByTestId('conversations-search-button'))
|
|
48
|
+
|
|
49
|
+
expect(mockNavigate).toHaveBeenCalledTimes(1)
|
|
50
|
+
expect(mockNavigate).toHaveBeenCalledWith('Search')
|
|
51
|
+
})
|
|
52
|
+
|
|
53
|
+
it('renders the search button after the other actions', () => {
|
|
54
|
+
const view = render(<SearchListHeaderComponent />)
|
|
55
|
+
|
|
56
|
+
const buttons = view.getAllByRole('button').map(button => button.props.accessibilityLabel)
|
|
57
|
+
|
|
58
|
+
expect(buttons.indexOf('Search')).toBeGreaterThanOrEqual(0)
|
|
59
|
+
expect(buttons.indexOf('Search')).toBeGreaterThan(buttons.indexOf('Chat settings'))
|
|
60
|
+
expect(buttons.indexOf('Search')).toBeGreaterThan(buttons.indexOf('New conversation'))
|
|
61
|
+
})
|
|
62
|
+
})
|
|
@@ -110,6 +110,10 @@ export const SearchListHeaderComponent = () => {
|
|
|
110
110
|
[navigation]
|
|
111
111
|
)
|
|
112
112
|
|
|
113
|
+
const handleSearch = useCallback(() => {
|
|
114
|
+
navigation.navigate('Search')
|
|
115
|
+
}, [navigation])
|
|
116
|
+
|
|
113
117
|
const handleChatSettings = useCallback(() => {
|
|
114
118
|
navigation.navigate('ChatSettings', {})
|
|
115
119
|
}, [navigation])
|
|
@@ -188,6 +192,13 @@ export const SearchListHeaderComponent = () => {
|
|
|
188
192
|
maxFontSizeMultiplier={MAX_FONT_SIZE_MULTIPLIER_LANDMARK}
|
|
189
193
|
/>
|
|
190
194
|
)}
|
|
195
|
+
<ListHeaderActionButton
|
|
196
|
+
name="general.search"
|
|
197
|
+
onPress={handleSearch}
|
|
198
|
+
accessibilityLabel="Search"
|
|
199
|
+
testID="conversations-search-button"
|
|
200
|
+
maxFontSizeMultiplier={MAX_FONT_SIZE_MULTIPLIER_LANDMARK}
|
|
201
|
+
/>
|
|
191
202
|
{shouldShowHeaderFiltersButton && <ToggleButton {...moreFiltersButtonProps} />}
|
|
192
203
|
</View>
|
|
193
204
|
</View>
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { StaticScreenProps, useNavigation } from '@react-navigation/native'
|
|
2
2
|
import { useCallback, useMemo } from 'react'
|
|
3
|
-
import { Alert, Linking, StyleSheet, View } from 'react-native'
|
|
3
|
+
import { Alert, Linking as RNLinking, StyleSheet, View } from 'react-native'
|
|
4
4
|
import { Heading, PressableRow, Text, TextInlineButton } from '../components'
|
|
5
5
|
import { useApiGet, useTheme } from '../hooks'
|
|
6
6
|
import { useAppName } from '../hooks/use_app_name'
|
|
7
7
|
import { useOrganization } from '../hooks/use_organization'
|
|
8
8
|
import { ResourceObject } from '../types'
|
|
9
|
-
import { Clipboard } from '../utils'
|
|
9
|
+
import { Clipboard, Linking } from '../utils'
|
|
10
10
|
|
|
11
11
|
type GetHelpScreenRouteProps = {
|
|
12
12
|
type?: 'chat' | 'general'
|
|
@@ -119,7 +119,7 @@ export function sendEmail(email: string) {
|
|
|
119
119
|
|
|
120
120
|
const url = encodeURI(`mailto:${email}`)
|
|
121
121
|
|
|
122
|
-
|
|
122
|
+
RNLinking.openURL(url).catch(() => {
|
|
123
123
|
Alert.alert('Oops', `Unable to open: ${email}`, [
|
|
124
124
|
{ text: 'Copy to clipboard', onPress: () => Clipboard.setStringAsync(email) },
|
|
125
125
|
{ text: 'OK' },
|
|
@@ -132,7 +132,7 @@ export function placePhoneCall(phoneNumber: string) {
|
|
|
132
132
|
|
|
133
133
|
const url = encodeURI(`tel:${phoneNumber}`)
|
|
134
134
|
|
|
135
|
-
|
|
135
|
+
RNLinking.openURL(url).catch(() => {
|
|
136
136
|
Alert.alert('Oops', `Unable to open: ${phoneNumber}`, [
|
|
137
137
|
{ text: 'Copy to clipboard', onPress: () => Clipboard.setStringAsync(phoneNumber) },
|
|
138
138
|
{ text: 'OK' },
|
|
@@ -124,10 +124,9 @@ function MessageActionsScreenContent({
|
|
|
124
124
|
})
|
|
125
125
|
}, [navigation, conversation_id, message.id, message.replyRootId, replyRootAuthorName])
|
|
126
126
|
|
|
127
|
-
const handleCopyPress = () => {
|
|
128
|
-
Clipboard.setStringAsync(message?.text || attachmentForCopy() || '')
|
|
129
|
-
|
|
130
|
-
)
|
|
127
|
+
const handleCopyPress = async () => {
|
|
128
|
+
await Clipboard.setStringAsync(message?.text || attachmentForCopy() || '')
|
|
129
|
+
Haptic.notificationSuccess()
|
|
131
130
|
navigation.goBack()
|
|
132
131
|
}
|
|
133
132
|
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { fireEvent, render } from '@testing-library/react-native'
|
|
2
|
+
import React from 'react'
|
|
3
|
+
import { SearchField } from '../search_field'
|
|
4
|
+
|
|
5
|
+
const inputLabel = 'Search titles and messages'
|
|
6
|
+
const clearLabel = 'Clear search'
|
|
7
|
+
|
|
8
|
+
describe('SearchField', () => {
|
|
9
|
+
it('reports typed text through onChange', () => {
|
|
10
|
+
const onChange = jest.fn()
|
|
11
|
+
const view = render(<SearchField term="" onChange={onChange} />)
|
|
12
|
+
|
|
13
|
+
fireEvent.changeText(view.getByLabelText(inputLabel), 'budget')
|
|
14
|
+
|
|
15
|
+
expect(onChange).toHaveBeenCalledWith('budget')
|
|
16
|
+
})
|
|
17
|
+
|
|
18
|
+
it('shows the clear button only for a non-empty term and clears on press', () => {
|
|
19
|
+
const onChange = jest.fn()
|
|
20
|
+
const view = render(<SearchField term="" onChange={onChange} />)
|
|
21
|
+
|
|
22
|
+
expect(view.queryByLabelText(clearLabel)).toBeNull()
|
|
23
|
+
|
|
24
|
+
view.rerender(<SearchField term="budget" onChange={onChange} />)
|
|
25
|
+
fireEvent.press(view.getByLabelText(clearLabel))
|
|
26
|
+
|
|
27
|
+
expect(onChange).toHaveBeenCalledWith('')
|
|
28
|
+
})
|
|
29
|
+
})
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { useRef } from 'react'
|
|
2
|
+
import { Pressable, StyleSheet, TextInput, View } from 'react-native'
|
|
3
|
+
import { Icon } from '../../../components'
|
|
4
|
+
import { AutoFocusAwareTextInput } from '../../../components/display/text_input'
|
|
5
|
+
import { useTheme } from '../../../hooks'
|
|
6
|
+
|
|
7
|
+
const PLACEHOLDER = 'Search titles and messages'
|
|
8
|
+
|
|
9
|
+
interface SearchFieldProps {
|
|
10
|
+
term: string
|
|
11
|
+
onChange: (term: string) => void
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export function SearchField({ term, onChange }: SearchFieldProps) {
|
|
15
|
+
const styles = useStyles()
|
|
16
|
+
const { colors } = useTheme()
|
|
17
|
+
const inputRef = useRef<TextInput>(null)
|
|
18
|
+
|
|
19
|
+
const clear = () => {
|
|
20
|
+
onChange('')
|
|
21
|
+
inputRef.current?.clear()
|
|
22
|
+
inputRef.current?.focus()
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
return (
|
|
26
|
+
<View style={styles.container}>
|
|
27
|
+
<View style={styles.field}>
|
|
28
|
+
<Icon name="general.search" size={16} color={colors.iconColorDefaultSecondary} />
|
|
29
|
+
<AutoFocusAwareTextInput
|
|
30
|
+
autoFocus
|
|
31
|
+
autoCorrect={false}
|
|
32
|
+
inputRef={inputRef}
|
|
33
|
+
placeholder={PLACEHOLDER}
|
|
34
|
+
placeholderTextColor={colors.textColorDefaultPlaceholder}
|
|
35
|
+
accessibilityLabel={PLACEHOLDER}
|
|
36
|
+
value={term}
|
|
37
|
+
onChangeText={onChange}
|
|
38
|
+
returnKeyType="search"
|
|
39
|
+
style={styles.input}
|
|
40
|
+
/>
|
|
41
|
+
{term.length > 0 && (
|
|
42
|
+
<Pressable
|
|
43
|
+
onPress={clear}
|
|
44
|
+
hitSlop={8}
|
|
45
|
+
accessibilityRole="button"
|
|
46
|
+
accessibilityLabel="Clear search"
|
|
47
|
+
>
|
|
48
|
+
<Icon name="general.x" size={12} color={colors.iconColorDefaultSecondary} />
|
|
49
|
+
</Pressable>
|
|
50
|
+
)}
|
|
51
|
+
</View>
|
|
52
|
+
</View>
|
|
53
|
+
)
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
const useStyles = () => {
|
|
57
|
+
const { colors } = useTheme()
|
|
58
|
+
|
|
59
|
+
return StyleSheet.create({
|
|
60
|
+
container: {
|
|
61
|
+
paddingHorizontal: 16,
|
|
62
|
+
paddingVertical: 8,
|
|
63
|
+
},
|
|
64
|
+
field: {
|
|
65
|
+
flexDirection: 'row',
|
|
66
|
+
alignItems: 'center',
|
|
67
|
+
gap: 8,
|
|
68
|
+
borderWidth: 1,
|
|
69
|
+
borderColor: colors.borderColorDefaultBase,
|
|
70
|
+
borderRadius: 8,
|
|
71
|
+
paddingHorizontal: 12,
|
|
72
|
+
paddingVertical: 8,
|
|
73
|
+
},
|
|
74
|
+
input: {
|
|
75
|
+
flex: 1,
|
|
76
|
+
color: colors.textColorDefaultPrimary,
|
|
77
|
+
fontSize: 16,
|
|
78
|
+
paddingVertical: 2,
|
|
79
|
+
},
|
|
80
|
+
})
|
|
81
|
+
}
|