@linktr.ee/messaging-react 1.2.0 → 1.3.0-rc-1761055628
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/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as e, jsxs as i, Fragment as se } from "react/jsx-runtime";
|
|
2
|
-
import
|
|
3
|
-
import $, { createContext as ue, useContext as me, useCallback as
|
|
2
|
+
import F from "classnames";
|
|
3
|
+
import $, { createContext as ue, useContext as me, useCallback as L, useState as v, useRef as A, useEffect as B } from "react";
|
|
4
4
|
import { StreamChatService as he } from "@linktr.ee/messaging-core";
|
|
5
5
|
import { Chat as fe, useChatContext as ge, ChannelList as xe, Channel as Ne, Window as Ce, MessageList as be, useChannelStateContext as ve, MessageInput as we } from "stream-chat-react";
|
|
6
6
|
import { NotePencilIcon as Ee, XIcon as oe, ArrowLeftIcon as Ie, DotsThreeIcon as ye, SpinnerGapIcon as Q, SignOutIcon as Se, ProhibitInsetIcon as te, FlagIcon as Re, MagnifyingGlassIcon as ke, ChatCircleDotsIcon as ne } from "@phosphor-icons/react";
|
|
@@ -24,7 +24,7 @@ const ae = ue({
|
|
|
24
24
|
customization: m = {},
|
|
25
25
|
debug: d = !1
|
|
26
26
|
}) => {
|
|
27
|
-
const r =
|
|
27
|
+
const r = L(
|
|
28
28
|
(N, ...S) => {
|
|
29
29
|
d && console.log(`🔥 [MessagingProvider] ${N}`, ...S);
|
|
30
30
|
},
|
|
@@ -37,7 +37,7 @@ const ae = ue({
|
|
|
37
37
|
capabilities: Object.keys(a),
|
|
38
38
|
customization: Object.keys(m)
|
|
39
39
|
});
|
|
40
|
-
const [o,
|
|
40
|
+
const [o, w] = v(null), [x, g] = v(null), [c, C] = v(!1), [b, y] = v(!1), [I, P] = v(null), O = A(!1), E = A({
|
|
41
41
|
userId: s == null ? void 0 : s.id,
|
|
42
42
|
apiKey: l,
|
|
43
43
|
serviceConfig: n,
|
|
@@ -89,7 +89,7 @@ const ae = ue({
|
|
|
89
89
|
apiKey: l,
|
|
90
90
|
debug: d
|
|
91
91
|
});
|
|
92
|
-
return
|
|
92
|
+
return w(S), r("✅ SERVICE SET", {
|
|
93
93
|
renderCount: N,
|
|
94
94
|
serviceInstance: !!S
|
|
95
95
|
}), () => {
|
|
@@ -106,14 +106,14 @@ const ae = ue({
|
|
|
106
106
|
hasService: !!o,
|
|
107
107
|
hasUser: !!s,
|
|
108
108
|
userId: s == null ? void 0 : s.id,
|
|
109
|
-
isConnecting:
|
|
109
|
+
isConnecting: O.current,
|
|
110
110
|
isConnected: c,
|
|
111
111
|
dependencies: { service: !!o, userId: s == null ? void 0 : s.id }
|
|
112
112
|
}), !o || !s) {
|
|
113
113
|
r("⚠️ USER CONNECTION SKIPPED", "Missing service or user");
|
|
114
114
|
return;
|
|
115
115
|
}
|
|
116
|
-
if (
|
|
116
|
+
if (O.current) {
|
|
117
117
|
r("⚠️ USER CONNECTION SKIPPED", "Already connecting");
|
|
118
118
|
return;
|
|
119
119
|
}
|
|
@@ -125,22 +125,22 @@ const ae = ue({
|
|
|
125
125
|
return;
|
|
126
126
|
}
|
|
127
127
|
(async () => {
|
|
128
|
-
r("🚀 STARTING USER CONNECTION", { userId: s.id }),
|
|
128
|
+
r("🚀 STARTING USER CONNECTION", { userId: s.id }), O.current = !0, y(!0), P(null);
|
|
129
129
|
try {
|
|
130
130
|
r("📞 CALLING SERVICE.CONNECTUSER", { userId: s.id });
|
|
131
|
-
const
|
|
132
|
-
g(
|
|
131
|
+
const M = await o.connectUser(s);
|
|
132
|
+
g(M), C(!0), T.current = { serviceId: o, userId: s.id }, r("✅ USER CONNECTION SUCCESS", {
|
|
133
133
|
userId: s.id,
|
|
134
|
-
clientId:
|
|
134
|
+
clientId: M.userID
|
|
135
135
|
});
|
|
136
|
-
} catch (
|
|
137
|
-
const H =
|
|
136
|
+
} catch (M) {
|
|
137
|
+
const H = M instanceof Error ? M.message : "Connection failed";
|
|
138
138
|
P(H), r("❌ USER CONNECTION ERROR", {
|
|
139
139
|
userId: s.id,
|
|
140
140
|
error: H
|
|
141
141
|
});
|
|
142
142
|
} finally {
|
|
143
|
-
y(!1),
|
|
143
|
+
y(!1), O.current = !1, r("🔄 USER CONNECTION FINISHED", {
|
|
144
144
|
userId: s.id,
|
|
145
145
|
isConnected: c
|
|
146
146
|
});
|
|
@@ -158,7 +158,7 @@ const ae = ue({
|
|
|
158
158
|
isConnected: c
|
|
159
159
|
});
|
|
160
160
|
}), [o, c, r]);
|
|
161
|
-
const u =
|
|
161
|
+
const u = L(async () => {
|
|
162
162
|
if (r("🔄 REFRESH CONNECTION CALLED", {
|
|
163
163
|
hasService: !!o,
|
|
164
164
|
hasUser: !!s
|
|
@@ -184,7 +184,7 @@ const ae = ue({
|
|
|
184
184
|
hasService: !!o,
|
|
185
185
|
hasClient: !!x,
|
|
186
186
|
isConnected: c,
|
|
187
|
-
isLoading:
|
|
187
|
+
isLoading: b,
|
|
188
188
|
hasError: !!I,
|
|
189
189
|
capabilitiesKeys: Object.keys(a),
|
|
190
190
|
customizationKeys: Object.keys(m)
|
|
@@ -192,7 +192,7 @@ const ae = ue({
|
|
|
192
192
|
service: o,
|
|
193
193
|
client: x,
|
|
194
194
|
isConnected: c,
|
|
195
|
-
isLoading:
|
|
195
|
+
isLoading: b,
|
|
196
196
|
error: I,
|
|
197
197
|
capabilities: a,
|
|
198
198
|
customization: m,
|
|
@@ -202,7 +202,7 @@ const ae = ue({
|
|
|
202
202
|
o,
|
|
203
203
|
x,
|
|
204
204
|
c,
|
|
205
|
-
|
|
205
|
+
b,
|
|
206
206
|
I,
|
|
207
207
|
a,
|
|
208
208
|
m,
|
|
@@ -221,7 +221,7 @@ function q({ label: t, className: s, children: n, ...l }) {
|
|
|
221
221
|
"button",
|
|
222
222
|
{
|
|
223
223
|
type: "button",
|
|
224
|
-
className:
|
|
224
|
+
className: F(
|
|
225
225
|
"rounded-full p-2 transition-colors focus-ring",
|
|
226
226
|
{
|
|
227
227
|
"cursor-not-allowed opacity-50": l.disabled,
|
|
@@ -239,30 +239,30 @@ function q({ label: t, className: s, children: n, ...l }) {
|
|
|
239
239
|
}
|
|
240
240
|
function Te(t) {
|
|
241
241
|
const s = [
|
|
242
|
-
{
|
|
243
|
-
//
|
|
244
|
-
{
|
|
245
|
-
//
|
|
246
|
-
{
|
|
247
|
-
//
|
|
248
|
-
{
|
|
249
|
-
//
|
|
250
|
-
{
|
|
251
|
-
//
|
|
252
|
-
{
|
|
253
|
-
//
|
|
254
|
-
{
|
|
255
|
-
//
|
|
256
|
-
{
|
|
257
|
-
//
|
|
258
|
-
{
|
|
259
|
-
//
|
|
260
|
-
{
|
|
261
|
-
//
|
|
262
|
-
{
|
|
263
|
-
//
|
|
264
|
-
{
|
|
265
|
-
//
|
|
242
|
+
{ color: "#8129D9" },
|
|
243
|
+
// purple
|
|
244
|
+
{ color: "#254f1a" },
|
|
245
|
+
// dark green
|
|
246
|
+
{ color: "#061492" },
|
|
247
|
+
// dark blue
|
|
248
|
+
{ color: "#1e2330" },
|
|
249
|
+
// dark blue-gray
|
|
250
|
+
{ color: "#502274" },
|
|
251
|
+
// dark purple
|
|
252
|
+
{ color: "#d717e7" },
|
|
253
|
+
// magenta
|
|
254
|
+
{ color: "#780016" },
|
|
255
|
+
// dark red
|
|
256
|
+
{ color: "#c41500" },
|
|
257
|
+
// red
|
|
258
|
+
{ color: "#fc3e4b" },
|
|
259
|
+
// pink
|
|
260
|
+
{ color: "#4c2e05" },
|
|
261
|
+
// brown
|
|
262
|
+
{ color: "#ff6c02" },
|
|
263
|
+
// orange
|
|
264
|
+
{ color: "#70764d" }
|
|
265
|
+
// olive green
|
|
266
266
|
];
|
|
267
267
|
let n = 0;
|
|
268
268
|
for (let a = 0; a < t.length; a++)
|
|
@@ -277,11 +277,11 @@ const Y = ({
|
|
|
277
277
|
size: l = 40,
|
|
278
278
|
className: a
|
|
279
279
|
}) => {
|
|
280
|
-
const {
|
|
280
|
+
const { color: m } = Te(t), d = s.charAt(0).toUpperCase(), o = l < 32 ? "text-xs" : l < 56 ? "text-sm" : "text-lg";
|
|
281
281
|
return /* @__PURE__ */ e(
|
|
282
282
|
"div",
|
|
283
283
|
{
|
|
284
|
-
className:
|
|
284
|
+
className: F(
|
|
285
285
|
"flex-shrink-0 overflow-hidden rounded-full",
|
|
286
286
|
a
|
|
287
287
|
),
|
|
@@ -296,27 +296,30 @@ const Y = ({
|
|
|
296
296
|
) : /* @__PURE__ */ e(
|
|
297
297
|
"div",
|
|
298
298
|
{
|
|
299
|
-
|
|
299
|
+
"aria-hidden": "true",
|
|
300
|
+
className: F(
|
|
300
301
|
"flex h-full w-full items-center justify-center font-semibold",
|
|
301
|
-
|
|
302
|
-
d,
|
|
303
|
-
b
|
|
302
|
+
o
|
|
304
303
|
),
|
|
305
|
-
|
|
304
|
+
style: {
|
|
305
|
+
color: m,
|
|
306
|
+
backgroundColor: `color-mix(in srgb, ${m} 20%, transparent)`
|
|
307
|
+
},
|
|
308
|
+
children: d
|
|
306
309
|
}
|
|
307
310
|
)
|
|
308
311
|
}
|
|
309
312
|
);
|
|
310
313
|
}, De = ({ channel: t, selectedChannel: s, onChannelSelect: n, debug: l = !1 }) => {
|
|
311
|
-
var
|
|
314
|
+
var b, y, I, P, O, E, R;
|
|
312
315
|
const a = (s == null ? void 0 : s.id) === (t == null ? void 0 : t.id), m = () => {
|
|
313
316
|
t && n(t);
|
|
314
|
-
}, r = Object.values(((
|
|
317
|
+
}, r = Object.values(((b = t == null ? void 0 : t.state) == null ? void 0 : b.members) || {}).find(
|
|
315
318
|
(T) => {
|
|
316
319
|
var u, f;
|
|
317
320
|
return ((u = T.user) == null ? void 0 : u.id) && T.user.id !== ((f = t == null ? void 0 : t._client) == null ? void 0 : f.userID);
|
|
318
321
|
}
|
|
319
|
-
), o = ((y = r == null ? void 0 : r.user) == null ? void 0 : y.name) || "Conversation",
|
|
322
|
+
), o = ((y = r == null ? void 0 : r.user) == null ? void 0 : y.name) || "Conversation", w = (I = r == null ? void 0 : r.user) == null ? void 0 : I.image, x = (O = (P = t == null ? void 0 : t.state) == null ? void 0 : P.messages) == null ? void 0 : O[t.state.messages.length - 1], g = (x == null ? void 0 : x.text) || "No messages yet", c = x != null && x.created_at ? new Date(x.created_at).toLocaleTimeString([], {
|
|
320
323
|
hour: "2-digit",
|
|
321
324
|
minute: "2-digit"
|
|
322
325
|
}) : "", C = ((E = t == null ? void 0 : t.state) == null ? void 0 : E.unreadCount) || 0;
|
|
@@ -331,7 +334,7 @@ const Y = ({
|
|
|
331
334
|
{
|
|
332
335
|
type: "button",
|
|
333
336
|
onClick: m,
|
|
334
|
-
className:
|
|
337
|
+
className: F(
|
|
335
338
|
"w-full px-4 py-3 transition-colors border-b border-sand text-left max-w-full overflow-hidden focus-ring",
|
|
336
339
|
{
|
|
337
340
|
"bg-primary-alt/10 border-l-4 border-l-primary": a,
|
|
@@ -344,7 +347,7 @@ const Y = ({
|
|
|
344
347
|
{
|
|
345
348
|
id: ((R = r == null ? void 0 : r.user) == null ? void 0 : R.id) || t.id || "unknown",
|
|
346
349
|
name: o,
|
|
347
|
-
image:
|
|
350
|
+
image: w,
|
|
348
351
|
size: 44
|
|
349
352
|
}
|
|
350
353
|
),
|
|
@@ -353,7 +356,7 @@ const Y = ({
|
|
|
353
356
|
/* @__PURE__ */ e(
|
|
354
357
|
"h3",
|
|
355
358
|
{
|
|
356
|
-
className:
|
|
359
|
+
className: F(
|
|
357
360
|
"text-sm font-medium truncate",
|
|
358
361
|
a ? "text-primary" : "text-charcoal"
|
|
359
362
|
),
|
|
@@ -370,7 +373,7 @@ const Y = ({
|
|
|
370
373
|
] })
|
|
371
374
|
}
|
|
372
375
|
);
|
|
373
|
-
},
|
|
376
|
+
}, Oe = ({
|
|
374
377
|
onChannelSelect: t,
|
|
375
378
|
selectedChannel: s,
|
|
376
379
|
showStartConversation: n = !1,
|
|
@@ -395,7 +398,7 @@ const Y = ({
|
|
|
395
398
|
clientUserId: o == null ? void 0 : o.userID,
|
|
396
399
|
clientConnected: (x = o == null ? void 0 : o.wsConnection) == null ? void 0 : x.isHealthy
|
|
397
400
|
});
|
|
398
|
-
const
|
|
401
|
+
const w = $.useMemo(() => {
|
|
399
402
|
const g = o.userID, c = g ? { type: "messaging", members: { $in: [g] }, hidden: !1 } : { type: "messaging" };
|
|
400
403
|
return r && console.log("📺 [ChannelList] 🔍 FILTERS MEMOIZED", {
|
|
401
404
|
renderCount: d.current,
|
|
@@ -406,7 +409,7 @@ const Y = ({
|
|
|
406
409
|
return /* @__PURE__ */ i(
|
|
407
410
|
"div",
|
|
408
411
|
{
|
|
409
|
-
className:
|
|
412
|
+
className: F(
|
|
410
413
|
"h-full flex flex-col min-w-0 overflow-hidden",
|
|
411
414
|
m
|
|
412
415
|
),
|
|
@@ -425,13 +428,13 @@ const Y = ({
|
|
|
425
428
|
] }) }),
|
|
426
429
|
/* @__PURE__ */ e("div", { className: "flex-1 overflow-hidden min-w-0", children: (r && console.log("📺 [ChannelList] 🎬 RENDERING STREAM CHANNEL LIST", {
|
|
427
430
|
renderCount: d.current,
|
|
428
|
-
filters:
|
|
431
|
+
filters: w,
|
|
429
432
|
hasClient: !!o,
|
|
430
433
|
clientUserId: o == null ? void 0 : o.userID
|
|
431
434
|
}), /* @__PURE__ */ e(
|
|
432
435
|
xe,
|
|
433
436
|
{
|
|
434
|
-
filters:
|
|
437
|
+
filters: w,
|
|
435
438
|
sort: { last_message_at: -1 },
|
|
436
439
|
options: { limit: 30 },
|
|
437
440
|
Preview: (g) => {
|
|
@@ -464,7 +467,7 @@ const Y = ({
|
|
|
464
467
|
"button",
|
|
465
468
|
{
|
|
466
469
|
type: "button",
|
|
467
|
-
className:
|
|
470
|
+
className: F(
|
|
468
471
|
"flex w-full items-center gap-3 rounded-lg px-4 py-3 text-left text-sm transition-colors focus-ring disabled:cursor-not-allowed disabled:opacity-60",
|
|
469
472
|
t === "danger" ? "text-danger hover:bg-danger/50" : "text-charcoal hover:bg-sand",
|
|
470
473
|
s
|
|
@@ -476,17 +479,17 @@ const Y = ({
|
|
|
476
479
|
function ie({ onClick: t }) {
|
|
477
480
|
return /* @__PURE__ */ e(q, { label: "Close", onClick: t, className: "p-1", children: /* @__PURE__ */ e(oe, { className: "h-5 w-5 text-stone", weight: "bold" }) });
|
|
478
481
|
}
|
|
479
|
-
const
|
|
482
|
+
const Ue = ({ renderActions: t }) => /* @__PURE__ */ i("div", { className: "message-input flex items-center gap-2 p-4", children: [
|
|
480
483
|
t && t(),
|
|
481
484
|
/* @__PURE__ */ e("div", { className: "flex-1", children: /* @__PURE__ */ e(we, { focus: !0, maxRows: 4 }) })
|
|
482
|
-
] }),
|
|
483
|
-
var o,
|
|
485
|
+
] }), Le = ({ onBack: t, showBackButton: s, onShowInfo: n, canShowInfo: l }) => {
|
|
486
|
+
var o, w, x, g;
|
|
484
487
|
const { channel: a } = ve(), m = $.useMemo(() => Object.values(a.state.members || {}).find(
|
|
485
488
|
(C) => {
|
|
486
|
-
var
|
|
487
|
-
return ((
|
|
489
|
+
var b;
|
|
490
|
+
return ((b = C.user) == null ? void 0 : b.id) && C.user.id !== a._client.userID;
|
|
488
491
|
}
|
|
489
|
-
), [a._client.userID, a.state.members]), d = ((o = m == null ? void 0 : m.user) == null ? void 0 : o.name) || ((
|
|
492
|
+
), [a._client.userID, a.state.members]), d = ((o = m == null ? void 0 : m.user) == null ? void 0 : o.name) || ((w = m == null ? void 0 : m.user) == null ? void 0 : w.id) || "Unknown member", r = (x = m == null ? void 0 : m.user) == null ? void 0 : x.image;
|
|
490
493
|
return /* @__PURE__ */ i("div", { className: "flex items-center justify-between gap-3 min-h-12", children: [
|
|
491
494
|
/* @__PURE__ */ i("div", { className: "flex items-center gap-3 min-w-0", children: [
|
|
492
495
|
s && t && /* @__PURE__ */ e(
|
|
@@ -512,7 +515,7 @@ const Oe = ({ renderActions: t }) => /* @__PURE__ */ i("div", { className: "mess
|
|
|
512
515
|
] }),
|
|
513
516
|
l && n && /* @__PURE__ */ e(q, { label: "Chat info", onClick: n, children: /* @__PURE__ */ e(ye, { className: "h-6 w-6 text-charcoal", weight: "bold" }) })
|
|
514
517
|
] });
|
|
515
|
-
},
|
|
518
|
+
}, Fe = ({
|
|
516
519
|
isOpen: t,
|
|
517
520
|
onClose: s,
|
|
518
521
|
participant: n,
|
|
@@ -521,20 +524,20 @@ const Oe = ({ renderActions: t }) => /* @__PURE__ */ i("div", { className: "mess
|
|
|
521
524
|
onLeaveConversation: m,
|
|
522
525
|
onBlockParticipant: d
|
|
523
526
|
}) => {
|
|
524
|
-
var
|
|
525
|
-
const { service: r, debug: o } = Z(),
|
|
527
|
+
var M, H, V, _, W, G, z;
|
|
528
|
+
const { service: r, debug: o } = Z(), w = A(null), [x, g] = v(!1), [c, C] = v(!1), [b, y] = v(!1);
|
|
526
529
|
B(() => {
|
|
527
|
-
const k =
|
|
530
|
+
const k = w.current;
|
|
528
531
|
k && (t ? k.showModal() : k.close());
|
|
529
532
|
}, [t]);
|
|
530
|
-
const I =
|
|
533
|
+
const I = L(async () => {
|
|
531
534
|
var k;
|
|
532
535
|
if (!(!r || !((k = n == null ? void 0 : n.user) != null && k.id)))
|
|
533
536
|
try {
|
|
534
537
|
const h = (await r.getBlockedUsers()).some(
|
|
535
|
-
(
|
|
536
|
-
var
|
|
537
|
-
return
|
|
538
|
+
(U) => {
|
|
539
|
+
var p;
|
|
540
|
+
return U.blocked_user_id === ((p = n == null ? void 0 : n.user) == null ? void 0 : p.id);
|
|
538
541
|
}
|
|
539
542
|
);
|
|
540
543
|
g(h);
|
|
@@ -544,7 +547,7 @@ const Oe = ({ renderActions: t }) => /* @__PURE__ */ i("div", { className: "mess
|
|
|
544
547
|
D
|
|
545
548
|
);
|
|
546
549
|
}
|
|
547
|
-
}, [r, (
|
|
550
|
+
}, [r, (M = n == null ? void 0 : n.user) == null ? void 0 : M.id]);
|
|
548
551
|
B(() => {
|
|
549
552
|
t && I();
|
|
550
553
|
}, [t, I]);
|
|
@@ -561,26 +564,26 @@ const Oe = ({ renderActions: t }) => /* @__PURE__ */ i("div", { className: "mess
|
|
|
561
564
|
C(!1);
|
|
562
565
|
}
|
|
563
566
|
}
|
|
564
|
-
},
|
|
567
|
+
}, O = async () => {
|
|
565
568
|
var k, D, h;
|
|
566
|
-
if (!(
|
|
569
|
+
if (!(b || !r)) {
|
|
567
570
|
o && console.log("[ChannelInfoDialog] Block member", (k = n == null ? void 0 : n.user) == null ? void 0 : k.id), y(!0);
|
|
568
571
|
try {
|
|
569
572
|
await r.blockUser((D = n == null ? void 0 : n.user) == null ? void 0 : D.id), d && await d((h = n == null ? void 0 : n.user) == null ? void 0 : h.id), s();
|
|
570
|
-
} catch (
|
|
571
|
-
console.error("[ChannelInfoDialog] Failed to block member",
|
|
573
|
+
} catch (U) {
|
|
574
|
+
console.error("[ChannelInfoDialog] Failed to block member", U);
|
|
572
575
|
} finally {
|
|
573
576
|
y(!1);
|
|
574
577
|
}
|
|
575
578
|
}
|
|
576
579
|
}, E = async () => {
|
|
577
580
|
var k, D, h;
|
|
578
|
-
if (!(
|
|
581
|
+
if (!(b || !r)) {
|
|
579
582
|
o && console.log("[ChannelInfoDialog] Unblock member", (k = n == null ? void 0 : n.user) == null ? void 0 : k.id), y(!0);
|
|
580
583
|
try {
|
|
581
584
|
await r.unBlockUser((D = n == null ? void 0 : n.user) == null ? void 0 : D.id), d && await d((h = n == null ? void 0 : n.user) == null ? void 0 : h.id), s();
|
|
582
|
-
} catch (
|
|
583
|
-
console.error("[ChannelInfoDialog] Failed to unblock member",
|
|
585
|
+
} catch (U) {
|
|
586
|
+
console.error("[ChannelInfoDialog] Failed to unblock member", U);
|
|
584
587
|
} finally {
|
|
585
588
|
y(!1);
|
|
586
589
|
}
|
|
@@ -599,11 +602,11 @@ const Oe = ({ renderActions: t }) => /* @__PURE__ */ i("div", { className: "mess
|
|
|
599
602
|
/* @__PURE__ */ e(
|
|
600
603
|
"dialog",
|
|
601
604
|
{
|
|
602
|
-
ref:
|
|
605
|
+
ref: w,
|
|
603
606
|
className: "mes-dialog",
|
|
604
607
|
onClose: s,
|
|
605
608
|
onClick: (k) => {
|
|
606
|
-
k.target ===
|
|
609
|
+
k.target === w.current && s();
|
|
607
610
|
},
|
|
608
611
|
children: /* @__PURE__ */ i("div", { className: "ml-auto flex h-full w-full flex-col bg-white shadow-max-elevation-light", children: [
|
|
609
612
|
/* @__PURE__ */ i("div", { className: "flex items-center justify-between border-b border-sand px-4 py-3", children: [
|
|
@@ -644,21 +647,21 @@ const Oe = ({ renderActions: t }) => /* @__PURE__ */ i("div", { className: "mess
|
|
|
644
647
|
X,
|
|
645
648
|
{
|
|
646
649
|
onClick: E,
|
|
647
|
-
disabled:
|
|
648
|
-
"aria-busy":
|
|
650
|
+
disabled: b,
|
|
651
|
+
"aria-busy": b,
|
|
649
652
|
children: [
|
|
650
|
-
|
|
653
|
+
b ? /* @__PURE__ */ e(Q, { className: "h-5 w-5 animate-spin" }) : /* @__PURE__ */ e(te, { className: "h-5 w-5" }),
|
|
651
654
|
/* @__PURE__ */ e("span", { children: "Unblock" })
|
|
652
655
|
]
|
|
653
656
|
}
|
|
654
657
|
) : /* @__PURE__ */ i(
|
|
655
658
|
X,
|
|
656
659
|
{
|
|
657
|
-
onClick:
|
|
658
|
-
disabled:
|
|
659
|
-
"aria-busy":
|
|
660
|
+
onClick: O,
|
|
661
|
+
disabled: b,
|
|
662
|
+
"aria-busy": b,
|
|
660
663
|
children: [
|
|
661
|
-
|
|
664
|
+
b ? /* @__PURE__ */ e(Q, { className: "h-5 w-5 animate-spin" }) : /* @__PURE__ */ e(te, { className: "h-5 w-5" }),
|
|
662
665
|
/* @__PURE__ */ e("span", { children: "Block" })
|
|
663
666
|
]
|
|
664
667
|
}
|
|
@@ -673,7 +676,7 @@ const Oe = ({ renderActions: t }) => /* @__PURE__ */ i("div", { className: "mess
|
|
|
673
676
|
}
|
|
674
677
|
)
|
|
675
678
|
);
|
|
676
|
-
},
|
|
679
|
+
}, Me = ({
|
|
677
680
|
channel: t,
|
|
678
681
|
onBack: s,
|
|
679
682
|
showBackButton: n = !1,
|
|
@@ -682,7 +685,7 @@ const Oe = ({ renderActions: t }) => /* @__PURE__ */ i("div", { className: "mess
|
|
|
682
685
|
onBlockParticipant: m,
|
|
683
686
|
className: d
|
|
684
687
|
}) => {
|
|
685
|
-
const [r, o] =
|
|
688
|
+
const [r, o] = v(!1), w = $.useMemo(() => Object.values(t.state.members || {}).find(
|
|
686
689
|
(c) => {
|
|
687
690
|
var C;
|
|
688
691
|
return ((C = c.user) == null ? void 0 : C.id) && c.user.id !== t._client.userID;
|
|
@@ -691,31 +694,31 @@ const Oe = ({ renderActions: t }) => /* @__PURE__ */ i("div", { className: "mess
|
|
|
691
694
|
const g = t.data ?? {};
|
|
692
695
|
return g.followerStatus ? String(g.followerStatus) : g.isFollower ? "Subscribed to you" : void 0;
|
|
693
696
|
}, [t.data]);
|
|
694
|
-
return /* @__PURE__ */ i("div", { className:
|
|
697
|
+
return /* @__PURE__ */ i("div", { className: F("h-full flex flex-col", d), children: [
|
|
695
698
|
/* @__PURE__ */ e(Ne, { channel: t, children: /* @__PURE__ */ i(Ce, { children: [
|
|
696
699
|
/* @__PURE__ */ e("div", { className: "border-b border-sand bg-white px-4 py-3", children: /* @__PURE__ */ e(
|
|
697
|
-
|
|
700
|
+
Le,
|
|
698
701
|
{
|
|
699
702
|
onBack: s,
|
|
700
703
|
showBackButton: n,
|
|
701
704
|
onShowInfo: () => o(!0),
|
|
702
|
-
canShowInfo: !!
|
|
705
|
+
canShowInfo: !!w
|
|
703
706
|
}
|
|
704
707
|
) }),
|
|
705
708
|
/* @__PURE__ */ e("div", { className: "flex-1 overflow-hidden", children: /* @__PURE__ */ e(be, { hideDeletedMessages: !0, hideNewMessageSeparator: !1 }) }),
|
|
706
709
|
/* @__PURE__ */ e(
|
|
707
|
-
|
|
710
|
+
Ue,
|
|
708
711
|
{
|
|
709
712
|
renderActions: () => l == null ? void 0 : l(t)
|
|
710
713
|
}
|
|
711
714
|
)
|
|
712
715
|
] }) }),
|
|
713
716
|
/* @__PURE__ */ e(
|
|
714
|
-
|
|
717
|
+
Fe,
|
|
715
718
|
{
|
|
716
719
|
isOpen: r,
|
|
717
720
|
onClose: () => o(!1),
|
|
718
|
-
participant:
|
|
721
|
+
participant: w,
|
|
719
722
|
channel: t,
|
|
720
723
|
followerStatusLabel: x,
|
|
721
724
|
onLeaveConversation: a,
|
|
@@ -724,7 +727,7 @@ const Oe = ({ renderActions: t }) => /* @__PURE__ */ i("div", { className: "mess
|
|
|
724
727
|
)
|
|
725
728
|
] });
|
|
726
729
|
};
|
|
727
|
-
function
|
|
730
|
+
function pe({
|
|
728
731
|
searchQuery: t,
|
|
729
732
|
setSearchQuery: s,
|
|
730
733
|
placeholder: n
|
|
@@ -772,9 +775,9 @@ const je = ({
|
|
|
772
775
|
searchPlaceholder: m = "Search participants...",
|
|
773
776
|
className: d
|
|
774
777
|
}) => {
|
|
775
|
-
const { debug: r } = Z(), [o,
|
|
778
|
+
const { debug: r } = Z(), [o, w] = v(""), [x, g] = v([]), [c, C] = v(!1), [b, y] = v(null), [I, P] = v(
|
|
776
779
|
null
|
|
777
|
-
),
|
|
780
|
+
), O = A(!1);
|
|
778
781
|
B(() => {
|
|
779
782
|
if (t.loading) {
|
|
780
783
|
r && console.log(
|
|
@@ -782,7 +785,7 @@ const je = ({
|
|
|
782
785
|
);
|
|
783
786
|
return;
|
|
784
787
|
}
|
|
785
|
-
if (
|
|
788
|
+
if (O.current) return;
|
|
786
789
|
(async () => {
|
|
787
790
|
r && console.log("[ParticipantPicker] Loading initial participants..."), C(!0), y(null);
|
|
788
791
|
try {
|
|
@@ -791,7 +794,7 @@ const je = ({
|
|
|
791
794
|
// Load all participants initially
|
|
792
795
|
limit: 100
|
|
793
796
|
});
|
|
794
|
-
g(f.participants),
|
|
797
|
+
g(f.participants), O.current = !0, r && console.log(
|
|
795
798
|
"[ParticipantPicker] Participants loaded successfully:",
|
|
796
799
|
f.participants.length
|
|
797
800
|
);
|
|
@@ -808,7 +811,7 @@ const je = ({
|
|
|
808
811
|
if (!o) return !0;
|
|
809
812
|
const f = o.toLowerCase();
|
|
810
813
|
return u.name.toLowerCase().includes(f) || ((N = u.email) == null ? void 0 : N.toLowerCase().includes(f)) || !1;
|
|
811
|
-
}), R =
|
|
814
|
+
}), R = L(
|
|
812
815
|
async (u) => {
|
|
813
816
|
if (!I) {
|
|
814
817
|
P(u.id);
|
|
@@ -823,7 +826,7 @@ const je = ({
|
|
|
823
826
|
), T = (u, f) => {
|
|
824
827
|
(u.key === "Enter" || u.key === " ") && (u.preventDefault(), R(f));
|
|
825
828
|
};
|
|
826
|
-
return /* @__PURE__ */ i("div", { className:
|
|
829
|
+
return /* @__PURE__ */ i("div", { className: F("flex flex-col h-full", d), children: [
|
|
827
830
|
/* @__PURE__ */ i("div", { className: "px-4 py-4 border-b border-sand bg-chalk", children: [
|
|
828
831
|
/* @__PURE__ */ i("div", { className: "flex items-center justify-between mb-3", children: [
|
|
829
832
|
/* @__PURE__ */ e("h2", { className: "text-lg font-semibold text-charcoal", children: "Start a new Conversation" }),
|
|
@@ -838,19 +841,19 @@ const je = ({
|
|
|
838
841
|
t.totalCount !== void 0 && ` • ${t.totalCount} ${a} total`
|
|
839
842
|
] }),
|
|
840
843
|
/* @__PURE__ */ e(
|
|
841
|
-
|
|
844
|
+
pe,
|
|
842
845
|
{
|
|
843
846
|
searchQuery: o,
|
|
844
|
-
setSearchQuery:
|
|
847
|
+
setSearchQuery: w,
|
|
845
848
|
placeholder: m
|
|
846
849
|
}
|
|
847
850
|
)
|
|
848
851
|
] }),
|
|
849
|
-
|
|
852
|
+
b && /* @__PURE__ */ i("div", { className: "p-4 text-sm text-danger bg-danger-alt", children: [
|
|
850
853
|
"Error loading ",
|
|
851
854
|
a,
|
|
852
855
|
": ",
|
|
853
|
-
|
|
856
|
+
b
|
|
854
857
|
] }),
|
|
855
858
|
/* @__PURE__ */ e("div", { className: "flex-1 overflow-auto", children: c && E.length === 0 ? /* @__PURE__ */ e("div", { className: "h-32 flex items-center justify-center", children: /* @__PURE__ */ i("div", { className: "flex items-center space-x-2", children: [
|
|
856
859
|
/* @__PURE__ */ e("div", { className: "w-4 h-4 animate-spin rounded-full border-2 border-primary border-t-transparent" }),
|
|
@@ -946,7 +949,7 @@ const je = ({
|
|
|
946
949
|
] }) }), Be = ({ className: t, message: s }) => /* @__PURE__ */ i(
|
|
947
950
|
"div",
|
|
948
951
|
{
|
|
949
|
-
className:
|
|
952
|
+
className: F("flex items-center justify-center h-full", t),
|
|
950
953
|
children: [
|
|
951
954
|
/* @__PURE__ */ i("svg", { viewBox: "0 0 100 100", className: "size-8 fill-pebble", stroke: "none", children: [
|
|
952
955
|
/* @__PURE__ */ e("circle", { cx: "6", cy: "50", r: "6", children: /* @__PURE__ */ e(
|
|
@@ -1001,109 +1004,109 @@ const je = ({
|
|
|
1001
1004
|
client: d,
|
|
1002
1005
|
isConnected: r,
|
|
1003
1006
|
isLoading: o,
|
|
1004
|
-
error:
|
|
1007
|
+
error: w,
|
|
1005
1008
|
refreshConnection: x,
|
|
1006
1009
|
debug: g
|
|
1007
|
-
} = Pe(), [c, C] =
|
|
1010
|
+
} = Pe(), [c, C] = v(null), [b, y] = v(!1), [I, P] = v(!1), [O, E] = v(/* @__PURE__ */ new Set()), [R, T] = v(0), u = A(null), {
|
|
1008
1011
|
showStartConversation: f = !1,
|
|
1009
1012
|
participantSource: N,
|
|
1010
1013
|
participantLabel: S = "participants"
|
|
1011
|
-
} = t, j = A(null),
|
|
1014
|
+
} = t, j = A(null), M = L(async () => {
|
|
1012
1015
|
if (!d || !r) return;
|
|
1013
1016
|
const h = d.userID;
|
|
1014
1017
|
if (h)
|
|
1015
1018
|
try {
|
|
1016
1019
|
g && console.log("[MessagingShell] Syncing channels for user:", h);
|
|
1017
|
-
const
|
|
1020
|
+
const U = await d.queryChannels(
|
|
1018
1021
|
{
|
|
1019
1022
|
type: "messaging",
|
|
1020
1023
|
members: { $in: [h] }
|
|
1021
1024
|
},
|
|
1022
1025
|
{},
|
|
1023
1026
|
{ limit: 100 }
|
|
1024
|
-
),
|
|
1025
|
-
|
|
1027
|
+
), p = /* @__PURE__ */ new Set();
|
|
1028
|
+
U.forEach((J) => {
|
|
1026
1029
|
const ce = J.state.members;
|
|
1027
1030
|
Object.values(ce).forEach((de) => {
|
|
1028
1031
|
var ee;
|
|
1029
1032
|
const K = (ee = de.user) == null ? void 0 : ee.id;
|
|
1030
|
-
K && K !== h &&
|
|
1033
|
+
K && K !== h && p.add(K);
|
|
1031
1034
|
});
|
|
1032
|
-
}), E(
|
|
1033
|
-
channelCount:
|
|
1034
|
-
memberCount:
|
|
1035
|
+
}), E(p), y(U.length > 0), j.current = h, g && console.log("[MessagingShell] Channels synced successfully:", {
|
|
1036
|
+
channelCount: U.length,
|
|
1037
|
+
memberCount: p.size
|
|
1035
1038
|
});
|
|
1036
|
-
} catch (
|
|
1037
|
-
console.error("[MessagingShell] Failed to sync channels:",
|
|
1039
|
+
} catch (U) {
|
|
1040
|
+
console.error("[MessagingShell] Failed to sync channels:", U);
|
|
1038
1041
|
}
|
|
1039
1042
|
}, [d, r, g]);
|
|
1040
1043
|
B(() => {
|
|
1041
1044
|
if (!d || !r) return;
|
|
1042
1045
|
const h = d.userID;
|
|
1043
|
-
h && j.current !== h &&
|
|
1044
|
-
}, [d, r,
|
|
1045
|
-
const H =
|
|
1046
|
+
h && j.current !== h && M();
|
|
1047
|
+
}, [d, r, M]);
|
|
1048
|
+
const H = L(
|
|
1046
1049
|
(h) => {
|
|
1047
1050
|
C(h), l == null || l(h);
|
|
1048
1051
|
},
|
|
1049
1052
|
[l]
|
|
1050
|
-
), V =
|
|
1053
|
+
), V = L(() => {
|
|
1051
1054
|
C(null);
|
|
1052
|
-
}, []), _ =
|
|
1055
|
+
}, []), _ = L(() => {
|
|
1053
1056
|
var h;
|
|
1054
|
-
N && (T((
|
|
1055
|
-
}, [N]), W =
|
|
1057
|
+
N && (T((U) => U + 1), P(!0), (h = u.current) == null || h.showModal());
|
|
1058
|
+
}, [N]), W = L(
|
|
1056
1059
|
async (h) => {
|
|
1057
|
-
var
|
|
1060
|
+
var U;
|
|
1058
1061
|
if (m)
|
|
1059
1062
|
try {
|
|
1060
1063
|
g && console.log(
|
|
1061
1064
|
"[MessagingShell] Starting conversation with:",
|
|
1062
1065
|
h.id
|
|
1063
1066
|
);
|
|
1064
|
-
const
|
|
1067
|
+
const p = await m.startChannelWithParticipant({
|
|
1065
1068
|
id: h.id,
|
|
1066
1069
|
name: h.name,
|
|
1067
1070
|
email: h.email,
|
|
1068
1071
|
phone: h.phone
|
|
1069
1072
|
});
|
|
1070
1073
|
try {
|
|
1071
|
-
await
|
|
1074
|
+
await p.show();
|
|
1072
1075
|
} catch (J) {
|
|
1073
1076
|
console.warn("[MessagingShell] Failed to unhide channel:", J);
|
|
1074
1077
|
}
|
|
1075
|
-
C(
|
|
1076
|
-
} catch (
|
|
1077
|
-
console.error("[MessagingShell] Failed to start conversation:",
|
|
1078
|
+
C(p), P(!1), (U = u.current) == null || U.close(), a == null || a(h);
|
|
1079
|
+
} catch (p) {
|
|
1080
|
+
console.error("[MessagingShell] Failed to start conversation:", p);
|
|
1078
1081
|
}
|
|
1079
1082
|
},
|
|
1080
1083
|
[m, a, g]
|
|
1081
|
-
), G =
|
|
1084
|
+
), G = L(() => {
|
|
1082
1085
|
var h;
|
|
1083
1086
|
P(!1), (h = u.current) == null || h.close();
|
|
1084
|
-
}, []), z =
|
|
1087
|
+
}, []), z = L(
|
|
1085
1088
|
async (h) => {
|
|
1086
|
-
g && console.log("[MessagingShell] Leaving conversation:", h.id), C(null), j.current = null, await
|
|
1089
|
+
g && console.log("[MessagingShell] Leaving conversation:", h.id), C(null), j.current = null, await M();
|
|
1087
1090
|
},
|
|
1088
|
-
[
|
|
1089
|
-
), k =
|
|
1091
|
+
[M, g]
|
|
1092
|
+
), k = L(
|
|
1090
1093
|
async (h) => {
|
|
1091
|
-
g && console.log("[MessagingShell] Blocking participant:", h), C(null), j.current = null, await
|
|
1094
|
+
g && console.log("[MessagingShell] Blocking participant:", h), C(null), j.current = null, await M();
|
|
1092
1095
|
},
|
|
1093
|
-
[
|
|
1096
|
+
[M, g]
|
|
1094
1097
|
), D = !!c;
|
|
1095
|
-
return o ? /* @__PURE__ */ e("div", { className:
|
|
1098
|
+
return o ? /* @__PURE__ */ e("div", { className: F("h-full", s), children: /* @__PURE__ */ e(He, {}) }) : w ? /* @__PURE__ */ e("div", { className: F("h-full", s), children: /* @__PURE__ */ e(le, { error: w, onRetry: x }) }) : !r || !d ? /* @__PURE__ */ e("div", { className: F("h-full", s), children: /* @__PURE__ */ e(
|
|
1096
1099
|
le,
|
|
1097
1100
|
{
|
|
1098
1101
|
error: "Not connected to messaging service",
|
|
1099
1102
|
onRetry: x
|
|
1100
1103
|
}
|
|
1101
|
-
) }) : /* @__PURE__ */ i("div", { className:
|
|
1104
|
+
) }) : /* @__PURE__ */ i("div", { className: F("h-full bg-white overflow-hidden", s), children: [
|
|
1102
1105
|
/* @__PURE__ */ i("div", { className: "flex h-full min-h-0", children: [
|
|
1103
1106
|
/* @__PURE__ */ e(
|
|
1104
1107
|
"div",
|
|
1105
1108
|
{
|
|
1106
|
-
className:
|
|
1109
|
+
className: F(
|
|
1107
1110
|
"min-h-0 min-w-0 bg-white lg:bg-chalk lg:flex lg:flex-col lg:border-r lg:border-sand",
|
|
1108
1111
|
{
|
|
1109
1112
|
"hidden lg:flex lg:w-80 lg:min-w-[280px] lg:max-w-[360px]": D,
|
|
@@ -1111,7 +1114,7 @@ const je = ({
|
|
|
1111
1114
|
}
|
|
1112
1115
|
),
|
|
1113
1116
|
children: /* @__PURE__ */ e(
|
|
1114
|
-
|
|
1117
|
+
Oe,
|
|
1115
1118
|
{
|
|
1116
1119
|
onChannelSelect: H,
|
|
1117
1120
|
selectedChannel: c || void 0,
|
|
@@ -1125,12 +1128,12 @@ const je = ({
|
|
|
1125
1128
|
/* @__PURE__ */ e(
|
|
1126
1129
|
"div",
|
|
1127
1130
|
{
|
|
1128
|
-
className:
|
|
1131
|
+
className: F("flex-1 flex-col min-w-0 min-h-0", {
|
|
1129
1132
|
"hidden lg:flex": !D,
|
|
1130
1133
|
flex: D
|
|
1131
1134
|
}),
|
|
1132
1135
|
children: c ? /* @__PURE__ */ e("div", { className: "flex-1 min-h-0 flex flex-col", children: /* @__PURE__ */ e(
|
|
1133
|
-
|
|
1136
|
+
Me,
|
|
1134
1137
|
{
|
|
1135
1138
|
channel: c,
|
|
1136
1139
|
onBack: V,
|
|
@@ -1143,7 +1146,7 @@ const je = ({
|
|
|
1143
1146
|
) }) : /* @__PURE__ */ e(
|
|
1144
1147
|
Ae,
|
|
1145
1148
|
{
|
|
1146
|
-
hasChannels:
|
|
1149
|
+
hasChannels: b,
|
|
1147
1150
|
onStartConversation: f ? _ : void 0,
|
|
1148
1151
|
participantLabel: S
|
|
1149
1152
|
}
|
|
@@ -1167,7 +1170,7 @@ const je = ({
|
|
|
1167
1170
|
participantSource: N,
|
|
1168
1171
|
onSelectParticipant: W,
|
|
1169
1172
|
onClose: G,
|
|
1170
|
-
existingParticipantIds:
|
|
1173
|
+
existingParticipantIds: O,
|
|
1171
1174
|
participantLabel: S,
|
|
1172
1175
|
searchPlaceholder: `Search ${S}...`
|
|
1173
1176
|
},
|
|
@@ -1177,30 +1180,30 @@ const je = ({
|
|
|
1177
1180
|
)
|
|
1178
1181
|
] });
|
|
1179
1182
|
}, Ze = (t, s = {}) => {
|
|
1180
|
-
const { initialSearch: n = "", pageSize: l = 20 } = s, [a, m] =
|
|
1183
|
+
const { initialSearch: n = "", pageSize: l = 20 } = s, [a, m] = v([]), [d, r] = v(!1), [o, w] = v(null), [x, g] = v(n), [c, C] = v(!0), [b, y] = v(), I = L(async (R = !1, T) => {
|
|
1181
1184
|
if (d) return;
|
|
1182
1185
|
const u = T !== void 0 ? T : x;
|
|
1183
|
-
r(!0),
|
|
1186
|
+
r(!0), w(null);
|
|
1184
1187
|
try {
|
|
1185
1188
|
const f = await t.loadParticipants({
|
|
1186
1189
|
search: u || void 0,
|
|
1187
1190
|
limit: l,
|
|
1188
|
-
cursor: R ? void 0 :
|
|
1191
|
+
cursor: R ? void 0 : b
|
|
1189
1192
|
});
|
|
1190
1193
|
m(
|
|
1191
1194
|
(N) => R ? f.participants : [...N, ...f.participants]
|
|
1192
1195
|
), C(f.hasMore), y(f.nextCursor);
|
|
1193
1196
|
} catch (f) {
|
|
1194
1197
|
const N = f instanceof Error ? f.message : "Failed to load participants";
|
|
1195
|
-
|
|
1198
|
+
w(N), console.error("[useParticipants] Load error:", f);
|
|
1196
1199
|
} finally {
|
|
1197
1200
|
r(!1);
|
|
1198
1201
|
}
|
|
1199
|
-
}, [t, x,
|
|
1202
|
+
}, [t, x, b, l, d]), P = L(() => {
|
|
1200
1203
|
c && !d && I(!1);
|
|
1201
|
-
}, [c, d, I]),
|
|
1204
|
+
}, [c, d, I]), O = L((R) => {
|
|
1202
1205
|
g(R), y(void 0), I(!0, R);
|
|
1203
|
-
}, [I]), E =
|
|
1206
|
+
}, [I]), E = L(() => {
|
|
1204
1207
|
y(void 0), I(!0);
|
|
1205
1208
|
}, [I]);
|
|
1206
1209
|
return B(() => {
|
|
@@ -1213,14 +1216,14 @@ const je = ({
|
|
|
1213
1216
|
hasMore: c,
|
|
1214
1217
|
totalCount: t.totalCount,
|
|
1215
1218
|
loadMore: P,
|
|
1216
|
-
search:
|
|
1219
|
+
search: O,
|
|
1217
1220
|
refresh: E
|
|
1218
1221
|
};
|
|
1219
1222
|
};
|
|
1220
1223
|
export {
|
|
1221
1224
|
Y as Avatar,
|
|
1222
|
-
|
|
1223
|
-
|
|
1225
|
+
Oe as ChannelList,
|
|
1226
|
+
Me as ChannelView,
|
|
1224
1227
|
Xe as MessagingProvider,
|
|
1225
1228
|
Qe as MessagingShell,
|
|
1226
1229
|
je as ParticipantPicker,
|