@ethora/chat-component 26.9.5 → 26.9.6
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/README.md +2 -0
- package/dist/{ChatProfileModal-Pr4--RdW.js → ChatProfileModal-DKuxJsdM.js} +526 -519
- package/dist/{FilePreviewModal-CYHlKzRc.js → FilePreviewModal-BcaSoO3-.js} +89 -89
- package/dist/{ManageDataModal-BE1eGlYh.js → ManageDataModal-Dw4dCQll.js} +2 -2
- package/dist/{MarkdownBody-G0_J0NL6.js → MarkdownBody-xtKDMR0h.js} +1 -1
- package/dist/MessageSearchModal-BVKU6H3v.js +389 -0
- package/dist/PublicChatsModal-CscOnVaQ.js +202 -0
- package/dist/{SideDrawer-BG2m7Bcm.js → SideDrawer-WneDrrWG.js} +27 -27
- package/dist/{UserProfileModal-B2Hp5bAF.js → UserProfileModal-CMHFq1I9.js} +3 -3
- package/dist/{UserSettingsModal-D871FDAT.js → UserSettingsModal-BoZXZ0oR.js} +2 -2
- package/dist/{VideoCallOverlay-Br0ji0nZ.js → VideoCallOverlay-CQNi7wp5.js} +1 -1
- package/dist/{VisibilityModal-DdFBV1_g.js → VisibilityModal-BPsNiMzJ.js} +2 -2
- package/dist/assets/icons.d.ts +9 -0
- package/dist/components/InputComponents/Search.d.ts +4 -0
- package/dist/components/MainComponents/ArchivedMessageCard.d.ts +11 -0
- package/dist/components/MainComponents/computeAnchoredScrollTop.d.ts +9 -0
- package/dist/components/MainComponents/useJumpToMessage.d.ts +63 -0
- package/dist/components/MainComponents/useStickToBottom.d.ts +27 -0
- package/dist/components/Modals/MessageSearchModal/MessageHitResults.d.ts +22 -0
- package/dist/components/Modals/MessageSearchModal/MessageSearchModal.d.ts +6 -0
- package/dist/components/Modals/MessageSearchModal/resolveSender.d.ts +33 -0
- package/dist/components/Modals/MessageSearchModal/searchFilters.d.ts +34 -0
- package/dist/components/Modals/MessageSearchModal/snippet.d.ts +14 -0
- package/dist/components/Modals/MessageSearchModal/useMessageSearch.d.ts +22 -0
- package/dist/components/Modals/PublicChatsModal/PublicChatsModal.d.ts +13 -0
- package/dist/components/styled/RoomListComponents/index.d.ts +3 -0
- package/dist/context/ToastContext.d.ts +7 -0
- package/dist/firebase-messaging-sw.js +21 -3
- package/dist/{handleCopyClick-DPjxMoJn.js → handleCopyClick-B70vLjJD.js} +1 -1
- package/dist/helpers/constants/MODAL_TYPES.d.ts +2 -0
- package/dist/helpers/nanoToMs.d.ts +1 -1
- package/dist/helpers/openRoomAtMessage.d.ts +17 -0
- package/dist/hooks/useMessageSearchShortcut.d.ts +14 -0
- package/dist/hooks/useRoomState.d.ts +1 -0
- package/dist/{main-BRIZ98KV.js → main-rJpE4hh-.js} +12318 -11108
- package/dist/main.css +1 -1
- package/dist/main.js +6 -6
- package/dist/networking/api-requests/messageSearch.api.d.ts +56 -0
- package/dist/networking/api-requests/publicChats.api.d.ts +23 -0
- package/dist/networking/api-requests/xmppToken.api.d.ts +1 -0
- package/dist/networking/xmppClient.d.ts +2 -0
- package/dist/roomStore/chatSettingsSlice.d.ts +1 -1
- package/dist/roomStore/roomsSlice.d.ts +38 -1
- package/dist/styles/classNames.d.ts +2 -0
- package/dist/types/models/config.model.d.ts +11 -0
- package/dist/utils/notificationUtils.d.ts +12 -0
- package/dist/version.d.ts +1 -1
- package/package.json +1 -1
- package/public/firebase-messaging-sw.js +21 -3
|
@@ -0,0 +1,389 @@
|
|
|
1
|
+
import { jsx as a, jsxs as n, Fragment as q } from "react/jsx-runtime";
|
|
2
|
+
import { useRef as J, useState as h, useMemo as I, useEffect as _ } from "react";
|
|
3
|
+
import { p as G, a as P, aI as K, u as z, aJ as V, aK as Y, ar as W, aL as X, aM as Z, x as i, q as ee } from "./main-rJpE4hh-.js";
|
|
4
|
+
import { S as re, i as te, j as ae, f as y } from "./SideDrawer-WneDrrWG.js";
|
|
5
|
+
function oe(t) {
|
|
6
|
+
const e = /^(\d{4})-(\d{2})-(\d{2})$/.exec(t || "");
|
|
7
|
+
if (!e) return;
|
|
8
|
+
const c = new Date(
|
|
9
|
+
Number(e[1]),
|
|
10
|
+
Number(e[2]) - 1,
|
|
11
|
+
Number(e[3]),
|
|
12
|
+
0,
|
|
13
|
+
0,
|
|
14
|
+
0,
|
|
15
|
+
0
|
|
16
|
+
);
|
|
17
|
+
return Number.isNaN(c.getTime()) ? void 0 : c.toISOString();
|
|
18
|
+
}
|
|
19
|
+
function se(t) {
|
|
20
|
+
const e = /^(\d{4})-(\d{2})-(\d{2})$/.exec(t || "");
|
|
21
|
+
if (!e) return;
|
|
22
|
+
const c = new Date(
|
|
23
|
+
Number(e[1]),
|
|
24
|
+
Number(e[2]) - 1,
|
|
25
|
+
Number(e[3]),
|
|
26
|
+
23,
|
|
27
|
+
59,
|
|
28
|
+
59,
|
|
29
|
+
999
|
|
30
|
+
);
|
|
31
|
+
return Number.isNaN(c.getTime()) ? void 0 : c.toISOString();
|
|
32
|
+
}
|
|
33
|
+
const ne = (t, e) => !!(t && e && t > e), ie = (t) => `${t.firstName || ""} ${t.lastName || ""}`.trim() || t.name || "";
|
|
34
|
+
function ce(t, e, c = 8) {
|
|
35
|
+
const S = e.trim().toLowerCase();
|
|
36
|
+
if (!S) return [];
|
|
37
|
+
const p = [], g = [], l = /* @__PURE__ */ new Set();
|
|
38
|
+
for (const x of t) {
|
|
39
|
+
const d = x._id, b = ie(x);
|
|
40
|
+
if (!d || !b || l.has(d)) continue;
|
|
41
|
+
const s = b.toLowerCase().indexOf(S);
|
|
42
|
+
if (s !== -1 && (l.add(d), (s === 0 ? p : g).push({ id: d, name: b }), p.length >= c))
|
|
43
|
+
break;
|
|
44
|
+
}
|
|
45
|
+
return [...p, ...g].slice(0, c);
|
|
46
|
+
}
|
|
47
|
+
const le = i.div`
|
|
48
|
+
display: flex;
|
|
49
|
+
flex-direction: column;
|
|
50
|
+
gap: var(--ethora-space-3, 12px);
|
|
51
|
+
min-height: 0;
|
|
52
|
+
`, de = i.div`
|
|
53
|
+
display: flex;
|
|
54
|
+
gap: var(--ethora-space-2, 8px);
|
|
55
|
+
`, H = i.button`
|
|
56
|
+
flex: 1 1 0;
|
|
57
|
+
height: 32px;
|
|
58
|
+
border: 1px solid
|
|
59
|
+
${({ $active: t }) => t ? "var(--ethora-color-primary, #0052cd)" : "var(--ethora-color-border, #e6e8ec)"};
|
|
60
|
+
border-radius: var(--ethora-radius-full, 999px);
|
|
61
|
+
background: ${({ $active: t }) => t ? "var(--ethora-color-primary-soft, #e7edf9)" : "transparent"};
|
|
62
|
+
color: ${({ $active: t }) => t ? "var(--ethora-color-primary-text, #0052cd)" : "var(--ethora-color-text-secondary, #5a5f66)"};
|
|
63
|
+
font: inherit;
|
|
64
|
+
font-size: var(--ethora-font-size-sm, 14px);
|
|
65
|
+
font-weight: var(--ethora-font-weight-medium, 500);
|
|
66
|
+
cursor: pointer;
|
|
67
|
+
transition: background-color var(--ethora-motion-fast, 150ms);
|
|
68
|
+
`, he = i.button`
|
|
69
|
+
align-self: flex-start;
|
|
70
|
+
display: inline-flex;
|
|
71
|
+
align-items: center;
|
|
72
|
+
gap: 6px;
|
|
73
|
+
padding: 4px 4px;
|
|
74
|
+
border: none;
|
|
75
|
+
background: transparent;
|
|
76
|
+
color: ${({ $active: t }) => t ? "var(--ethora-color-primary-text, #0052cd)" : "var(--ethora-color-text-secondary, #5a5f66)"};
|
|
77
|
+
font: inherit;
|
|
78
|
+
font-size: var(--ethora-font-size-sm, 14px);
|
|
79
|
+
cursor: pointer;
|
|
80
|
+
|
|
81
|
+
> span {
|
|
82
|
+
min-width: 18px;
|
|
83
|
+
padding: 0 5px;
|
|
84
|
+
border-radius: var(--ethora-radius-full, 999px);
|
|
85
|
+
background: var(--ethora-color-primary, #0052cd);
|
|
86
|
+
color: var(--ethora-color-text-on-primary, #fff);
|
|
87
|
+
font-size: var(--ethora-font-size-xs, 12px);
|
|
88
|
+
text-align: center;
|
|
89
|
+
}
|
|
90
|
+
`, pe = i.div`
|
|
91
|
+
display: flex;
|
|
92
|
+
flex-direction: column;
|
|
93
|
+
gap: var(--ethora-space-2, 8px);
|
|
94
|
+
padding: var(--ethora-space-3, 12px);
|
|
95
|
+
border: 1px solid var(--ethora-color-border, #e6e8ec);
|
|
96
|
+
border-radius: var(--ethora-radius-md, 12px);
|
|
97
|
+
`, $ = i.label`
|
|
98
|
+
display: flex;
|
|
99
|
+
flex-direction: column;
|
|
100
|
+
gap: 4px;
|
|
101
|
+
font-size: var(--ethora-font-size-xs, 12px);
|
|
102
|
+
color: var(--ethora-color-text-muted, #6c6c6c);
|
|
103
|
+
|
|
104
|
+
input {
|
|
105
|
+
height: 36px;
|
|
106
|
+
box-sizing: border-box;
|
|
107
|
+
padding: 0 10px;
|
|
108
|
+
border: 1px solid var(--ethora-color-border, #e6e8ec);
|
|
109
|
+
border-radius: var(--ethora-radius-sm, 8px);
|
|
110
|
+
background: var(--ethora-color-bg-subtle, #f5f7fa);
|
|
111
|
+
color: var(--ethora-color-text, #141414);
|
|
112
|
+
font: inherit;
|
|
113
|
+
font-size: var(--ethora-font-size-sm, 14px);
|
|
114
|
+
}
|
|
115
|
+
`, ue = i.div`
|
|
116
|
+
display: grid;
|
|
117
|
+
grid-template-columns: 1fr 1fr;
|
|
118
|
+
gap: var(--ethora-space-2, 8px);
|
|
119
|
+
`, fe = i.ul`
|
|
120
|
+
list-style: none;
|
|
121
|
+
margin: 0;
|
|
122
|
+
padding: 4px;
|
|
123
|
+
border: 1px solid var(--ethora-color-border, #e6e8ec);
|
|
124
|
+
border-radius: var(--ethora-radius-sm, 8px);
|
|
125
|
+
background: var(--ethora-color-bg, #fff);
|
|
126
|
+
|
|
127
|
+
button {
|
|
128
|
+
width: 100%;
|
|
129
|
+
padding: 6px 8px;
|
|
130
|
+
border: none;
|
|
131
|
+
border-radius: 6px;
|
|
132
|
+
background: transparent;
|
|
133
|
+
color: var(--ethora-color-text, #141414);
|
|
134
|
+
font: inherit;
|
|
135
|
+
font-size: var(--ethora-font-size-sm, 14px);
|
|
136
|
+
text-align: start;
|
|
137
|
+
cursor: pointer;
|
|
138
|
+
}
|
|
139
|
+
button:hover,
|
|
140
|
+
button:focus-visible {
|
|
141
|
+
background: var(--ethora-color-bg-hover, #f0f2f5);
|
|
142
|
+
}
|
|
143
|
+
`, me = i.span`
|
|
144
|
+
display: inline-flex;
|
|
145
|
+
align-items: center;
|
|
146
|
+
gap: 6px;
|
|
147
|
+
align-self: flex-start;
|
|
148
|
+
padding: 3px 4px 3px 10px;
|
|
149
|
+
border-radius: var(--ethora-radius-full, 999px);
|
|
150
|
+
background: var(--ethora-color-primary-soft, #e7edf9);
|
|
151
|
+
color: var(--ethora-color-primary-text, #0052cd);
|
|
152
|
+
font-size: var(--ethora-font-size-sm, 14px);
|
|
153
|
+
|
|
154
|
+
button {
|
|
155
|
+
border: none;
|
|
156
|
+
background: transparent;
|
|
157
|
+
color: inherit;
|
|
158
|
+
font: inherit;
|
|
159
|
+
cursor: pointer;
|
|
160
|
+
padding: 0 6px;
|
|
161
|
+
}
|
|
162
|
+
`, ge = i.button`
|
|
163
|
+
align-self: flex-start;
|
|
164
|
+
border: none;
|
|
165
|
+
background: transparent;
|
|
166
|
+
color: var(--ethora-color-text-secondary, #5a5f66);
|
|
167
|
+
font: inherit;
|
|
168
|
+
font-size: var(--ethora-font-size-xs, 12px);
|
|
169
|
+
text-decoration: underline;
|
|
170
|
+
cursor: pointer;
|
|
171
|
+
padding: 0;
|
|
172
|
+
`, xe = i.div`
|
|
173
|
+
font-size: var(--ethora-font-size-xs, 12px);
|
|
174
|
+
color: var(--ethora-color-text-muted, #6c6c6c);
|
|
175
|
+
`, be = i.button`
|
|
176
|
+
align-self: center;
|
|
177
|
+
margin-top: var(--ethora-space-2, 8px);
|
|
178
|
+
padding: 6px 14px;
|
|
179
|
+
border: 1px solid var(--ethora-color-border, #e6e8ec);
|
|
180
|
+
border-radius: var(--ethora-radius-full, 999px);
|
|
181
|
+
background: transparent;
|
|
182
|
+
color: var(--ethora-color-text-secondary, #5a5f66);
|
|
183
|
+
font: inherit;
|
|
184
|
+
font-size: var(--ethora-font-size-sm, 14px);
|
|
185
|
+
cursor: pointer;
|
|
186
|
+
|
|
187
|
+
&:disabled {
|
|
188
|
+
opacity: 0.6;
|
|
189
|
+
cursor: default;
|
|
190
|
+
}
|
|
191
|
+
`, Ce = ({
|
|
192
|
+
handleCloseModal: t
|
|
193
|
+
}) => {
|
|
194
|
+
const e = G(), c = P(), S = K(767), p = J(null), g = z((r) => r.rooms.rooms), l = z(
|
|
195
|
+
(r) => r.rooms.activeRoomJID
|
|
196
|
+
), x = z((r) => r.rooms.usersSet);
|
|
197
|
+
z(
|
|
198
|
+
(r) => r.chatSettingStore.user?.xmppUsername
|
|
199
|
+
);
|
|
200
|
+
const [d, b] = h(""), [s, O] = h(
|
|
201
|
+
l ? "chat" : "all"
|
|
202
|
+
), R = l ? l.split("@")[0] : void 0, [w, T] = h(!1), [u, F] = h(""), [f, L] = h(""), [m, M] = h(
|
|
203
|
+
null
|
|
204
|
+
), [k, N] = h(""), v = ne(u, f), U = I(
|
|
205
|
+
() => ({
|
|
206
|
+
fromUserId: m?.id,
|
|
207
|
+
since: v ? void 0 : oe(u),
|
|
208
|
+
until: v ? void 0 : se(f)
|
|
209
|
+
}),
|
|
210
|
+
[m?.id, u, f, v]
|
|
211
|
+
), C = (m ? 1 : 0) + (u ? 1 : 0) + (f ? 1 : 0), j = () => {
|
|
212
|
+
M(null), N(""), F(""), L("");
|
|
213
|
+
}, A = I(() => {
|
|
214
|
+
if (!k.trim()) return [];
|
|
215
|
+
const r = s === "chat" ? l && g[l]?.members || [] : Object.values(x || {});
|
|
216
|
+
return ce(r, k);
|
|
217
|
+
}, [k, s, g, l, x]), o = V(
|
|
218
|
+
v ? "" : d,
|
|
219
|
+
s,
|
|
220
|
+
R,
|
|
221
|
+
U
|
|
222
|
+
);
|
|
223
|
+
_(() => {
|
|
224
|
+
p.current?.focus();
|
|
225
|
+
}, []);
|
|
226
|
+
const { open: E } = Y(), Q = (r) => {
|
|
227
|
+
E(r) && S && c(ee(void 0));
|
|
228
|
+
}, D = I(() => o.items, [o.items]), B = d.trim();
|
|
229
|
+
return /* @__PURE__ */ a(
|
|
230
|
+
re,
|
|
231
|
+
{
|
|
232
|
+
title: e("search.messages.title"),
|
|
233
|
+
onClose: t,
|
|
234
|
+
backLabel: e("action.close"),
|
|
235
|
+
children: /* @__PURE__ */ n(le, { children: [
|
|
236
|
+
/* @__PURE__ */ n(te, { children: [
|
|
237
|
+
/* @__PURE__ */ a(W, {}),
|
|
238
|
+
/* @__PURE__ */ a(
|
|
239
|
+
ae,
|
|
240
|
+
{
|
|
241
|
+
ref: p,
|
|
242
|
+
"data-autofocus": !0,
|
|
243
|
+
type: "search",
|
|
244
|
+
value: d,
|
|
245
|
+
onChange: (r) => b(r.target.value),
|
|
246
|
+
placeholder: e(
|
|
247
|
+
s === "chat" ? "search.messages.placeholderChat" : "search.messages.placeholderAll"
|
|
248
|
+
),
|
|
249
|
+
"aria-label": e("search.messages.title")
|
|
250
|
+
}
|
|
251
|
+
)
|
|
252
|
+
] }),
|
|
253
|
+
/* @__PURE__ */ n(de, { role: "group", "aria-label": e("search.messages.scope"), children: [
|
|
254
|
+
/* @__PURE__ */ a(
|
|
255
|
+
H,
|
|
256
|
+
{
|
|
257
|
+
type: "button",
|
|
258
|
+
$active: s === "chat",
|
|
259
|
+
"aria-pressed": s === "chat",
|
|
260
|
+
disabled: !R,
|
|
261
|
+
onClick: () => O("chat"),
|
|
262
|
+
children: e("search.messages.scopeChat")
|
|
263
|
+
}
|
|
264
|
+
),
|
|
265
|
+
/* @__PURE__ */ a(
|
|
266
|
+
H,
|
|
267
|
+
{
|
|
268
|
+
type: "button",
|
|
269
|
+
$active: s === "all",
|
|
270
|
+
"aria-pressed": s === "all",
|
|
271
|
+
onClick: () => O("all"),
|
|
272
|
+
children: e("search.messages.scopeAll")
|
|
273
|
+
}
|
|
274
|
+
)
|
|
275
|
+
] }),
|
|
276
|
+
/* @__PURE__ */ n(
|
|
277
|
+
he,
|
|
278
|
+
{
|
|
279
|
+
type: "button",
|
|
280
|
+
$active: w || C > 0,
|
|
281
|
+
"aria-expanded": w,
|
|
282
|
+
onClick: () => T((r) => !r),
|
|
283
|
+
children: [
|
|
284
|
+
e("search.messages.filters"),
|
|
285
|
+
C > 0 && /* @__PURE__ */ a("span", { children: C })
|
|
286
|
+
]
|
|
287
|
+
}
|
|
288
|
+
),
|
|
289
|
+
w && /* @__PURE__ */ n(pe, { children: [
|
|
290
|
+
/* @__PURE__ */ n($, { children: [
|
|
291
|
+
e("search.messages.filterSender"),
|
|
292
|
+
m ? /* @__PURE__ */ n(me, { children: [
|
|
293
|
+
m.name,
|
|
294
|
+
/* @__PURE__ */ a(
|
|
295
|
+
"button",
|
|
296
|
+
{
|
|
297
|
+
type: "button",
|
|
298
|
+
"aria-label": e("search.messages.filterClear"),
|
|
299
|
+
onClick: () => M(null),
|
|
300
|
+
children: "×"
|
|
301
|
+
}
|
|
302
|
+
)
|
|
303
|
+
] }) : /* @__PURE__ */ a(
|
|
304
|
+
"input",
|
|
305
|
+
{
|
|
306
|
+
type: "search",
|
|
307
|
+
value: k,
|
|
308
|
+
onChange: (r) => N(r.target.value),
|
|
309
|
+
placeholder: e("search.messages.filterSenderPlaceholder")
|
|
310
|
+
}
|
|
311
|
+
)
|
|
312
|
+
] }),
|
|
313
|
+
!m && A.length > 0 && /* @__PURE__ */ a(fe, { role: "listbox", children: A.map((r) => /* @__PURE__ */ a("li", { children: /* @__PURE__ */ a(
|
|
314
|
+
"button",
|
|
315
|
+
{
|
|
316
|
+
type: "button",
|
|
317
|
+
role: "option",
|
|
318
|
+
"aria-selected": !1,
|
|
319
|
+
onClick: () => {
|
|
320
|
+
M(r), N("");
|
|
321
|
+
},
|
|
322
|
+
children: r.name
|
|
323
|
+
}
|
|
324
|
+
) }, r.id)) }),
|
|
325
|
+
/* @__PURE__ */ n(ue, { children: [
|
|
326
|
+
/* @__PURE__ */ n($, { children: [
|
|
327
|
+
e("search.messages.filterSince"),
|
|
328
|
+
/* @__PURE__ */ a(
|
|
329
|
+
"input",
|
|
330
|
+
{
|
|
331
|
+
type: "date",
|
|
332
|
+
value: u,
|
|
333
|
+
max: f || void 0,
|
|
334
|
+
onChange: (r) => F(r.target.value)
|
|
335
|
+
}
|
|
336
|
+
)
|
|
337
|
+
] }),
|
|
338
|
+
/* @__PURE__ */ n($, { children: [
|
|
339
|
+
e("search.messages.filterUntil"),
|
|
340
|
+
/* @__PURE__ */ a(
|
|
341
|
+
"input",
|
|
342
|
+
{
|
|
343
|
+
type: "date",
|
|
344
|
+
value: f,
|
|
345
|
+
min: u || void 0,
|
|
346
|
+
onChange: (r) => L(r.target.value)
|
|
347
|
+
}
|
|
348
|
+
)
|
|
349
|
+
] })
|
|
350
|
+
] }),
|
|
351
|
+
v && /* @__PURE__ */ a(y, { role: "alert", children: e("search.messages.dateOrder") }),
|
|
352
|
+
C > 0 && /* @__PURE__ */ a(ge, { type: "button", onClick: j, children: e("search.messages.filterClearAll") })
|
|
353
|
+
] }),
|
|
354
|
+
!o.searchable && /* @__PURE__ */ a(y, { children: B ? e("search.messages.tooShort", { count: X }) : e("search.messages.hint") }),
|
|
355
|
+
o.searchable && o.status === "loading" && /* @__PURE__ */ a(y, { role: "status", children: e("search.messages.searching") }),
|
|
356
|
+
o.status === "error" && /* @__PURE__ */ n(y, { role: "alert", children: [
|
|
357
|
+
e("search.messages.error"),
|
|
358
|
+
" ",
|
|
359
|
+
/* @__PURE__ */ a("button", { type: "button", onClick: o.retry, children: e("search.messages.retry") })
|
|
360
|
+
] }),
|
|
361
|
+
o.searchable && o.status === "done" && D.length === 0 && /* @__PURE__ */ a(y, { children: e("search.messages.empty") }),
|
|
362
|
+
D.length > 0 && /* @__PURE__ */ n(q, { children: [
|
|
363
|
+
/* @__PURE__ */ a(xe, { role: "status", children: e("search.messages.count", { count: o.total }) }),
|
|
364
|
+
/* @__PURE__ */ a(
|
|
365
|
+
Z,
|
|
366
|
+
{
|
|
367
|
+
hits: D,
|
|
368
|
+
query: B,
|
|
369
|
+
showRoom: s === "all",
|
|
370
|
+
onOpen: Q
|
|
371
|
+
}
|
|
372
|
+
),
|
|
373
|
+
o.hasMore && /* @__PURE__ */ a(
|
|
374
|
+
be,
|
|
375
|
+
{
|
|
376
|
+
type: "button",
|
|
377
|
+
onClick: o.loadMore,
|
|
378
|
+
disabled: o.status === "loadingMore",
|
|
379
|
+
children: o.status === "loadingMore" ? e("search.messages.searching") : e("search.messages.loadMore")
|
|
380
|
+
}
|
|
381
|
+
)
|
|
382
|
+
] })
|
|
383
|
+
] })
|
|
384
|
+
}
|
|
385
|
+
);
|
|
386
|
+
};
|
|
387
|
+
export {
|
|
388
|
+
Ce as default
|
|
389
|
+
};
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
import { jsxs as d, jsx as a } from "react/jsx-runtime";
|
|
2
|
+
import { useState as p, useRef as B, useCallback as P, useEffect as T, useMemo as z } from "react";
|
|
3
|
+
import { g as E, aN as U, p as _, a as q, aI as F, u as A, ar as H, x as c, a2 as J, q as G } from "./main-rJpE4hh-.js";
|
|
4
|
+
import { S as V, i as Z, j as K, f as S } from "./SideDrawer-WneDrrWG.js";
|
|
5
|
+
const I = 50;
|
|
6
|
+
async function Q({
|
|
7
|
+
offset: r = 0,
|
|
8
|
+
limit: t = I,
|
|
9
|
+
signal: u
|
|
10
|
+
} = {}) {
|
|
11
|
+
const x = E.getState().chatSettingStore.user?.token || "", s = (await U.get("/v1/chats/public", {
|
|
12
|
+
params: { limit: Math.min(t, I), offset: r },
|
|
13
|
+
headers: { Authorization: x },
|
|
14
|
+
signal: u
|
|
15
|
+
}))?.data || {}, l = Array.isArray(s.items) ? s.items : [];
|
|
16
|
+
return {
|
|
17
|
+
// A chat that has been reported is not one to advertise in a directory.
|
|
18
|
+
items: l.filter((i) => i.name && !i.reported).map((i) => ({
|
|
19
|
+
name: String(i.name),
|
|
20
|
+
title: String(i.title || "").trim(),
|
|
21
|
+
description: String(i.description || "").trim(),
|
|
22
|
+
picture: String(i.picture || ""),
|
|
23
|
+
e2ee: !!i.e2ee
|
|
24
|
+
})),
|
|
25
|
+
total: Number(s.total) || 0,
|
|
26
|
+
offset: Number(s.offset) || r,
|
|
27
|
+
limit: Number(s.limit) || t,
|
|
28
|
+
nextOffset: r + l.length
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
const W = c.ul`
|
|
32
|
+
list-style: none;
|
|
33
|
+
margin: 0;
|
|
34
|
+
padding: 0;
|
|
35
|
+
display: flex;
|
|
36
|
+
flex-direction: column;
|
|
37
|
+
`, X = c.li`
|
|
38
|
+
display: flex;
|
|
39
|
+
align-items: center;
|
|
40
|
+
gap: var(--ethora-space-3, 12px);
|
|
41
|
+
padding: var(--ethora-space-2, 8px) var(--ethora-space-1, 4px);
|
|
42
|
+
`, Y = c.div`
|
|
43
|
+
flex: 0 0 auto;
|
|
44
|
+
width: 40px;
|
|
45
|
+
height: 40px;
|
|
46
|
+
border-radius: var(--ethora-radius-full, 999px);
|
|
47
|
+
background: ${({ $src: r }) => r ? `center / cover no-repeat url("${r.replace(/["\\]/g, (t) => encodeURIComponent(t))}")` : "var(--ethora-color-primary-soft, #e7edf9)"};
|
|
48
|
+
color: var(--ethora-color-primary-text, #0052cd);
|
|
49
|
+
font-weight: var(--ethora-font-weight-semibold, 600);
|
|
50
|
+
display: flex;
|
|
51
|
+
align-items: center;
|
|
52
|
+
justify-content: center;
|
|
53
|
+
`, ee = c.div`
|
|
54
|
+
flex: 1 1 auto;
|
|
55
|
+
min-width: 0;
|
|
56
|
+
display: flex;
|
|
57
|
+
flex-direction: column;
|
|
58
|
+
gap: 2px;
|
|
59
|
+
text-align: start;
|
|
60
|
+
|
|
61
|
+
> strong {
|
|
62
|
+
font-size: var(--ethora-font-size-sm, 14px);
|
|
63
|
+
font-weight: var(--ethora-font-weight-medium, 500);
|
|
64
|
+
color: var(--ethora-color-text, #141414);
|
|
65
|
+
overflow: hidden;
|
|
66
|
+
text-overflow: ellipsis;
|
|
67
|
+
white-space: nowrap;
|
|
68
|
+
}
|
|
69
|
+
> span {
|
|
70
|
+
font-size: var(--ethora-font-size-xs, 12px);
|
|
71
|
+
color: var(--ethora-color-text-muted, #6c6c6c);
|
|
72
|
+
overflow: hidden;
|
|
73
|
+
text-overflow: ellipsis;
|
|
74
|
+
white-space: nowrap;
|
|
75
|
+
}
|
|
76
|
+
`, te = c.button`
|
|
77
|
+
flex: 0 0 auto;
|
|
78
|
+
padding: 6px 14px;
|
|
79
|
+
border-radius: var(--ethora-radius-full, 999px);
|
|
80
|
+
border: 1px solid var(--ethora-color-primary, #0052cd);
|
|
81
|
+
background: ${({ $open: r }) => r ? "transparent" : "var(--ethora-color-primary, #0052cd)"};
|
|
82
|
+
color: ${({ $open: r }) => r ? "var(--ethora-color-primary-text, #0052cd)" : "var(--ethora-color-text-on-primary, #fff)"};
|
|
83
|
+
font: inherit;
|
|
84
|
+
font-size: var(--ethora-font-size-sm, 14px);
|
|
85
|
+
font-weight: var(--ethora-font-weight-medium, 500);
|
|
86
|
+
cursor: pointer;
|
|
87
|
+
`, re = c.button`
|
|
88
|
+
align-self: center;
|
|
89
|
+
margin-top: var(--ethora-space-2, 8px);
|
|
90
|
+
padding: 6px 14px;
|
|
91
|
+
border: 1px solid var(--ethora-color-border, #e6e8ec);
|
|
92
|
+
border-radius: var(--ethora-radius-full, 999px);
|
|
93
|
+
background: transparent;
|
|
94
|
+
color: var(--ethora-color-text-secondary, #5a5f66);
|
|
95
|
+
font: inherit;
|
|
96
|
+
font-size: var(--ethora-font-size-sm, 14px);
|
|
97
|
+
cursor: pointer;
|
|
98
|
+
|
|
99
|
+
&:disabled {
|
|
100
|
+
opacity: 0.6;
|
|
101
|
+
cursor: default;
|
|
102
|
+
}
|
|
103
|
+
`, oe = (r) => (r.title || r.name).trim().charAt(0).toUpperCase() || "#", le = ({
|
|
104
|
+
handleCloseModal: r
|
|
105
|
+
}) => {
|
|
106
|
+
const t = _(), u = q(), x = F(767), b = A((e) => e.rooms.rooms), s = A(
|
|
107
|
+
(e) => e.chatSettingStore.config?.xmppSettings?.conference
|
|
108
|
+
), [l, i] = p([]), [j, $] = p(0), [v, D] = p(0), [n, w] = p("loading"), [h, L] = p(""), m = B(0), f = P(async (e) => {
|
|
109
|
+
const o = ++m.current;
|
|
110
|
+
w(e ? "loadingMore" : "loading");
|
|
111
|
+
try {
|
|
112
|
+
const g = await Q({ offset: e });
|
|
113
|
+
if (o !== m.current) return;
|
|
114
|
+
i((k) => {
|
|
115
|
+
const R = new Set(k.map((C) => C.name));
|
|
116
|
+
return e ? [...k, ...g.items.filter((C) => !R.has(C.name))] : g.items;
|
|
117
|
+
}), $(g.total), D(g.nextOffset), w("done");
|
|
118
|
+
} catch {
|
|
119
|
+
o === m.current && w("error");
|
|
120
|
+
}
|
|
121
|
+
}, []);
|
|
122
|
+
T(() => (f(0), () => {
|
|
123
|
+
m.current += 1;
|
|
124
|
+
}), [f]);
|
|
125
|
+
const O = z(
|
|
126
|
+
() => new Set(Object.keys(b).map((e) => e.split("@")[0])),
|
|
127
|
+
[b]
|
|
128
|
+
), y = z(() => {
|
|
129
|
+
const e = h.trim().toLowerCase();
|
|
130
|
+
return e ? l.filter(
|
|
131
|
+
(o) => o.title.toLowerCase().includes(e) || o.description.toLowerCase().includes(e)
|
|
132
|
+
) : l;
|
|
133
|
+
}, [l, h]), N = (e) => {
|
|
134
|
+
const o = (s || "").trim();
|
|
135
|
+
o && (u(J({ roomJID: `${e.name}@${o}` })), x && u(G(void 0)));
|
|
136
|
+
}, M = v < j;
|
|
137
|
+
return /* @__PURE__ */ d(
|
|
138
|
+
V,
|
|
139
|
+
{
|
|
140
|
+
title: t("publicChats.title"),
|
|
141
|
+
onClose: r,
|
|
142
|
+
backLabel: t("action.close"),
|
|
143
|
+
children: [
|
|
144
|
+
/* @__PURE__ */ d(Z, { children: [
|
|
145
|
+
/* @__PURE__ */ a(H, {}),
|
|
146
|
+
/* @__PURE__ */ a(
|
|
147
|
+
K,
|
|
148
|
+
{
|
|
149
|
+
type: "search",
|
|
150
|
+
value: h,
|
|
151
|
+
onChange: (e) => L(e.target.value),
|
|
152
|
+
placeholder: t("publicChats.filter"),
|
|
153
|
+
"aria-label": t("publicChats.filter")
|
|
154
|
+
}
|
|
155
|
+
)
|
|
156
|
+
] }),
|
|
157
|
+
n === "loading" && /* @__PURE__ */ a(S, { role: "status", children: t("publicChats.loading") }),
|
|
158
|
+
n === "error" && /* @__PURE__ */ d(S, { role: "alert", children: [
|
|
159
|
+
t("publicChats.error"),
|
|
160
|
+
" ",
|
|
161
|
+
/* @__PURE__ */ a("button", { type: "button", onClick: () => {
|
|
162
|
+
f(v);
|
|
163
|
+
}, children: t("search.messages.retry") })
|
|
164
|
+
] }),
|
|
165
|
+
n !== "loading" && n !== "error" && y.length === 0 && /* @__PURE__ */ a(S, { children: h.trim() && M ? t("publicChats.emptyFilterMore") : t("publicChats.empty") }),
|
|
166
|
+
y.length > 0 && /* @__PURE__ */ a(W, { children: y.map((e) => {
|
|
167
|
+
const o = O.has(e.name);
|
|
168
|
+
return /* @__PURE__ */ d(X, { children: [
|
|
169
|
+
/* @__PURE__ */ a(Y, { $src: e.picture, "aria-hidden": "true", children: !e.picture && oe(e) }),
|
|
170
|
+
/* @__PURE__ */ d(ee, { children: [
|
|
171
|
+
/* @__PURE__ */ a("strong", { children: e.title || t("search.messages.chat") }),
|
|
172
|
+
e.description && /* @__PURE__ */ a("span", { children: e.description })
|
|
173
|
+
] }),
|
|
174
|
+
/* @__PURE__ */ a(
|
|
175
|
+
te,
|
|
176
|
+
{
|
|
177
|
+
type: "button",
|
|
178
|
+
$open: o,
|
|
179
|
+
onClick: () => N(e),
|
|
180
|
+
children: t(o ? "publicChats.open" : "publicChats.join")
|
|
181
|
+
}
|
|
182
|
+
)
|
|
183
|
+
] }, e.name);
|
|
184
|
+
}) }),
|
|
185
|
+
M && n !== "loading" && n !== "error" && /* @__PURE__ */ a(
|
|
186
|
+
re,
|
|
187
|
+
{
|
|
188
|
+
type: "button",
|
|
189
|
+
disabled: n === "loadingMore",
|
|
190
|
+
onClick: () => {
|
|
191
|
+
f(v);
|
|
192
|
+
},
|
|
193
|
+
children: t(n === "loadingMore" ? "search.messages.searching" : "search.messages.loadMore")
|
|
194
|
+
}
|
|
195
|
+
)
|
|
196
|
+
]
|
|
197
|
+
}
|
|
198
|
+
);
|
|
199
|
+
};
|
|
200
|
+
export {
|
|
201
|
+
le as default
|
|
202
|
+
};
|