@planningcenter/chat-react-native 4.6.3 → 4.6.4-qa-staging.1
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/contexts/api_provider.d.ts +1 -0
- package/build/contexts/api_provider.d.ts.map +1 -1
- package/build/contexts/api_provider.js +11 -5
- package/build/contexts/api_provider.js.map +1 -1
- package/build/hooks/index.d.ts +1 -0
- package/build/hooks/index.d.ts.map +1 -1
- package/build/hooks/index.js +1 -0
- package/build/hooks/index.js.map +1 -1
- package/build/hooks/use_current_person.d.ts.map +1 -1
- package/build/hooks/use_current_person.js +1 -1
- package/build/hooks/use_current_person.js.map +1 -1
- package/build/hooks/use_person_settings.d.ts +1 -0
- package/build/hooks/use_person_settings.d.ts.map +1 -1
- package/build/hooks/use_person_settings.js +10 -7
- package/build/hooks/use_person_settings.js.map +1 -1
- package/build/hooks/use_system_message_people.d.ts +14 -0
- package/build/hooks/use_system_message_people.d.ts.map +1 -0
- package/build/hooks/use_system_message_people.js +101 -0
- package/build/hooks/use_system_message_people.js.map +1 -0
- package/build/screens/settings_screen.js +6 -6
- package/build/screens/settings_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 +33 -96
- package/build/screens/system_message_people_screen.js.map +1 -1
- package/build/types/resources/person.d.ts +1 -0
- package/build/types/resources/person.d.ts.map +1 -1
- package/build/types/resources/person.js.map +1 -1
- package/package.json +3 -3
- package/src/__tests__/hooks/use_person_settings.test.tsx +53 -0
- package/src/__tests__/screens/settings_screen.test.tsx +58 -0
- package/src/contexts/__tests__/configured_retry.test.ts +39 -0
- package/src/contexts/api_provider.tsx +12 -5
- package/src/hooks/__tests__/use_system_message_people.test.tsx +79 -0
- package/src/hooks/index.ts +1 -0
- package/src/hooks/use_current_person.ts +1 -0
- package/src/hooks/use_person_settings.ts +3 -1
- package/src/hooks/use_system_message_people.ts +55 -0
- package/src/screens/settings_screen.tsx +4 -4
- package/src/screens/system_message_people_screen.tsx +6 -20
- package/src/types/resources/person.ts +1 -0
|
@@ -5,7 +5,7 @@ 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 { useSystemMessagePeople } from '../hooks/use_system_message_people';
|
|
9
9
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
10
10
|
export const SystemMessagePeopleScreenOptions = getFormSheetScreenOptions({
|
|
11
11
|
sheetAllowedDetents: Platform.select({
|
|
@@ -15,7 +15,7 @@ export const SystemMessagePeopleScreenOptions = getFormSheetScreenOptions({
|
|
|
15
15
|
headerTitle: 'People'
|
|
16
16
|
});
|
|
17
17
|
export function SystemMessagePeopleScreen(t0) {
|
|
18
|
-
const $ = _c(
|
|
18
|
+
const $ = _c(9);
|
|
19
19
|
const {
|
|
20
20
|
route
|
|
21
21
|
} = t0;
|
|
@@ -24,110 +24,50 @@ export function SystemMessagePeopleScreen(t0) {
|
|
|
24
24
|
person_ids
|
|
25
25
|
} = route.params;
|
|
26
26
|
const styles = useStyles();
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
};
|
|
33
|
-
$[0] = t2;
|
|
34
|
-
} else {
|
|
35
|
-
t2 = $[0];
|
|
36
|
-
}
|
|
37
|
-
let t3;
|
|
38
|
-
if ($[1] !== person_ids) {
|
|
39
|
-
t3 = {
|
|
40
|
-
id: person_ids
|
|
27
|
+
let t1;
|
|
28
|
+
if ($[0] !== conversation_id || $[1] !== person_ids) {
|
|
29
|
+
t1 = {
|
|
30
|
+
conversationId: conversation_id,
|
|
31
|
+
personIds: person_ids
|
|
41
32
|
};
|
|
33
|
+
$[0] = conversation_id;
|
|
42
34
|
$[1] = person_ids;
|
|
43
|
-
$[2] =
|
|
35
|
+
$[2] = t1;
|
|
44
36
|
} else {
|
|
45
|
-
|
|
46
|
-
}
|
|
47
|
-
let t4;
|
|
48
|
-
if ($[3] !== person_ids.length || $[4] !== t3) {
|
|
49
|
-
t4 = {
|
|
50
|
-
fields: t2,
|
|
51
|
-
where: t3,
|
|
52
|
-
limit: person_ids.length
|
|
53
|
-
};
|
|
54
|
-
$[3] = person_ids.length;
|
|
55
|
-
$[4] = t3;
|
|
56
|
-
$[5] = t4;
|
|
57
|
-
} else {
|
|
58
|
-
t4 = $[5];
|
|
59
|
-
}
|
|
60
|
-
let t5;
|
|
61
|
-
if ($[6] !== t1 || $[7] !== t4) {
|
|
62
|
-
t5 = {
|
|
63
|
-
url: t1,
|
|
64
|
-
data: t4
|
|
65
|
-
};
|
|
66
|
-
$[6] = t1;
|
|
67
|
-
$[7] = t4;
|
|
68
|
-
$[8] = t5;
|
|
69
|
-
} else {
|
|
70
|
-
t5 = $[8];
|
|
37
|
+
t1 = $[2];
|
|
71
38
|
}
|
|
72
39
|
const {
|
|
73
|
-
data:
|
|
74
|
-
} =
|
|
75
|
-
let
|
|
76
|
-
if ($[
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
$[10] = t6;
|
|
80
|
-
} else {
|
|
81
|
-
t6 = $[10];
|
|
82
|
-
}
|
|
83
|
-
const orderById = t6;
|
|
84
|
-
let t7;
|
|
85
|
-
if ($[11] !== members || $[12] !== orderById) {
|
|
86
|
-
let t8;
|
|
87
|
-
if ($[14] !== orderById) {
|
|
88
|
-
t8 = (a, b) => (orderById[a.id] ?? 0) - (orderById[b.id] ?? 0);
|
|
89
|
-
$[14] = orderById;
|
|
90
|
-
$[15] = t8;
|
|
91
|
-
} else {
|
|
92
|
-
t8 = $[15];
|
|
93
|
-
}
|
|
94
|
-
t7 = [...members].sort(t8);
|
|
95
|
-
$[11] = members;
|
|
96
|
-
$[12] = orderById;
|
|
97
|
-
$[13] = t7;
|
|
98
|
-
} else {
|
|
99
|
-
t7 = $[13];
|
|
100
|
-
}
|
|
101
|
-
const sortedMembers = t7;
|
|
102
|
-
let t8;
|
|
103
|
-
if ($[16] !== sortedMembers || $[17] !== styles.contentContainer) {
|
|
104
|
-
t8 = /*#__PURE__*/_jsx(FlatList, {
|
|
105
|
-
data: sortedMembers,
|
|
40
|
+
data: people
|
|
41
|
+
} = useSystemMessagePeople(t1);
|
|
42
|
+
let t2;
|
|
43
|
+
if ($[3] !== people || $[4] !== styles.contentContainer) {
|
|
44
|
+
t2 = /*#__PURE__*/_jsx(FlatList, {
|
|
45
|
+
data: people,
|
|
106
46
|
contentContainerStyle: styles.contentContainer,
|
|
107
|
-
keyExtractor:
|
|
108
|
-
renderItem:
|
|
47
|
+
keyExtractor: _temp,
|
|
48
|
+
renderItem: _temp2
|
|
109
49
|
});
|
|
110
|
-
$[
|
|
111
|
-
$[
|
|
112
|
-
$[
|
|
50
|
+
$[3] = people;
|
|
51
|
+
$[4] = styles.contentContainer;
|
|
52
|
+
$[5] = t2;
|
|
113
53
|
} else {
|
|
114
|
-
|
|
54
|
+
t2 = $[5];
|
|
115
55
|
}
|
|
116
|
-
let
|
|
117
|
-
if ($[
|
|
118
|
-
|
|
56
|
+
let t3;
|
|
57
|
+
if ($[6] !== styles.formSheetContent || $[7] !== t2) {
|
|
58
|
+
t3 = /*#__PURE__*/_jsx(FormSheet.Root, {
|
|
119
59
|
contentStyle: styles.formSheetContent,
|
|
120
|
-
children:
|
|
60
|
+
children: t2
|
|
121
61
|
});
|
|
122
|
-
$[
|
|
123
|
-
$[
|
|
124
|
-
$[
|
|
62
|
+
$[6] = styles.formSheetContent;
|
|
63
|
+
$[7] = t2;
|
|
64
|
+
$[8] = t3;
|
|
125
65
|
} else {
|
|
126
|
-
|
|
66
|
+
t3 = $[8];
|
|
127
67
|
}
|
|
128
|
-
return
|
|
68
|
+
return t3;
|
|
129
69
|
}
|
|
130
|
-
function
|
|
70
|
+
function _temp2(t0) {
|
|
131
71
|
const {
|
|
132
72
|
item: item_0
|
|
133
73
|
} = t0;
|
|
@@ -135,12 +75,9 @@ function _temp3(t0) {
|
|
|
135
75
|
person: item_0
|
|
136
76
|
});
|
|
137
77
|
}
|
|
138
|
-
function
|
|
78
|
+
function _temp(item) {
|
|
139
79
|
return item.id.toString();
|
|
140
80
|
}
|
|
141
|
-
function _temp(id, i) {
|
|
142
|
-
return [id, i];
|
|
143
|
-
}
|
|
144
81
|
const Person = memo(t0 => {
|
|
145
82
|
const $ = _c(9);
|
|
146
83
|
const {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"system_message_people_screen.js","names":["React","memo","Platform","StyleSheet","View","FlatList","useSafeAreaInsets","Avatar","Text","FormSheet","getFormSheetScreenOptions","
|
|
1
|
+
{"version":3,"file":"system_message_people_screen.js","names":["React","memo","Platform","StyleSheet","View","FlatList","useSafeAreaInsets","Avatar","Text","FormSheet","getFormSheetScreenOptions","useSystemMessagePeople","jsx","_jsx","jsxs","_jsxs","SystemMessagePeopleScreenOptions","sheetAllowedDetents","select","android","default","headerTitle","SystemMessagePeopleScreen","t0","$","_c","route","conversation_id","person_ids","params","styles","useStyles","t1","conversationId","personIds","data","people","t2","contentContainer","contentContainerStyle","keyExtractor","_temp","renderItem","_temp2","t3","formSheetContent","Root","contentStyle","children","item","item_0","Person","id","toString","person","avatar","sourceUri","size","name","personName","variant","numberOfLines","style","personRow","bottom","create","paddingTop","paddingBottom","flexDirection","alignItems","gap","paddingVertical","paddingHorizontal","flex"],"sources":["../../src/screens/system_message_people_screen.tsx"],"sourcesContent":["import { StaticScreenProps } from '@react-navigation/native'\nimport React, { memo } from 'react'\nimport { Platform, StyleSheet, View } from 'react-native'\nimport { FlatList } from 'react-native-gesture-handler'\nimport { useSafeAreaInsets } from 'react-native-safe-area-context'\nimport { Avatar, Text } from '../components'\nimport FormSheet, { getFormSheetScreenOptions } from '../components/primitive/form_sheet'\nimport { SystemMessagePerson, useSystemMessagePeople } from '../hooks/use_system_message_people'\n\nexport const SystemMessagePeopleScreenOptions = getFormSheetScreenOptions({\n sheetAllowedDetents: Platform.select({\n android: [0.5, 0.94],\n default: [0.5, 1],\n }),\n headerTitle: 'People',\n})\n\nexport type SystemMessagePeopleScreenProps = StaticScreenProps<{\n conversation_id: number\n person_ids: number[]\n}>\n\nexport function SystemMessagePeopleScreen({ route }: SystemMessagePeopleScreenProps) {\n const { conversation_id, person_ids } = route.params\n const styles = useStyles()\n\n const { data: people } = useSystemMessagePeople({\n conversationId: conversation_id,\n personIds: person_ids,\n })\n\n return (\n <FormSheet.Root contentStyle={styles.formSheetContent}>\n <FlatList\n data={people}\n contentContainerStyle={styles.contentContainer}\n keyExtractor={item => item.id.toString()}\n renderItem={({ item }) => <Person person={item} />}\n />\n </FormSheet.Root>\n )\n}\n\nconst Person = memo(({ person }: { person: SystemMessagePerson }) => {\n const styles = useStyles()\n\n return (\n <View style={styles.personRow}>\n <Avatar sourceUri={person.avatar} size=\"sm\" />\n <Text variant=\"tertiary\" numberOfLines={2} style={styles.personName}>\n {person.name}\n </Text>\n </View>\n )\n})\n\nconst useStyles = () => {\n const { bottom } = useSafeAreaInsets()\n\n return StyleSheet.create({\n formSheetContent: {\n paddingTop: 16,\n },\n contentContainer: {\n paddingTop: 8,\n paddingBottom: bottom + 24,\n },\n personRow: {\n flexDirection: 'row',\n alignItems: 'center',\n gap: 8,\n paddingVertical: 8,\n paddingHorizontal: 16,\n flex: 1,\n },\n personName: {\n flex: 1,\n },\n })\n}\n"],"mappings":";AACA,OAAOA,KAAK,IAAIC,IAAI,QAAQ,OAAO;AACnC,SAASC,QAAQ,EAAEC,UAAU,EAAEC,IAAI,QAAQ,cAAc;AACzD,SAASC,QAAQ,QAAQ,8BAA8B;AACvD,SAASC,iBAAiB,QAAQ,gCAAgC;AAClE,SAASC,MAAM,EAAEC,IAAI,QAAQ,eAAe;AAC5C,OAAOC,SAAS,IAAIC,yBAAyB,QAAQ,oCAAoC;AACzF,SAA8BC,sBAAsB,QA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AA,EACM,KAAK;QAAAC,UAAA,EACR,QAAQ;QAAAC,GAAA,EACf,CAAC;QAAAC,eAAA,EACW,CAAC;QAAAC,iBAAA,EACC,EAAE;QAAAC,IAAA,EACf;MACR,CAAC;MAAAd,UAAA,EACW;QAAAc,IAAA,EACJ;MACR;IACF,CAAC,CAAC;IAAAjD,CAAA,MAAAwC,MAAA;IAAAxC,CAAA,MAAAD,EAAA;EAAA;IAAAA,EAAA,GAAAC,CAAA;EAAA;EAAA,OAnBKD,EAmBL;AAAA,CACH","ignoreList":[]}
|
|
@@ -18,6 +18,7 @@ export interface CurrentPersonResource extends PersonResource {
|
|
|
18
18
|
ageQualificationStatus?: AgeQualificationStatus;
|
|
19
19
|
directMessagesDisabled: boolean;
|
|
20
20
|
directMessagesEligible: boolean;
|
|
21
|
+
canManageDirectMessages?: boolean;
|
|
21
22
|
canBrowseArchivedConversations?: boolean;
|
|
22
23
|
under_18: boolean;
|
|
23
24
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"person.d.ts","sourceRoot":"","sources":["../../../src/types/resources/person.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAA;AAElD,eAAO,MAAM,sBAAsB;;;;CAIzB,CAAA;AAEV,MAAM,MAAM,sBAAsB,GAChC,CAAC,OAAO,sBAAsB,CAAC,CAAC,MAAM,OAAO,sBAAsB,CAAC,CAAA;AAEtE,MAAM,WAAW,cAAe,SAAQ,cAAc;IACpD,EAAE,EAAE,MAAM,CAAA;IACV,IAAI,EAAE,QAAQ,CAAA;IACd,IAAI,EAAE,MAAM,CAAA;IACZ,MAAM,EAAE,MAAM,CAAA;CACf;AAED,MAAM,WAAW,qBAAsB,SAAQ,cAAc;IAC3D,OAAO,EAAE,OAAO,CAAA;IAChB,WAAW,EAAE,MAAM,CAAA;IACnB,cAAc,EAAE,OAAO,CAAA;IACvB,sBAAsB,CAAC,EAAE,sBAAsB,CAAA;IAC/C,sBAAsB,EAAE,OAAO,CAAA;IAC/B,sBAAsB,EAAE,OAAO,CAAA;IAC/B,8BAA8B,CAAC,EAAE,OAAO,CAAA;IACxC,QAAQ,EAAE,OAAO,CAAA;CAClB"}
|
|
1
|
+
{"version":3,"file":"person.d.ts","sourceRoot":"","sources":["../../../src/types/resources/person.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAA;AAElD,eAAO,MAAM,sBAAsB;;;;CAIzB,CAAA;AAEV,MAAM,MAAM,sBAAsB,GAChC,CAAC,OAAO,sBAAsB,CAAC,CAAC,MAAM,OAAO,sBAAsB,CAAC,CAAA;AAEtE,MAAM,WAAW,cAAe,SAAQ,cAAc;IACpD,EAAE,EAAE,MAAM,CAAA;IACV,IAAI,EAAE,QAAQ,CAAA;IACd,IAAI,EAAE,MAAM,CAAA;IACZ,MAAM,EAAE,MAAM,CAAA;CACf;AAED,MAAM,WAAW,qBAAsB,SAAQ,cAAc;IAC3D,OAAO,EAAE,OAAO,CAAA;IAChB,WAAW,EAAE,MAAM,CAAA;IACnB,cAAc,EAAE,OAAO,CAAA;IACvB,sBAAsB,CAAC,EAAE,sBAAsB,CAAA;IAC/C,sBAAsB,EAAE,OAAO,CAAA;IAC/B,sBAAsB,EAAE,OAAO,CAAA;IAC/B,uBAAuB,CAAC,EAAE,OAAO,CAAA;IACjC,8BAA8B,CAAC,EAAE,OAAO,CAAA;IACxC,QAAQ,EAAE,OAAO,CAAA;CAClB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"person.js","names":["AgeQualificationStatus","QUALIFIED","DISQUALIFIED","UNKNOWN"],"sources":["../../../src/types/resources/person.ts"],"sourcesContent":["import { ResourceObject } from '../api_primitives'\n\nexport const AgeQualificationStatus = {\n QUALIFIED: 'qualified',\n DISQUALIFIED: 'disqualified',\n UNKNOWN: 'unknown',\n} as const\n\nexport type AgeQualificationStatus =\n (typeof AgeQualificationStatus)[keyof typeof AgeQualificationStatus]\n\nexport interface PersonResource extends ResourceObject {\n id: number\n type: 'Person'\n name: string\n avatar: string\n}\n\nexport interface CurrentPersonResource extends PersonResource {\n canChat: boolean\n unreadCount: number\n pcoChatEnabled: boolean\n ageQualificationStatus?: AgeQualificationStatus\n directMessagesDisabled: boolean\n directMessagesEligible: boolean\n canBrowseArchivedConversations?: boolean\n under_18: boolean\n}\n"],"mappings":"AAEA,OAAO,MAAMA,sBAAsB,GAAG;EACpCC,SAAS,EAAE,WAAW;EACtBC,YAAY,EAAE,cAAc;EAC5BC,OAAO,EAAE;AACX,CAAU","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"person.js","names":["AgeQualificationStatus","QUALIFIED","DISQUALIFIED","UNKNOWN"],"sources":["../../../src/types/resources/person.ts"],"sourcesContent":["import { ResourceObject } from '../api_primitives'\n\nexport const AgeQualificationStatus = {\n QUALIFIED: 'qualified',\n DISQUALIFIED: 'disqualified',\n UNKNOWN: 'unknown',\n} as const\n\nexport type AgeQualificationStatus =\n (typeof AgeQualificationStatus)[keyof typeof AgeQualificationStatus]\n\nexport interface PersonResource extends ResourceObject {\n id: number\n type: 'Person'\n name: string\n avatar: string\n}\n\nexport interface CurrentPersonResource extends PersonResource {\n canChat: boolean\n unreadCount: number\n pcoChatEnabled: boolean\n ageQualificationStatus?: AgeQualificationStatus\n directMessagesDisabled: boolean\n directMessagesEligible: boolean\n canManageDirectMessages?: boolean\n canBrowseArchivedConversations?: boolean\n under_18: boolean\n}\n"],"mappings":"AAEA,OAAO,MAAMA,sBAAsB,GAAG;EACpCC,SAAS,EAAE,WAAW;EACtBC,YAAY,EAAE,cAAc;EAC5BC,OAAO,EAAE;AACX,CAAU","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@planningcenter/chat-react-native",
|
|
3
|
-
"version": "4.6.
|
|
3
|
+
"version": "4.6.4-qa-staging.1",
|
|
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.6.
|
|
36
|
+
"@planningcenter/emoji-keyboard": "4.6.4-qa-staging.1",
|
|
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": "abae355555a9b464f435fbd9ae8dba699efbbb88"
|
|
88
88
|
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { QueryClientProvider } from '@tanstack/react-query'
|
|
2
|
+
import { renderHook } from '@testing-library/react-native'
|
|
3
|
+
import React from 'react'
|
|
4
|
+
import { buildTestQueryClient } from '../../__utils__/query_client'
|
|
5
|
+
import { useCurrentPerson } from '../../hooks/use_current_person'
|
|
6
|
+
import { usePersonSettings } from '../../hooks/use_person_settings'
|
|
7
|
+
import { CurrentPersonResource } from '../../types'
|
|
8
|
+
|
|
9
|
+
jest.mock('../../hooks/use_api_client', () => ({ useApiClient: () => ({}) }))
|
|
10
|
+
jest.mock('../../hooks/use_current_person', () => ({
|
|
11
|
+
useCurrentPerson: jest.fn(),
|
|
12
|
+
useCurrentPersonCache: () => ({ update: jest.fn(), invalidate: jest.fn() }),
|
|
13
|
+
}))
|
|
14
|
+
|
|
15
|
+
const mockedUseCurrentPerson = useCurrentPerson as jest.MockedFunction<typeof useCurrentPerson>
|
|
16
|
+
|
|
17
|
+
const renderUsePersonSettings = (person: Partial<CurrentPersonResource>) => {
|
|
18
|
+
mockedUseCurrentPerson.mockReturnValue(person as CurrentPersonResource)
|
|
19
|
+
const wrapper = ({ children }: { children: React.ReactNode }) => (
|
|
20
|
+
<QueryClientProvider client={buildTestQueryClient()}>{children}</QueryClientProvider>
|
|
21
|
+
)
|
|
22
|
+
|
|
23
|
+
return renderHook(() => usePersonSettings(), { wrapper })
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
describe('usePersonSettings', () => {
|
|
27
|
+
describe('canManageDirectMessages', () => {
|
|
28
|
+
it('is true for a minor who can manage direct messages', () => {
|
|
29
|
+
const { result } = renderUsePersonSettings({
|
|
30
|
+
canManageDirectMessages: true,
|
|
31
|
+
directMessagesEligible: false,
|
|
32
|
+
under_18: true,
|
|
33
|
+
})
|
|
34
|
+
|
|
35
|
+
expect(result.current.canManageDirectMessages).toBe(true)
|
|
36
|
+
})
|
|
37
|
+
|
|
38
|
+
it('is false when the person cannot manage direct messages', () => {
|
|
39
|
+
const { result } = renderUsePersonSettings({
|
|
40
|
+
canManageDirectMessages: false,
|
|
41
|
+
directMessagesEligible: false,
|
|
42
|
+
})
|
|
43
|
+
|
|
44
|
+
expect(result.current.canManageDirectMessages).toBe(false)
|
|
45
|
+
})
|
|
46
|
+
|
|
47
|
+
it('falls back to direct message eligibility when the attribute is absent', () => {
|
|
48
|
+
const { result } = renderUsePersonSettings({ directMessagesEligible: true })
|
|
49
|
+
|
|
50
|
+
expect(result.current.canManageDirectMessages).toBe(true)
|
|
51
|
+
})
|
|
52
|
+
})
|
|
53
|
+
})
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { DefaultTheme, ThemeProvider } from '@react-navigation/native'
|
|
2
|
+
import { render } from '@testing-library/react-native'
|
|
3
|
+
import React from 'react'
|
|
4
|
+
import { SafeAreaProvider } from 'react-native-safe-area-context'
|
|
5
|
+
import { SettingsScreen, SettingsScreenProps } from '../../screens/settings_screen'
|
|
6
|
+
|
|
7
|
+
let mockCanManageDirectMessages = true
|
|
8
|
+
|
|
9
|
+
jest.mock('@react-navigation/native', () => ({
|
|
10
|
+
...jest.requireActual('@react-navigation/native'),
|
|
11
|
+
useNavigation: () => ({ navigate: jest.fn() }),
|
|
12
|
+
}))
|
|
13
|
+
jest.mock('../../hooks/use_app_name', () => ({ useAppName: () => 'church_center' }))
|
|
14
|
+
jest.mock('../../hooks/use_person_settings', () => ({
|
|
15
|
+
usePersonSettings: () => ({
|
|
16
|
+
canManageDirectMessages: mockCanManageDirectMessages,
|
|
17
|
+
directMessagesDisabled: false,
|
|
18
|
+
setDirectMessagesDisabled: jest.fn(),
|
|
19
|
+
isMutating: false,
|
|
20
|
+
}),
|
|
21
|
+
}))
|
|
22
|
+
jest.mock('../../components/display/version_footer', () => ({ VersionFooter: () => null }))
|
|
23
|
+
|
|
24
|
+
const safeAreaMetrics = {
|
|
25
|
+
frame: { x: 0, y: 0, width: 390, height: 844 },
|
|
26
|
+
insets: { top: 0, right: 0, bottom: 0, left: 0 },
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const route = { key: 'Settings', name: 'Settings', params: {} } as SettingsScreenProps['route']
|
|
30
|
+
|
|
31
|
+
const renderScreen = () =>
|
|
32
|
+
render(
|
|
33
|
+
<SafeAreaProvider initialMetrics={safeAreaMetrics}>
|
|
34
|
+
<ThemeProvider value={DefaultTheme}>
|
|
35
|
+
<SettingsScreen route={route} />
|
|
36
|
+
</ThemeProvider>
|
|
37
|
+
</SafeAreaProvider>
|
|
38
|
+
)
|
|
39
|
+
|
|
40
|
+
describe('SettingsScreen', () => {
|
|
41
|
+
beforeEach(() => {
|
|
42
|
+
mockCanManageDirectMessages = true
|
|
43
|
+
})
|
|
44
|
+
|
|
45
|
+
it('shows the direct messages toggle when the person can manage direct messages', () => {
|
|
46
|
+
const { getByText } = renderScreen()
|
|
47
|
+
|
|
48
|
+
expect(getByText('Allow direct messages')).toBeTruthy()
|
|
49
|
+
})
|
|
50
|
+
|
|
51
|
+
it('hides the direct messages toggle when the person cannot manage direct messages', () => {
|
|
52
|
+
mockCanManageDirectMessages = false
|
|
53
|
+
const { queryByText, getByText } = renderScreen()
|
|
54
|
+
|
|
55
|
+
expect(queryByText('Allow direct messages')).toBeNull()
|
|
56
|
+
expect(getByText('Notification settings')).toBeTruthy()
|
|
57
|
+
})
|
|
58
|
+
})
|
|
@@ -0,0 +1,39 @@
|
|
|
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
|
+
})
|
|
@@ -14,7 +14,7 @@ import { featuresQueryOptions } from '../hooks/use_features'
|
|
|
14
14
|
import { useJoltForegroundPing } from '../hooks/use_jolt'
|
|
15
15
|
import { RequestQueryKey } from '../hooks/use_suspense_api'
|
|
16
16
|
import { emitAuthRefresh } from '../utils/auth_events'
|
|
17
|
-
import { ResponseError } from '../utils/response_error'
|
|
17
|
+
import { isResponseLike, ResponseError } from '../utils/response_error'
|
|
18
18
|
import { ChatContext, ChatContextValue } from './chat_context'
|
|
19
19
|
|
|
20
20
|
let apiClient: ApiClient | undefined
|
|
@@ -29,14 +29,21 @@ const defaultQueryFn = ({ queryKey }: { queryKey: QueryKey }) => {
|
|
|
29
29
|
return apiClient[app].get({ url, data, headers })
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
-
const configuredRetry = (failureCount: number, error:
|
|
33
|
-
if (
|
|
32
|
+
export const configuredRetry = (failureCount: number, error: unknown) => {
|
|
33
|
+
if (isClientError(error)) return false
|
|
34
34
|
|
|
35
35
|
return failureCount < 3
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
-
const
|
|
39
|
-
|
|
38
|
+
const isClientError = (error: unknown): boolean => {
|
|
39
|
+
const status = errorStatus(error)
|
|
40
|
+
return status !== undefined && status >= 400 && status < 500
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const errorStatus = (error: unknown): number | undefined => {
|
|
44
|
+
if (error instanceof ResponseError) return error.status
|
|
45
|
+
if (isResponseLike(error)) return error.status
|
|
46
|
+
return undefined
|
|
40
47
|
}
|
|
41
48
|
|
|
42
49
|
export const chatQueryClient = new QueryClient({
|
|
@@ -0,0 +1,79 @@
|
|
|
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
|
+
})
|
package/src/hooks/index.ts
CHANGED
|
@@ -9,6 +9,8 @@ export function usePersonSettings() {
|
|
|
9
9
|
const { update, invalidate } = useCurrentPersonCache()
|
|
10
10
|
|
|
11
11
|
const directMessagesDisabled = person?.directMessagesDisabled ?? false
|
|
12
|
+
const canManageDirectMessages =
|
|
13
|
+
person?.canManageDirectMessages ?? person?.directMessagesEligible ?? false
|
|
12
14
|
|
|
13
15
|
const { mutate: setDirectMessagesDisabled, isPending: isMutating } = useMutation({
|
|
14
16
|
mutationFn: (disabled: boolean) => {
|
|
@@ -25,5 +27,5 @@ export function usePersonSettings() {
|
|
|
25
27
|
},
|
|
26
28
|
})
|
|
27
29
|
|
|
28
|
-
return { directMessagesDisabled, setDirectMessagesDisabled, isMutating }
|
|
30
|
+
return { canManageDirectMessages, directMessagesDisabled, setDirectMessagesDisabled, isMutating }
|
|
29
31
|
}
|
|
@@ -0,0 +1,55 @@
|
|
|
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
|
+
}
|
|
@@ -5,7 +5,7 @@ import { Platform, ScrollView, StyleSheet, View } from 'react-native'
|
|
|
5
5
|
import { useSafeAreaInsets } from 'react-native-safe-area-context'
|
|
6
6
|
import { Heading, Icon, Text, VersionFooter } from '../components'
|
|
7
7
|
import { Switch } from '../components/display/switch'
|
|
8
|
-
import {
|
|
8
|
+
import { useTheme } from '../hooks'
|
|
9
9
|
import { useAppName } from '../hooks/use_app_name'
|
|
10
10
|
import { usePersonSettings } from '../hooks/use_person_settings'
|
|
11
11
|
|
|
@@ -13,8 +13,8 @@ export type SettingsScreenProps = StaticScreenProps<{}>
|
|
|
13
13
|
|
|
14
14
|
export function SettingsScreen({}: SettingsScreenProps) {
|
|
15
15
|
const styles = useStyles()
|
|
16
|
-
const { directMessagesDisabled, setDirectMessagesDisabled, isMutating } =
|
|
17
|
-
|
|
16
|
+
const { canManageDirectMessages, directMessagesDisabled, setDirectMessagesDisabled, isMutating } =
|
|
17
|
+
usePersonSettings()
|
|
18
18
|
const appName = useAppName()
|
|
19
19
|
const navigation = useNavigation()
|
|
20
20
|
|
|
@@ -33,7 +33,7 @@ export function SettingsScreen({}: SettingsScreenProps) {
|
|
|
33
33
|
<View style={styles.sectionHeader}>
|
|
34
34
|
<Heading variant="h2">Messages</Heading>
|
|
35
35
|
</View>
|
|
36
|
-
{
|
|
36
|
+
{canManageDirectMessages && (
|
|
37
37
|
<View style={styles.settingRow}>
|
|
38
38
|
<View style={styles.settingRowText}>
|
|
39
39
|
<Text>Allow direct messages</Text>
|