@planningcenter/chat-react-native 4.3.0-rc.12 → 4.3.0-rc.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/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.map +1 -1
- package/build/hooks/use_search_results.js +67 -59
- package/build/hooks/use_search_results.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/search/components/results_section.d.ts +1 -1
- package/build/screens/search/components/results_section.d.ts.map +1 -1
- package/build/screens/search/components/results_section.js.map +1 -1
- 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/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/package.json +2 -2
- package/src/hooks/__tests__/use_debounced_search_term.test.tsx +38 -0
- package/src/hooks/__tests__/use_search_results.test.tsx +14 -2
- package/src/hooks/use_debounced_search_term.ts +20 -0
- package/src/hooks/use_search_results.ts +4 -3
- package/src/screens/conversation_select_recipients/conversation_select_direct_message_recipients_screen.tsx +3 -8
- package/src/screens/search/__tests__/search_screen.test.tsx +64 -0
- package/src/screens/search/components/__tests__/search_results_list.test.tsx +135 -0
- package/src/screens/search/components/results_section.tsx +1 -1
- package/src/screens/search/components/search_results_list.tsx +147 -0
- package/src/screens/search/search_screen.tsx +9 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { c as _c } from "react/compiler-runtime";
|
|
2
2
|
import { PlatformPressable } from '@react-navigation/elements';
|
|
3
3
|
import { StackActions, useNavigation } from '@react-navigation/native';
|
|
4
|
-
import {
|
|
4
|
+
import { useRef, useState } from 'react';
|
|
5
5
|
import { FlatList, Pressable, StyleSheet, View } from 'react-native';
|
|
6
6
|
import { Avatar, Badge, Banner, Icon, KeyboardView, Spinner, Text } from '../../components';
|
|
7
7
|
import { ActionButton } from '../../components/display/action_button';
|
|
@@ -12,12 +12,13 @@ import { useDirectMessageAffiliations } from '../../hooks/direct_messages/use_di
|
|
|
12
12
|
import { useDirectMessageCandidates } from '../../hooks/direct_messages/use_direct_message_candidates';
|
|
13
13
|
import { useDirectMessageConversationValidate } from '../../hooks/direct_messages/use_direct_message_conversation_validate';
|
|
14
14
|
import { useFindOrCreateDirectMessageConversation } from '../../hooks/direct_messages/use_find_or_create_direct_message_conversation';
|
|
15
|
+
import { useDebouncedSearchTerm } from '../../hooks/use_debounced_search_term';
|
|
15
16
|
import { availableFeatures, useFeatures } from '../../hooks/use_features';
|
|
16
17
|
import { ResultsHeading } from './components/results_heading';
|
|
17
18
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
18
19
|
const MAX_RECIPIENTS = 9;
|
|
19
20
|
export function ConversationSelectDirectMessageRecipientsScreen(t0) {
|
|
20
|
-
const $ = _c(
|
|
21
|
+
const $ = _c(55);
|
|
21
22
|
const {
|
|
22
23
|
route
|
|
23
24
|
} = t0;
|
|
@@ -47,7 +48,7 @@ export function ConversationSelectDirectMessageRecipientsScreen(t0) {
|
|
|
47
48
|
featureEnabled
|
|
48
49
|
} = useFeatures();
|
|
49
50
|
const [searchTerm, setSearchTerm] = useState("");
|
|
50
|
-
const
|
|
51
|
+
const debouncedTerm = useDebouncedSearchTerm(searchTerm);
|
|
51
52
|
let t4;
|
|
52
53
|
if ($[4] !== preselected_people) {
|
|
53
54
|
t4 = () => new Map(preselected_people.map(_temp));
|
|
@@ -59,261 +60,244 @@ export function ConversationSelectDirectMessageRecipientsScreen(t0) {
|
|
|
59
60
|
const [selectedPeople, setSelectedPeople] = useState(t4);
|
|
60
61
|
const searchInputRef = useRef(null);
|
|
61
62
|
let t5;
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
t5 = () => {
|
|
65
|
-
const timer = setTimeout(() => setDebouncedTerm(searchTerm), 200);
|
|
66
|
-
return () => clearTimeout(timer);
|
|
67
|
-
};
|
|
68
|
-
t6 = [searchTerm];
|
|
69
|
-
$[6] = searchTerm;
|
|
70
|
-
$[7] = t5;
|
|
71
|
-
$[8] = t6;
|
|
72
|
-
} else {
|
|
73
|
-
t5 = $[7];
|
|
74
|
-
t6 = $[8];
|
|
75
|
-
}
|
|
76
|
-
useEffect(t5, t6);
|
|
77
|
-
let t7;
|
|
78
|
-
if ($[9] !== featureEnabled || $[10] !== selectedPeople.size) {
|
|
79
|
-
t7 = person_0 => {
|
|
63
|
+
if ($[6] !== featureEnabled || $[7] !== selectedPeople.size) {
|
|
64
|
+
t5 = person_0 => {
|
|
80
65
|
if (selectedPeople.size >= MAX_RECIPIENTS) {
|
|
81
66
|
return;
|
|
82
67
|
}
|
|
83
68
|
setSelectedPeople(prev => new Map(prev).set(person_0.id, person_0));
|
|
84
69
|
setSearchTerm("");
|
|
85
|
-
setDebouncedTerm("");
|
|
86
70
|
if (featureEnabled(availableFeatures.dm_search_clear_fix)) {
|
|
87
71
|
searchInputRef.current?.clear();
|
|
88
72
|
}
|
|
89
73
|
};
|
|
90
|
-
$[
|
|
91
|
-
$[
|
|
92
|
-
$[
|
|
74
|
+
$[6] = featureEnabled;
|
|
75
|
+
$[7] = selectedPeople.size;
|
|
76
|
+
$[8] = t5;
|
|
93
77
|
} else {
|
|
94
|
-
|
|
78
|
+
t5 = $[8];
|
|
95
79
|
}
|
|
96
|
-
const selectPerson =
|
|
97
|
-
let
|
|
98
|
-
if ($[
|
|
99
|
-
|
|
80
|
+
const selectPerson = t5;
|
|
81
|
+
let t6;
|
|
82
|
+
if ($[9] === Symbol.for("react.memo_cache_sentinel")) {
|
|
83
|
+
t6 = id => {
|
|
100
84
|
setSelectedPeople(prev_0 => {
|
|
101
85
|
const next = new Map(prev_0);
|
|
102
86
|
next.delete(id);
|
|
103
87
|
return next;
|
|
104
88
|
});
|
|
105
89
|
};
|
|
106
|
-
$[
|
|
90
|
+
$[9] = t6;
|
|
107
91
|
} else {
|
|
108
|
-
|
|
92
|
+
t6 = $[9];
|
|
109
93
|
}
|
|
110
|
-
const removePerson =
|
|
111
|
-
let
|
|
112
|
-
if ($[
|
|
113
|
-
|
|
114
|
-
$[
|
|
115
|
-
$[
|
|
94
|
+
const removePerson = t6;
|
|
95
|
+
let t7;
|
|
96
|
+
if ($[10] !== selectedPeople) {
|
|
97
|
+
t7 = [...selectedPeople.keys()];
|
|
98
|
+
$[10] = selectedPeople;
|
|
99
|
+
$[11] = t7;
|
|
116
100
|
} else {
|
|
117
|
-
|
|
101
|
+
t7 = $[11];
|
|
118
102
|
}
|
|
119
|
-
const recipientIds =
|
|
120
|
-
let
|
|
121
|
-
if ($[
|
|
122
|
-
|
|
103
|
+
const recipientIds = t7;
|
|
104
|
+
let t8;
|
|
105
|
+
if ($[12] !== recipientIds) {
|
|
106
|
+
t8 = {
|
|
123
107
|
recipientIds
|
|
124
108
|
};
|
|
125
|
-
$[
|
|
126
|
-
$[
|
|
109
|
+
$[12] = recipientIds;
|
|
110
|
+
$[13] = t8;
|
|
127
111
|
} else {
|
|
128
|
-
|
|
112
|
+
t8 = $[13];
|
|
129
113
|
}
|
|
130
114
|
const {
|
|
131
115
|
warnings,
|
|
132
116
|
validationPending
|
|
133
|
-
} = useDirectMessageConversationValidate(
|
|
134
|
-
let
|
|
135
|
-
if ($[
|
|
136
|
-
|
|
117
|
+
} = useDirectMessageConversationValidate(t8);
|
|
118
|
+
let t9;
|
|
119
|
+
if ($[14] !== navigation) {
|
|
120
|
+
t9 = conversationId => {
|
|
137
121
|
navigation.getParent()?.dispatch(StackActions.replace("Conversation", {
|
|
138
122
|
conversation_id: conversationId
|
|
139
123
|
}));
|
|
140
124
|
};
|
|
141
|
-
$[
|
|
142
|
-
$[
|
|
125
|
+
$[14] = navigation;
|
|
126
|
+
$[15] = t9;
|
|
143
127
|
} else {
|
|
144
|
-
|
|
128
|
+
t9 = $[15];
|
|
145
129
|
}
|
|
146
|
-
const handleSuccess =
|
|
147
|
-
let
|
|
148
|
-
if ($[
|
|
149
|
-
|
|
130
|
+
const handleSuccess = t9;
|
|
131
|
+
let t10;
|
|
132
|
+
if ($[16] !== handleSuccess || $[17] !== recipientIds) {
|
|
133
|
+
t10 = {
|
|
150
134
|
recipientIds,
|
|
151
135
|
onSuccess: handleSuccess
|
|
152
136
|
};
|
|
153
|
-
$[
|
|
154
|
-
$[
|
|
155
|
-
$[
|
|
137
|
+
$[16] = handleSuccess;
|
|
138
|
+
$[17] = recipientIds;
|
|
139
|
+
$[18] = t10;
|
|
156
140
|
} else {
|
|
157
|
-
|
|
141
|
+
t10 = $[18];
|
|
158
142
|
}
|
|
159
143
|
const {
|
|
160
144
|
findOrCreateConversation,
|
|
161
145
|
directMessageExists,
|
|
162
146
|
isFinding,
|
|
163
147
|
isError
|
|
164
|
-
} = useFindOrCreateDirectMessageConversation(
|
|
165
|
-
let
|
|
148
|
+
} = useFindOrCreateDirectMessageConversation(t10);
|
|
149
|
+
let t11;
|
|
166
150
|
bb0: {
|
|
167
151
|
if (selectedPeople.size === 0) {
|
|
168
|
-
|
|
152
|
+
t11 = "Start conversation";
|
|
169
153
|
break bb0;
|
|
170
154
|
}
|
|
171
155
|
if (selectedPeople.size === 1) {
|
|
172
|
-
let
|
|
173
|
-
if ($[
|
|
174
|
-
|
|
175
|
-
$[
|
|
176
|
-
$[
|
|
156
|
+
let t12;
|
|
157
|
+
if ($[19] !== selectedPeople) {
|
|
158
|
+
t12 = selectedPeople.values().next().value.name.split(" ");
|
|
159
|
+
$[19] = selectedPeople;
|
|
160
|
+
$[20] = t12;
|
|
177
161
|
} else {
|
|
178
|
-
|
|
162
|
+
t12 = $[20];
|
|
179
163
|
}
|
|
180
|
-
const firstName =
|
|
181
|
-
|
|
164
|
+
const firstName = t12[0];
|
|
165
|
+
t11 = directMessageExists ? `Open message with ${firstName}` : `Message ${firstName}`;
|
|
182
166
|
break bb0;
|
|
183
167
|
}
|
|
184
|
-
|
|
168
|
+
t11 = directMessageExists ? `Open direct message (${selectedPeople.size})` : `Start direct message (${selectedPeople.size})`;
|
|
185
169
|
}
|
|
186
|
-
const buttonText =
|
|
187
|
-
let
|
|
188
|
-
if ($[
|
|
189
|
-
|
|
170
|
+
const buttonText = t11;
|
|
171
|
+
let t12;
|
|
172
|
+
if ($[21] !== isError || $[22] !== styles.errorBanner) {
|
|
173
|
+
t12 = isError && /*#__PURE__*/_jsx(Banner, {
|
|
190
174
|
appearance: "error",
|
|
191
175
|
description: "There was an issue starting the conversation. Please try again.",
|
|
192
176
|
style: styles.errorBanner
|
|
193
177
|
});
|
|
194
|
-
$[
|
|
195
|
-
$[
|
|
196
|
-
$[
|
|
178
|
+
$[21] = isError;
|
|
179
|
+
$[22] = styles.errorBanner;
|
|
180
|
+
$[23] = t12;
|
|
197
181
|
} else {
|
|
198
|
-
|
|
182
|
+
t12 = $[23];
|
|
199
183
|
}
|
|
200
|
-
let
|
|
201
|
-
if ($[
|
|
202
|
-
|
|
203
|
-
$[
|
|
184
|
+
let t13;
|
|
185
|
+
if ($[24] === Symbol.for("react.memo_cache_sentinel")) {
|
|
186
|
+
t13 = () => setSelectedPeople(new Map());
|
|
187
|
+
$[24] = t13;
|
|
204
188
|
} else {
|
|
205
|
-
|
|
189
|
+
t13 = $[24];
|
|
206
190
|
}
|
|
207
|
-
let
|
|
208
|
-
if ($[
|
|
209
|
-
|
|
191
|
+
let t14;
|
|
192
|
+
if ($[25] !== searchTerm || $[26] !== selectedPeople) {
|
|
193
|
+
t14 = /*#__PURE__*/_jsx(ToField, {
|
|
210
194
|
selectedPeople: selectedPeople,
|
|
211
195
|
searchTerm: searchTerm,
|
|
212
196
|
onSearchChange: setSearchTerm,
|
|
213
197
|
onRemove: removePerson,
|
|
214
|
-
onClear:
|
|
198
|
+
onClear: t13,
|
|
215
199
|
searchInputRef: searchInputRef
|
|
216
200
|
});
|
|
217
|
-
$[
|
|
218
|
-
$[
|
|
219
|
-
$[
|
|
201
|
+
$[25] = searchTerm;
|
|
202
|
+
$[26] = selectedPeople;
|
|
203
|
+
$[27] = t14;
|
|
220
204
|
} else {
|
|
221
|
-
|
|
205
|
+
t14 = $[27];
|
|
222
206
|
}
|
|
223
|
-
let
|
|
224
|
-
if ($[
|
|
225
|
-
|
|
207
|
+
let t15;
|
|
208
|
+
if ($[28] !== styles.errorBanner) {
|
|
209
|
+
t15 = /*#__PURE__*/_jsx(Banner, {
|
|
226
210
|
appearance: "error",
|
|
227
211
|
description: "Couldn't load people right now. Try again.",
|
|
228
212
|
style: styles.errorBanner
|
|
229
213
|
});
|
|
230
|
-
$[
|
|
231
|
-
$[
|
|
214
|
+
$[28] = styles.errorBanner;
|
|
215
|
+
$[29] = t15;
|
|
232
216
|
} else {
|
|
233
|
-
|
|
217
|
+
t15 = $[29];
|
|
234
218
|
}
|
|
235
|
-
let
|
|
236
|
-
if ($[
|
|
237
|
-
|
|
219
|
+
let t16;
|
|
220
|
+
if ($[30] !== debouncedTerm || $[31] !== selectPerson || $[32] !== selectedPeople) {
|
|
221
|
+
t16 = /*#__PURE__*/_jsx(CandidateResults, {
|
|
238
222
|
term: debouncedTerm,
|
|
239
223
|
selectedPeople: selectedPeople,
|
|
240
224
|
onSelect: selectPerson
|
|
241
225
|
});
|
|
242
|
-
$[
|
|
243
|
-
$[
|
|
244
|
-
$[
|
|
245
|
-
$[
|
|
226
|
+
$[30] = debouncedTerm;
|
|
227
|
+
$[31] = selectPerson;
|
|
228
|
+
$[32] = selectedPeople;
|
|
229
|
+
$[33] = t16;
|
|
246
230
|
} else {
|
|
247
|
-
|
|
231
|
+
t16 = $[33];
|
|
248
232
|
}
|
|
249
|
-
let
|
|
250
|
-
if ($[
|
|
251
|
-
|
|
252
|
-
fallback:
|
|
253
|
-
children:
|
|
233
|
+
let t17;
|
|
234
|
+
if ($[34] !== debouncedTerm || $[35] !== t15 || $[36] !== t16) {
|
|
235
|
+
t17 = /*#__PURE__*/_jsx(ComponentErrorBoundary, {
|
|
236
|
+
fallback: t15,
|
|
237
|
+
children: t16
|
|
254
238
|
}, debouncedTerm);
|
|
255
|
-
$[
|
|
256
|
-
$[
|
|
257
|
-
$[
|
|
258
|
-
$[
|
|
239
|
+
$[34] = debouncedTerm;
|
|
240
|
+
$[35] = t15;
|
|
241
|
+
$[36] = t16;
|
|
242
|
+
$[37] = t17;
|
|
259
243
|
} else {
|
|
260
|
-
|
|
244
|
+
t17 = $[37];
|
|
261
245
|
}
|
|
262
|
-
let
|
|
263
|
-
if ($[
|
|
264
|
-
|
|
246
|
+
let t18;
|
|
247
|
+
if ($[38] !== styles.candidateResultsContainer || $[39] !== t17) {
|
|
248
|
+
t18 = /*#__PURE__*/_jsx(View, {
|
|
265
249
|
style: styles.candidateResultsContainer,
|
|
266
|
-
children:
|
|
250
|
+
children: t17
|
|
267
251
|
});
|
|
268
|
-
$[
|
|
269
|
-
$[
|
|
270
|
-
$[
|
|
252
|
+
$[38] = styles.candidateResultsContainer;
|
|
253
|
+
$[39] = t17;
|
|
254
|
+
$[40] = t18;
|
|
271
255
|
} else {
|
|
272
|
-
|
|
256
|
+
t18 = $[40];
|
|
273
257
|
}
|
|
274
|
-
const
|
|
275
|
-
const
|
|
276
|
-
let
|
|
277
|
-
if ($[
|
|
278
|
-
|
|
279
|
-
$[
|
|
280
|
-
$[
|
|
281
|
-
$[
|
|
258
|
+
const t19 = selectedPeople.size === 0 || validationPending || warnings.length > 0 || isFinding;
|
|
259
|
+
const t20 = validationPending || isFinding;
|
|
260
|
+
let t21;
|
|
261
|
+
if ($[41] !== findOrCreateConversation || $[42] !== recipientIds) {
|
|
262
|
+
t21 = () => findOrCreateConversation(recipientIds);
|
|
263
|
+
$[41] = findOrCreateConversation;
|
|
264
|
+
$[42] = recipientIds;
|
|
265
|
+
$[43] = t21;
|
|
282
266
|
} else {
|
|
283
|
-
|
|
267
|
+
t21 = $[43];
|
|
284
268
|
}
|
|
285
|
-
let
|
|
286
|
-
if ($[
|
|
287
|
-
|
|
269
|
+
let t22;
|
|
270
|
+
if ($[44] !== buttonText || $[45] !== t19 || $[46] !== t20 || $[47] !== t21 || $[48] !== warnings) {
|
|
271
|
+
t22 = /*#__PURE__*/_jsx(ActionButton, {
|
|
288
272
|
title: buttonText,
|
|
289
|
-
disabled:
|
|
290
|
-
loading:
|
|
291
|
-
onPress:
|
|
273
|
+
disabled: t19,
|
|
274
|
+
loading: t20,
|
|
275
|
+
onPress: t21,
|
|
292
276
|
warnings: warnings
|
|
293
277
|
});
|
|
294
|
-
$[
|
|
295
|
-
$[
|
|
278
|
+
$[44] = buttonText;
|
|
279
|
+
$[45] = t19;
|
|
280
|
+
$[46] = t20;
|
|
281
|
+
$[47] = t21;
|
|
282
|
+
$[48] = warnings;
|
|
296
283
|
$[49] = t22;
|
|
297
|
-
$[50] = t23;
|
|
298
|
-
$[51] = warnings;
|
|
299
|
-
$[52] = t24;
|
|
300
284
|
} else {
|
|
301
|
-
|
|
285
|
+
t22 = $[49];
|
|
302
286
|
}
|
|
303
|
-
let
|
|
304
|
-
if ($[
|
|
305
|
-
|
|
306
|
-
children: [
|
|
287
|
+
let t23;
|
|
288
|
+
if ($[50] !== t12 || $[51] !== t14 || $[52] !== t18 || $[53] !== t22) {
|
|
289
|
+
t23 = /*#__PURE__*/_jsxs(KeyboardView, {
|
|
290
|
+
children: [t12, t14, t18, t22]
|
|
307
291
|
});
|
|
308
|
-
$[
|
|
309
|
-
$[
|
|
310
|
-
$[
|
|
311
|
-
$[
|
|
312
|
-
$[
|
|
292
|
+
$[50] = t12;
|
|
293
|
+
$[51] = t14;
|
|
294
|
+
$[52] = t18;
|
|
295
|
+
$[53] = t22;
|
|
296
|
+
$[54] = t23;
|
|
313
297
|
} else {
|
|
314
|
-
|
|
298
|
+
t23 = $[54];
|
|
315
299
|
}
|
|
316
|
-
return
|
|
300
|
+
return t23;
|
|
317
301
|
}
|
|
318
302
|
function _temp(person) {
|
|
319
303
|
return [person.id, {
|