@linktr.ee/messaging-react 1.12.8-rc-1766044676 โ 1.12.8-rc-1766045447
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 +261 -239
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/components/CustomMessageInput/index.tsx +34 -1
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as e, jsxs as i, Fragment as we } from "react/jsx-runtime";
|
|
2
2
|
import k from "classnames";
|
|
3
|
-
import
|
|
3
|
+
import U, { createContext as ye, useContext as Ee, useCallback as D, useState as y, useRef as z, useEffect as G } from "react";
|
|
4
4
|
import { StreamChatService as $e } from "@linktr.ee/messaging-core";
|
|
5
5
|
import { Chat as Ge, ChannelList as He, useMessageComposer as Ie, useStateStore as Ve, MessageInput as We, useMessageInputContext as Ze, useMessageComposerHasSendableData as qe, useChannelStateContext as ue, SimpleAttachmentSelector as Ye, QuotedMessagePreview as Je, AttachmentPreviewList as Qe, TextareaComposer as Xe, MessageTimestamp as Ke, Channel as es, Window as ss, MessageList as ts } from "stream-chat-react";
|
|
6
6
|
import { XIcon as oe, ArrowUpIcon as ns, ArrowLeftIcon as ge, DotsThreeIcon as xe, SpinnerGapIcon as re, SignOutIcon as rs, ProhibitInsetIcon as be, FlagIcon as ls, MagnifyingGlassIcon as as, ChatCircleDotsIcon as Ne } from "@phosphor-icons/react";
|
|
@@ -15,7 +15,7 @@ const Se = ye({
|
|
|
15
15
|
refreshConnection: async () => {
|
|
16
16
|
},
|
|
17
17
|
debug: !1
|
|
18
|
-
}), ie = () => Ee(Se),
|
|
18
|
+
}), ie = () => Ee(Se), Us = ({
|
|
19
19
|
children: t,
|
|
20
20
|
user: s,
|
|
21
21
|
serviceConfig: n,
|
|
@@ -23,9 +23,9 @@ const Se = ye({
|
|
|
23
23
|
capabilities: a = {},
|
|
24
24
|
debug: o = !1
|
|
25
25
|
}) => {
|
|
26
|
-
const l =
|
|
27
|
-
(
|
|
28
|
-
o && console.log(`๐ฅ [MessagingProvider] ${
|
|
26
|
+
const l = D(
|
|
27
|
+
(m, ...x) => {
|
|
28
|
+
o && console.log(`๐ฅ [MessagingProvider] ${m}`, ...x);
|
|
29
29
|
},
|
|
30
30
|
[o]
|
|
31
31
|
);
|
|
@@ -35,7 +35,7 @@ const Se = ye({
|
|
|
35
35
|
serviceConfig: !!n,
|
|
36
36
|
capabilities: Object.keys(a)
|
|
37
37
|
});
|
|
38
|
-
const [h, f] = y(null), [g,
|
|
38
|
+
const [h, f] = y(null), [g, N] = y(null), [c, E] = y(!1), [R, I] = y(!1), [w, C] = y(null), u = z(!1), b = z({
|
|
39
39
|
userId: s == null ? void 0 : s.id,
|
|
40
40
|
apiKey: r,
|
|
41
41
|
serviceConfig: n,
|
|
@@ -56,9 +56,9 @@ const Se = ye({
|
|
|
56
56
|
serviceConfig: n,
|
|
57
57
|
capabilities: a
|
|
58
58
|
}, G(() => {
|
|
59
|
-
const
|
|
59
|
+
const m = S.current;
|
|
60
60
|
if (l("๐ง SERVICE INIT EFFECT TRIGGERED", {
|
|
61
|
-
renderCount:
|
|
61
|
+
renderCount: m,
|
|
62
62
|
apiKey: !!r,
|
|
63
63
|
serviceConfig: !!n,
|
|
64
64
|
dependencies: {
|
|
@@ -69,13 +69,13 @@ const Se = ye({
|
|
|
69
69
|
}
|
|
70
70
|
}), !r || !n) {
|
|
71
71
|
l("โ ๏ธ SERVICE INIT SKIPPED", {
|
|
72
|
-
renderCount:
|
|
72
|
+
renderCount: m,
|
|
73
73
|
reason: "Missing apiKey or serviceConfig"
|
|
74
74
|
});
|
|
75
75
|
return;
|
|
76
76
|
}
|
|
77
77
|
l("๐ CREATING NEW SERVICE", {
|
|
78
|
-
renderCount:
|
|
78
|
+
renderCount: m,
|
|
79
79
|
apiKey: (r == null ? void 0 : r.substring(0, 8)) + "...",
|
|
80
80
|
serviceConfigChanged: b.current.serviceConfig !== n
|
|
81
81
|
});
|
|
@@ -85,11 +85,11 @@ const Se = ye({
|
|
|
85
85
|
debug: o
|
|
86
86
|
});
|
|
87
87
|
return f(x), l("โ
SERVICE SET", {
|
|
88
|
-
renderCount:
|
|
88
|
+
renderCount: m,
|
|
89
89
|
serviceInstance: !!x
|
|
90
90
|
}), () => {
|
|
91
91
|
l("๐งน SERVICE CLEANUP", {
|
|
92
|
-
renderCount:
|
|
92
|
+
renderCount: m,
|
|
93
93
|
reason: "Effect cleanup"
|
|
94
94
|
}), x.disconnectUser().catch(console.error);
|
|
95
95
|
};
|
|
@@ -102,7 +102,7 @@ const Se = ye({
|
|
|
102
102
|
hasUser: !!s,
|
|
103
103
|
userId: s == null ? void 0 : s.id,
|
|
104
104
|
isConnecting: u.current,
|
|
105
|
-
isConnected:
|
|
105
|
+
isConnected: c,
|
|
106
106
|
dependencies: { service: !!h, userId: s == null ? void 0 : s.id }
|
|
107
107
|
}), !h || !s) {
|
|
108
108
|
l("โ ๏ธ USER CONNECTION SKIPPED", "Missing service or user");
|
|
@@ -120,40 +120,40 @@ const Se = ye({
|
|
|
120
120
|
return;
|
|
121
121
|
}
|
|
122
122
|
(async () => {
|
|
123
|
-
l("๐ STARTING USER CONNECTION", { userId: s.id }), u.current = !0, I(!0),
|
|
123
|
+
l("๐ STARTING USER CONNECTION", { userId: s.id }), u.current = !0, I(!0), C(null);
|
|
124
124
|
try {
|
|
125
125
|
l("๐ CALLING SERVICE.CONNECTUSER", { userId: s.id });
|
|
126
126
|
const A = await h.connectUser(s);
|
|
127
|
-
|
|
127
|
+
N(A), E(!0), p.current = { serviceId: h, userId: s.id }, l("โ
USER CONNECTION SUCCESS", {
|
|
128
128
|
userId: s.id,
|
|
129
129
|
clientId: A.userID
|
|
130
130
|
});
|
|
131
131
|
} catch (A) {
|
|
132
132
|
const H = A instanceof Error ? A.message : "Connection failed";
|
|
133
|
-
|
|
133
|
+
C(H), l("โ USER CONNECTION ERROR", {
|
|
134
134
|
userId: s.id,
|
|
135
135
|
error: H
|
|
136
136
|
});
|
|
137
137
|
} finally {
|
|
138
138
|
I(!1), u.current = !1, l("๐ USER CONNECTION FINISHED", {
|
|
139
139
|
userId: s.id,
|
|
140
|
-
isConnected:
|
|
140
|
+
isConnected: c
|
|
141
141
|
});
|
|
142
142
|
}
|
|
143
143
|
})();
|
|
144
|
-
}, [h, s, l,
|
|
144
|
+
}, [h, s, l, c]), G(() => (l("๐ CLEANUP EFFECT REGISTERED", {
|
|
145
145
|
hasService: !!h,
|
|
146
|
-
isConnected:
|
|
146
|
+
isConnected: c
|
|
147
147
|
}), () => {
|
|
148
|
-
h &&
|
|
148
|
+
h && c ? (l(
|
|
149
149
|
"๐งน CLEANUP EFFECT TRIGGERED",
|
|
150
150
|
"Cleaning up connection on unmount"
|
|
151
151
|
), p.current = null, h.disconnectUser().catch(console.error)) : l("๐ CLEANUP EFFECT SKIPPED", {
|
|
152
152
|
hasService: !!h,
|
|
153
|
-
isConnected:
|
|
153
|
+
isConnected: c
|
|
154
154
|
});
|
|
155
|
-
}), [h,
|
|
156
|
-
const T =
|
|
155
|
+
}), [h, c, l]);
|
|
156
|
+
const T = D(async () => {
|
|
157
157
|
if (l("๐ REFRESH CONNECTION CALLED", {
|
|
158
158
|
hasService: !!h,
|
|
159
159
|
hasUser: !!s
|
|
@@ -164,28 +164,28 @@ const Se = ye({
|
|
|
164
164
|
l("๐ STARTING CONNECTION REFRESH", { userId: s.id }), I(!0);
|
|
165
165
|
try {
|
|
166
166
|
l("๐ DISCONNECTING FOR REFRESH"), await h.disconnectUser(), l("๐ RECONNECTING FOR REFRESH");
|
|
167
|
-
const
|
|
168
|
-
|
|
169
|
-
} catch (
|
|
170
|
-
const x =
|
|
171
|
-
|
|
167
|
+
const m = await h.connectUser(s);
|
|
168
|
+
N(m), E(!0), C(null), l("โ
CONNECTION REFRESH SUCCESS", { userId: s.id });
|
|
169
|
+
} catch (m) {
|
|
170
|
+
const x = m instanceof Error ? m.message : "Refresh failed";
|
|
171
|
+
C(x), l("โ CONNECTION REFRESH ERROR", {
|
|
172
172
|
userId: s.id,
|
|
173
173
|
error: x
|
|
174
174
|
});
|
|
175
175
|
} finally {
|
|
176
176
|
I(!1), l("๐ CONNECTION REFRESH FINISHED", { userId: s.id });
|
|
177
177
|
}
|
|
178
|
-
}, [h, s, l]),
|
|
178
|
+
}, [h, s, l]), d = U.useMemo(() => (l("๐ซ CONTEXT VALUE MEMOIZATION", {
|
|
179
179
|
hasService: !!h,
|
|
180
180
|
hasClient: !!g,
|
|
181
|
-
isConnected:
|
|
181
|
+
isConnected: c,
|
|
182
182
|
isLoading: R,
|
|
183
183
|
hasError: !!w,
|
|
184
184
|
capabilitiesKeys: Object.keys(a)
|
|
185
185
|
}), {
|
|
186
186
|
service: h,
|
|
187
187
|
client: g,
|
|
188
|
-
isConnected:
|
|
188
|
+
isConnected: c,
|
|
189
189
|
isLoading: R,
|
|
190
190
|
error: w,
|
|
191
191
|
capabilities: a,
|
|
@@ -194,7 +194,7 @@ const Se = ye({
|
|
|
194
194
|
}), [
|
|
195
195
|
h,
|
|
196
196
|
g,
|
|
197
|
-
|
|
197
|
+
c,
|
|
198
198
|
R,
|
|
199
199
|
w,
|
|
200
200
|
a,
|
|
@@ -204,9 +204,9 @@ const Se = ye({
|
|
|
204
204
|
]);
|
|
205
205
|
return l("๐ RENDER END", {
|
|
206
206
|
renderCount: S.current,
|
|
207
|
-
willRenderChat: !!(g &&
|
|
208
|
-
contextValueReady: !!
|
|
209
|
-
}), /* @__PURE__ */ e(Se.Provider, { value:
|
|
207
|
+
willRenderChat: !!(g && c),
|
|
208
|
+
contextValueReady: !!d
|
|
209
|
+
}), /* @__PURE__ */ e(Se.Provider, { value: d, children: g && c ? /* @__PURE__ */ e(
|
|
210
210
|
Ge,
|
|
211
211
|
{
|
|
212
212
|
client: g,
|
|
@@ -317,22 +317,22 @@ const Z = ({
|
|
|
317
317
|
)
|
|
318
318
|
}
|
|
319
319
|
);
|
|
320
|
-
}, pe =
|
|
320
|
+
}, pe = U.memo(
|
|
321
321
|
({ channel: t, selectedChannel: s, onChannelSelect: n, debug: r = !1, unread: a }) => {
|
|
322
|
-
var
|
|
322
|
+
var C, u, b, S, p, T;
|
|
323
323
|
const o = (s == null ? void 0 : s.id) === (t == null ? void 0 : t.id), l = () => {
|
|
324
324
|
t && n(t);
|
|
325
|
-
}, f = Object.values(((
|
|
326
|
-
(
|
|
327
|
-
var
|
|
328
|
-
return ((
|
|
325
|
+
}, f = Object.values(((C = t == null ? void 0 : t.state) == null ? void 0 : C.members) || {}).find(
|
|
326
|
+
(d) => {
|
|
327
|
+
var m, x;
|
|
328
|
+
return ((m = d.user) == null ? void 0 : m.id) && d.user.id !== ((x = t == null ? void 0 : t._client) == null ? void 0 : x.userID);
|
|
329
329
|
}
|
|
330
|
-
), g = ((u = f == null ? void 0 : f.user) == null ? void 0 : u.name) || "Conversation",
|
|
331
|
-
var
|
|
332
|
-
if (
|
|
333
|
-
const
|
|
334
|
-
return
|
|
335
|
-
})(), I =
|
|
330
|
+
), g = ((u = f == null ? void 0 : f.user) == null ? void 0 : u.name) || "Conversation", N = (b = f == null ? void 0 : f.user) == null ? void 0 : b.image, c = (p = (S = t == null ? void 0 : t.state) == null ? void 0 : S.messages) == null ? void 0 : p[t.state.messages.length - 1], R = (() => {
|
|
331
|
+
var m;
|
|
332
|
+
if (c != null && c.text) return c.text;
|
|
333
|
+
const d = (m = c == null ? void 0 : c.attachments) == null ? void 0 : m[0];
|
|
334
|
+
return d ? d.og_scrape_url ? d.og_scrape_url : d.type === "image" ? "๐ท Sent an image" : d.type === "video" ? "๐ฅ Sent a video" : d.type === "audio" ? "๐ต Sent audio" : d.type === "file" ? "๐ Sent a file" : "๐ Sent an attachment" : "No messages yet";
|
|
335
|
+
})(), I = c != null && c.created_at ? cs(new Date(c.created_at)) : "", w = a ?? 0;
|
|
336
336
|
return r && console.log("๐บ [ChannelList] ๐ CHANNEL PREVIEW RENDER", {
|
|
337
337
|
channelId: t == null ? void 0 : t.id,
|
|
338
338
|
isSelected: o,
|
|
@@ -357,7 +357,7 @@ const Z = ({
|
|
|
357
357
|
{
|
|
358
358
|
id: ((T = f == null ? void 0 : f.user) == null ? void 0 : T.id) || t.id || "unknown",
|
|
359
359
|
name: g,
|
|
360
|
-
image:
|
|
360
|
+
image: N,
|
|
361
361
|
size: 44,
|
|
362
362
|
className: "[&_.avatar-fallback]:group-hover:bg-[#eeeeee]"
|
|
363
363
|
}
|
|
@@ -387,7 +387,7 @@ const Z = ({
|
|
|
387
387
|
}
|
|
388
388
|
);
|
|
389
389
|
pe.displayName = "CustomChannelPreview";
|
|
390
|
-
const ke =
|
|
390
|
+
const ke = U.memo(
|
|
391
391
|
({
|
|
392
392
|
onChannelSelect: t,
|
|
393
393
|
selectedChannel: s,
|
|
@@ -395,7 +395,7 @@ const ke = P.memo(
|
|
|
395
395
|
className: r,
|
|
396
396
|
customEmptyStateIndicator: a
|
|
397
397
|
}) => {
|
|
398
|
-
const o =
|
|
398
|
+
const o = U.useRef(0);
|
|
399
399
|
o.current++;
|
|
400
400
|
const { debug: l = !1 } = ie();
|
|
401
401
|
l && console.log("๐บ [ChannelList] ๐ RENDER START", {
|
|
@@ -403,7 +403,7 @@ const ke = P.memo(
|
|
|
403
403
|
selectedChannelId: s == null ? void 0 : s.id,
|
|
404
404
|
filters: n
|
|
405
405
|
});
|
|
406
|
-
const h =
|
|
406
|
+
const h = U.useMemo(() => (g) => /* @__PURE__ */ e(
|
|
407
407
|
pe,
|
|
408
408
|
{
|
|
409
409
|
...g,
|
|
@@ -474,7 +474,7 @@ function Re({ label: t, className: s, children: n, ...r }) {
|
|
|
474
474
|
}
|
|
475
475
|
);
|
|
476
476
|
}
|
|
477
|
-
function
|
|
477
|
+
function De({ onClick: t }) {
|
|
478
478
|
return /* @__PURE__ */ e(Re, { label: "Close", onClick: t, className: "p-1", children: /* @__PURE__ */ e(oe, { className: "h-5 w-5 text-stone", weight: "bold" }) });
|
|
479
479
|
}
|
|
480
480
|
const us = (t) => ({
|
|
@@ -536,7 +536,7 @@ const us = (t) => ({
|
|
|
536
536
|
},
|
|
537
537
|
a.og_scrape_url
|
|
538
538
|
)) }) : null;
|
|
539
|
-
},
|
|
539
|
+
}, _e = ye(
|
|
540
540
|
{}
|
|
541
541
|
), gs = ({ attachment: t, onRemove: s }) => /* @__PURE__ */ i("div", { className: "relative w-full block rounded-[24px] bg-[#121110] p-2 mb-4", children: [
|
|
542
542
|
t.thumb_url && /* @__PURE__ */ e(
|
|
@@ -563,22 +563,44 @@ const us = (t) => ({
|
|
|
563
563
|
] })
|
|
564
564
|
] }), xs = () => {
|
|
565
565
|
const { handleSubmit: t } = Ze(), s = qe(), { channel: n } = ue(), r = Ie(), { pendingAttachment: a, onClearPendingAttachment: o } = Ee(
|
|
566
|
-
|
|
567
|
-
), l = s || !!a, h =
|
|
568
|
-
|
|
569
|
-
|
|
566
|
+
_e
|
|
567
|
+
), l = s || !!a, h = D(
|
|
568
|
+
(g) => {
|
|
569
|
+
g.key === "Enter" && !g.shiftKey && a && (g.preventDefault(), g.stopPropagation(), (async () => {
|
|
570
|
+
var N;
|
|
571
|
+
if (a && n)
|
|
572
|
+
try {
|
|
573
|
+
const c = ((N = r.textComposer.text) == null ? void 0 : N.trim()) || "";
|
|
574
|
+
await n.sendMessage({
|
|
575
|
+
text: c,
|
|
576
|
+
attachments: [a]
|
|
577
|
+
}), r.textComposer.setText(""), o == null || o();
|
|
578
|
+
} catch (c) {
|
|
579
|
+
console.error("Failed to send message with attachment:", c);
|
|
580
|
+
}
|
|
581
|
+
})());
|
|
582
|
+
},
|
|
583
|
+
[
|
|
584
|
+
n,
|
|
585
|
+
r.textComposer,
|
|
586
|
+
o,
|
|
587
|
+
a
|
|
588
|
+
]
|
|
589
|
+
), f = D(
|
|
590
|
+
async (g) => {
|
|
591
|
+
var N;
|
|
570
592
|
if (a && n)
|
|
571
593
|
try {
|
|
572
|
-
const
|
|
594
|
+
const c = ((N = r.textComposer.text) == null ? void 0 : N.trim()) || "";
|
|
573
595
|
await n.sendMessage({
|
|
574
|
-
text:
|
|
596
|
+
text: c,
|
|
575
597
|
attachments: [a]
|
|
576
598
|
}), r.textComposer.setText(""), o == null || o();
|
|
577
|
-
} catch (
|
|
578
|
-
console.error("Failed to send message with attachment:",
|
|
599
|
+
} catch (c) {
|
|
600
|
+
console.error("Failed to send message with attachment:", c);
|
|
579
601
|
}
|
|
580
602
|
else
|
|
581
|
-
await t(
|
|
603
|
+
await t(g);
|
|
582
604
|
},
|
|
583
605
|
[
|
|
584
606
|
n,
|
|
@@ -601,7 +623,7 @@ const us = (t) => ({
|
|
|
601
623
|
onRemove: o
|
|
602
624
|
}
|
|
603
625
|
),
|
|
604
|
-
/* @__PURE__ */ i("div", { className: "flex", children: [
|
|
626
|
+
/* @__PURE__ */ i("div", { className: "flex", onKeyDown: h, children: [
|
|
605
627
|
/* @__PURE__ */ e("div", { className: "w-full ml-2 mr-4 self-center leading-[0]", children: /* @__PURE__ */ e(
|
|
606
628
|
Xe,
|
|
607
629
|
{
|
|
@@ -616,7 +638,7 @@ const us = (t) => ({
|
|
|
616
638
|
className: "str-chat__send-button mt-auto flex justify-center items-center flex-shrink-0 rounded-full size-8 bg-[#121110] disabled:bg-[#F1F0EE] disabled:text-black/20 text-white",
|
|
617
639
|
"data-testid": "send-button",
|
|
618
640
|
disabled: !l,
|
|
619
|
-
onClick:
|
|
641
|
+
onClick: f,
|
|
620
642
|
type: "button",
|
|
621
643
|
children: /* @__PURE__ */ e(ns, { className: "size-4" })
|
|
622
644
|
}
|
|
@@ -629,7 +651,7 @@ const us = (t) => ({
|
|
|
629
651
|
pendingAttachment: s,
|
|
630
652
|
onClearPendingAttachment: n
|
|
631
653
|
}) => /* @__PURE__ */ e(
|
|
632
|
-
|
|
654
|
+
_e.Provider,
|
|
633
655
|
{
|
|
634
656
|
value: { pendingAttachment: s, onClearPendingAttachment: n },
|
|
635
657
|
children: /* @__PURE__ */ i("div", { className: "message-input flex items-center gap-2 p-4", children: [
|
|
@@ -690,19 +712,19 @@ const us = (t) => ({
|
|
|
690
712
|
s && /* @__PURE__ */ e("span", { className: "text-stone", children: s })
|
|
691
713
|
]
|
|
692
714
|
}
|
|
693
|
-
), ae =
|
|
715
|
+
), ae = U.memo(() => /* @__PURE__ */ e("div", { className: "messaging-loading-state flex items-center justify-center h-full", children: /* @__PURE__ */ i("div", { className: "flex items-center", children: [
|
|
694
716
|
/* @__PURE__ */ e(vs, { className: "w-6 h-6" }),
|
|
695
717
|
/* @__PURE__ */ e("span", { className: "text-sm text-stone", children: "Loading messages" })
|
|
696
718
|
] }) }));
|
|
697
719
|
ae.displayName = "LoadingState";
|
|
698
720
|
const ws = ({ onBack: t, showBackButton: s, onShowInfo: n, canShowInfo: r }) => {
|
|
699
|
-
var f, g,
|
|
700
|
-
const { channel: a } = ue(), o =
|
|
721
|
+
var f, g, N, c, E;
|
|
722
|
+
const { channel: a } = ue(), o = U.useMemo(() => Object.values(a.state.members || {}).find(
|
|
701
723
|
(I) => {
|
|
702
724
|
var w;
|
|
703
725
|
return ((w = I.user) == null ? void 0 : w.id) && I.user.id !== a._client.userID;
|
|
704
726
|
}
|
|
705
|
-
), [a._client.userID, a.state.members]), l = ((f = o == null ? void 0 : o.user) == null ? void 0 : f.name) || ((g = o == null ? void 0 : o.user) == null ? void 0 : g.id) || "Unknown member", h = (
|
|
727
|
+
), [a._client.userID, a.state.members]), l = ((f = o == null ? void 0 : o.user) == null ? void 0 : f.name) || ((g = o == null ? void 0 : o.user) == null ? void 0 : g.id) || "Unknown member", h = (N = o == null ? void 0 : o.user) == null ? void 0 : N.image;
|
|
706
728
|
return /* @__PURE__ */ i("div", { className: "@container", children: [
|
|
707
729
|
/* @__PURE__ */ i("div", { className: "flex justify-between items-center @lg:hidden", children: [
|
|
708
730
|
/* @__PURE__ */ e(
|
|
@@ -723,7 +745,7 @@ const ws = ({ onBack: t, showBackButton: s, onShowInfo: n, canShowInfo: r }) =>
|
|
|
723
745
|
/* @__PURE__ */ e(
|
|
724
746
|
Z,
|
|
725
747
|
{
|
|
726
|
-
id: ((
|
|
748
|
+
id: ((c = o == null ? void 0 : o.user) == null ? void 0 : c.id) || a.id || "unknown",
|
|
727
749
|
name: l,
|
|
728
750
|
image: h,
|
|
729
751
|
size: 40
|
|
@@ -790,69 +812,69 @@ const ws = ({ onBack: t, showBackButton: s, onShowInfo: n, canShowInfo: r }) =>
|
|
|
790
812
|
showDeleteConversation: h = !0,
|
|
791
813
|
onDeleteConversationClick: f,
|
|
792
814
|
onBlockParticipantClick: g,
|
|
793
|
-
onReportParticipantClick:
|
|
815
|
+
onReportParticipantClick: N
|
|
794
816
|
}) => {
|
|
795
817
|
var q, Q, X, K, ce, j, V;
|
|
796
|
-
const { service:
|
|
818
|
+
const { service: c, debug: E } = ie(), [R, I] = y(!1), [w, C] = y(!1), [u, b] = y(!1), S = D(async () => {
|
|
797
819
|
var F;
|
|
798
|
-
if (!(!
|
|
820
|
+
if (!(!c || !((F = n == null ? void 0 : n.user) != null && F.id)))
|
|
799
821
|
try {
|
|
800
|
-
const
|
|
822
|
+
const P = (await c.getBlockedUsers()).some(
|
|
801
823
|
($) => {
|
|
802
824
|
var Y;
|
|
803
825
|
return $.blocked_user_id === ((Y = n == null ? void 0 : n.user) == null ? void 0 : Y.id);
|
|
804
826
|
}
|
|
805
827
|
);
|
|
806
|
-
I(
|
|
807
|
-
} catch (
|
|
828
|
+
I(P);
|
|
829
|
+
} catch (_) {
|
|
808
830
|
console.error(
|
|
809
831
|
"[ChannelInfoDialog] Failed to check blocked status:",
|
|
810
|
-
|
|
832
|
+
_
|
|
811
833
|
);
|
|
812
834
|
}
|
|
813
|
-
}, [
|
|
835
|
+
}, [c, (q = n == null ? void 0 : n.user) == null ? void 0 : q.id]);
|
|
814
836
|
G(() => {
|
|
815
837
|
S();
|
|
816
838
|
}, [S]);
|
|
817
839
|
const p = async () => {
|
|
818
840
|
var F;
|
|
819
841
|
if (!w) {
|
|
820
|
-
f == null || f(), E && console.log("[ChannelInfoDialog] Leave conversation", r.cid),
|
|
842
|
+
f == null || f(), E && console.log("[ChannelInfoDialog] Leave conversation", r.cid), C(!0);
|
|
821
843
|
try {
|
|
822
|
-
const
|
|
823
|
-
await r.hide(
|
|
824
|
-
} catch (
|
|
825
|
-
console.error("[ChannelInfoDialog] Failed to leave conversation",
|
|
844
|
+
const _ = ((F = r._client) == null ? void 0 : F.userID) ?? null;
|
|
845
|
+
await r.hide(_, !1), o && await o(r), s();
|
|
846
|
+
} catch (_) {
|
|
847
|
+
console.error("[ChannelInfoDialog] Failed to leave conversation", _);
|
|
826
848
|
} finally {
|
|
827
|
-
|
|
849
|
+
C(!1);
|
|
828
850
|
}
|
|
829
851
|
}
|
|
830
852
|
}, T = async () => {
|
|
831
|
-
var F,
|
|
832
|
-
if (!(u || !
|
|
853
|
+
var F, _, P;
|
|
854
|
+
if (!(u || !c)) {
|
|
833
855
|
g == null || g(), E && console.log("[ChannelInfoDialog] Block member", (F = n == null ? void 0 : n.user) == null ? void 0 : F.id), b(!0);
|
|
834
856
|
try {
|
|
835
|
-
await
|
|
857
|
+
await c.blockUser((_ = n == null ? void 0 : n.user) == null ? void 0 : _.id), l && await l((P = n == null ? void 0 : n.user) == null ? void 0 : P.id), s();
|
|
836
858
|
} catch ($) {
|
|
837
859
|
console.error("[ChannelInfoDialog] Failed to block member", $);
|
|
838
860
|
} finally {
|
|
839
861
|
b(!1);
|
|
840
862
|
}
|
|
841
863
|
}
|
|
842
|
-
},
|
|
843
|
-
var F,
|
|
844
|
-
if (!(u || !
|
|
864
|
+
}, d = async () => {
|
|
865
|
+
var F, _, P;
|
|
866
|
+
if (!(u || !c)) {
|
|
845
867
|
g == null || g(), E && console.log("[ChannelInfoDialog] Unblock member", (F = n == null ? void 0 : n.user) == null ? void 0 : F.id), b(!0);
|
|
846
868
|
try {
|
|
847
|
-
await
|
|
869
|
+
await c.unBlockUser((_ = n == null ? void 0 : n.user) == null ? void 0 : _.id), l && await l((P = n == null ? void 0 : n.user) == null ? void 0 : P.id), s();
|
|
848
870
|
} catch ($) {
|
|
849
871
|
console.error("[ChannelInfoDialog] Failed to unblock member", $);
|
|
850
872
|
} finally {
|
|
851
873
|
b(!1);
|
|
852
874
|
}
|
|
853
875
|
}
|
|
854
|
-
},
|
|
855
|
-
|
|
876
|
+
}, m = () => {
|
|
877
|
+
N == null || N(), s(), window.open(
|
|
856
878
|
"https://linktr.ee/s/about/trust-center/report",
|
|
857
879
|
"_blank",
|
|
858
880
|
"noopener,noreferrer"
|
|
@@ -874,7 +896,7 @@ const ws = ({ onBack: t, showBackButton: s, onShowInfo: n, canShowInfo: r }) =>
|
|
|
874
896
|
children: /* @__PURE__ */ i("div", { className: "ml-auto flex h-full w-full flex-col bg-white shadow-none transition-shadow duration-200 group-open:shadow-max-elevation-light", children: [
|
|
875
897
|
/* @__PURE__ */ i("div", { className: "flex items-center justify-between border-b border-sand px-4 py-3", children: [
|
|
876
898
|
/* @__PURE__ */ e("h2", { className: "text-base font-semibold text-charcoal", children: "Chat info" }),
|
|
877
|
-
/* @__PURE__ */ e(
|
|
899
|
+
/* @__PURE__ */ e(De, { onClick: s })
|
|
878
900
|
] }),
|
|
879
901
|
/* @__PURE__ */ i("div", { className: "flex-1 px-2 overflow-y-auto w-full", children: [
|
|
880
902
|
/* @__PURE__ */ e(
|
|
@@ -930,7 +952,7 @@ const ws = ({ onBack: t, showBackButton: s, onShowInfo: n, canShowInfo: r }) =>
|
|
|
930
952
|
/* @__PURE__ */ e("li", { children: R ? /* @__PURE__ */ i(
|
|
931
953
|
ne,
|
|
932
954
|
{
|
|
933
|
-
onClick:
|
|
955
|
+
onClick: d,
|
|
934
956
|
disabled: u,
|
|
935
957
|
"aria-busy": u,
|
|
936
958
|
children: [
|
|
@@ -950,7 +972,7 @@ const ws = ({ onBack: t, showBackButton: s, onShowInfo: n, canShowInfo: r }) =>
|
|
|
950
972
|
]
|
|
951
973
|
}
|
|
952
974
|
) }),
|
|
953
|
-
/* @__PURE__ */ e("li", { children: /* @__PURE__ */ i(ne, { variant: "danger", onClick:
|
|
975
|
+
/* @__PURE__ */ e("li", { children: /* @__PURE__ */ i(ne, { variant: "danger", onClick: m, children: [
|
|
954
976
|
/* @__PURE__ */ e(ls, { className: "h-5 w-5" }),
|
|
955
977
|
/* @__PURE__ */ e("span", { children: "Report" })
|
|
956
978
|
] }) })
|
|
@@ -971,23 +993,23 @@ const ws = ({ onBack: t, showBackButton: s, onShowInfo: n, canShowInfo: r }) =>
|
|
|
971
993
|
onBlockParticipantClick: h,
|
|
972
994
|
onReportParticipantClick: f,
|
|
973
995
|
pendingAttachment: g,
|
|
974
|
-
onClearPendingAttachment:
|
|
996
|
+
onClearPendingAttachment: N
|
|
975
997
|
}) => {
|
|
976
|
-
const { channel:
|
|
998
|
+
const { channel: c } = ue(), E = z(null), R = U.useMemo(() => Object.values(c.state.members || {}).find(
|
|
977
999
|
(b) => {
|
|
978
1000
|
var S;
|
|
979
|
-
return ((S = b.user) == null ? void 0 : S.id) && b.user.id !==
|
|
1001
|
+
return ((S = b.user) == null ? void 0 : S.id) && b.user.id !== c._client.userID;
|
|
980
1002
|
}
|
|
981
|
-
), [
|
|
982
|
-
const u =
|
|
1003
|
+
), [c._client.userID, c.state.members]), I = U.useMemo(() => {
|
|
1004
|
+
const u = c.data ?? {};
|
|
983
1005
|
if (u.followerStatus)
|
|
984
1006
|
return String(u.followerStatus);
|
|
985
1007
|
if (u.isFollower !== void 0)
|
|
986
1008
|
return u.isFollower ? "Subscribed to you" : "Not subscribed";
|
|
987
|
-
}, [
|
|
1009
|
+
}, [c.data]), w = D(() => {
|
|
988
1010
|
var u;
|
|
989
1011
|
(u = E.current) == null || u.showModal();
|
|
990
|
-
}, []),
|
|
1012
|
+
}, []), C = D(() => {
|
|
991
1013
|
var u;
|
|
992
1014
|
(u = E.current) == null || u.close();
|
|
993
1015
|
}, []);
|
|
@@ -1013,9 +1035,9 @@ const ws = ({ onBack: t, showBackButton: s, onShowInfo: n, canShowInfo: r }) =>
|
|
|
1013
1035
|
/* @__PURE__ */ e(
|
|
1014
1036
|
bs,
|
|
1015
1037
|
{
|
|
1016
|
-
renderActions: () => n == null ? void 0 : n(
|
|
1038
|
+
renderActions: () => n == null ? void 0 : n(c),
|
|
1017
1039
|
pendingAttachment: g,
|
|
1018
|
-
onClearPendingAttachment:
|
|
1040
|
+
onClearPendingAttachment: N
|
|
1019
1041
|
}
|
|
1020
1042
|
)
|
|
1021
1043
|
] }),
|
|
@@ -1023,9 +1045,9 @@ const ws = ({ onBack: t, showBackButton: s, onShowInfo: n, canShowInfo: r }) =>
|
|
|
1023
1045
|
ys,
|
|
1024
1046
|
{
|
|
1025
1047
|
dialogRef: E,
|
|
1026
|
-
onClose:
|
|
1048
|
+
onClose: C,
|
|
1027
1049
|
participant: R,
|
|
1028
|
-
channel:
|
|
1050
|
+
channel: c,
|
|
1029
1051
|
followerStatusLabel: I,
|
|
1030
1052
|
onLeaveConversation: r,
|
|
1031
1053
|
onBlockParticipant: a,
|
|
@@ -1036,7 +1058,7 @@ const ws = ({ onBack: t, showBackButton: s, onShowInfo: n, canShowInfo: r }) =>
|
|
|
1036
1058
|
}
|
|
1037
1059
|
)
|
|
1038
1060
|
] });
|
|
1039
|
-
}, Me =
|
|
1061
|
+
}, Me = U.memo(
|
|
1040
1062
|
({
|
|
1041
1063
|
channel: t,
|
|
1042
1064
|
onBack: s,
|
|
@@ -1048,8 +1070,8 @@ const ws = ({ onBack: t, showBackButton: s, onShowInfo: n, canShowInfo: r }) =>
|
|
|
1048
1070
|
CustomChannelEmptyState: h = Cs,
|
|
1049
1071
|
showDeleteConversation: f = !0,
|
|
1050
1072
|
onDeleteConversationClick: g,
|
|
1051
|
-
onBlockParticipantClick:
|
|
1052
|
-
onReportParticipantClick:
|
|
1073
|
+
onBlockParticipantClick: N,
|
|
1074
|
+
onReportParticipantClick: c,
|
|
1053
1075
|
pendingAttachment: E,
|
|
1054
1076
|
onClearPendingAttachment: R
|
|
1055
1077
|
}) => /* @__PURE__ */ e(
|
|
@@ -1077,8 +1099,8 @@ const ws = ({ onBack: t, showBackButton: s, onShowInfo: n, canShowInfo: r }) =>
|
|
|
1077
1099
|
CustomChannelEmptyState: h,
|
|
1078
1100
|
showDeleteConversation: f,
|
|
1079
1101
|
onDeleteConversationClick: g,
|
|
1080
|
-
onBlockParticipantClick:
|
|
1081
|
-
onReportParticipantClick:
|
|
1102
|
+
onBlockParticipantClick: N,
|
|
1103
|
+
onReportParticipantClick: c,
|
|
1082
1104
|
pendingAttachment: E,
|
|
1083
1105
|
onClearPendingAttachment: R
|
|
1084
1106
|
}
|
|
@@ -1137,7 +1159,7 @@ const Ss = ({
|
|
|
1137
1159
|
searchPlaceholder: o = "Search participants...",
|
|
1138
1160
|
className: l
|
|
1139
1161
|
}) => {
|
|
1140
|
-
const { debug: h } = ie(), [f, g] = y(""), [
|
|
1162
|
+
const { debug: h } = ie(), [f, g] = y(""), [N, c] = y([]), [E, R] = y(!1), [I, w] = y(null), [C, u] = y(
|
|
1141
1163
|
null
|
|
1142
1164
|
), b = z(!1);
|
|
1143
1165
|
G(() => {
|
|
@@ -1151,48 +1173,48 @@ const Ss = ({
|
|
|
1151
1173
|
(async () => {
|
|
1152
1174
|
h && console.log("[ParticipantPicker] Loading initial participants..."), R(!0), w(null);
|
|
1153
1175
|
try {
|
|
1154
|
-
const
|
|
1176
|
+
const m = await t.loadParticipants({
|
|
1155
1177
|
search: "",
|
|
1156
1178
|
// Load all participants initially
|
|
1157
1179
|
limit: 100
|
|
1158
1180
|
});
|
|
1159
|
-
m
|
|
1181
|
+
c(m.participants), b.current = !0, h && console.log(
|
|
1160
1182
|
"[ParticipantPicker] Participants loaded successfully:",
|
|
1161
|
-
|
|
1183
|
+
m.participants.length
|
|
1162
1184
|
);
|
|
1163
|
-
} catch (
|
|
1164
|
-
const x =
|
|
1165
|
-
w(x), console.error("[ParticipantPicker] Failed to load participants:",
|
|
1185
|
+
} catch (m) {
|
|
1186
|
+
const x = m instanceof Error ? m.message : "Failed to load participants";
|
|
1187
|
+
w(x), console.error("[ParticipantPicker] Failed to load participants:", m);
|
|
1166
1188
|
} finally {
|
|
1167
1189
|
R(!1);
|
|
1168
1190
|
}
|
|
1169
1191
|
})();
|
|
1170
1192
|
}, [t.loading, h]);
|
|
1171
|
-
const S =
|
|
1193
|
+
const S = N.filter((d) => !r.has(d.id)).filter((d) => {
|
|
1172
1194
|
var x;
|
|
1173
1195
|
if (!f) return !0;
|
|
1174
|
-
const
|
|
1175
|
-
return
|
|
1176
|
-
}), p =
|
|
1177
|
-
async (
|
|
1178
|
-
if (!
|
|
1179
|
-
u(
|
|
1196
|
+
const m = f.toLowerCase();
|
|
1197
|
+
return d.name.toLowerCase().includes(m) || ((x = d.email) == null ? void 0 : x.toLowerCase().includes(m)) || !1;
|
|
1198
|
+
}), p = D(
|
|
1199
|
+
async (d) => {
|
|
1200
|
+
if (!C) {
|
|
1201
|
+
u(d.id);
|
|
1180
1202
|
try {
|
|
1181
|
-
await s(
|
|
1182
|
-
} catch (
|
|
1183
|
-
console.error("[ParticipantPicker] Failed to start chat:",
|
|
1203
|
+
await s(d);
|
|
1204
|
+
} catch (m) {
|
|
1205
|
+
console.error("[ParticipantPicker] Failed to start chat:", m), u(null);
|
|
1184
1206
|
}
|
|
1185
1207
|
}
|
|
1186
1208
|
},
|
|
1187
|
-
[s,
|
|
1188
|
-
), T = (
|
|
1189
|
-
(
|
|
1209
|
+
[s, C]
|
|
1210
|
+
), T = (d, m) => {
|
|
1211
|
+
(d.key === "Enter" || d.key === " ") && (d.preventDefault(), p(m));
|
|
1190
1212
|
};
|
|
1191
1213
|
return /* @__PURE__ */ i("div", { className: k("flex flex-col h-full", l), children: [
|
|
1192
1214
|
/* @__PURE__ */ i("div", { className: "px-4 py-4 border-b border-sand bg-chalk", children: [
|
|
1193
1215
|
/* @__PURE__ */ i("div", { className: "flex items-center justify-between mb-3", children: [
|
|
1194
1216
|
/* @__PURE__ */ e("h2", { className: "text-lg font-semibold text-charcoal", children: "Start a new Conversation" }),
|
|
1195
|
-
/* @__PURE__ */ e(
|
|
1217
|
+
/* @__PURE__ */ e(De, { onClick: n })
|
|
1196
1218
|
] }),
|
|
1197
1219
|
/* @__PURE__ */ i("p", { className: "text-xs text-stone mb-3", children: [
|
|
1198
1220
|
"Select a ",
|
|
@@ -1226,38 +1248,38 @@ const Ss = ({
|
|
|
1226
1248
|
] })
|
|
1227
1249
|
] }) }) : S.length === 0 ? /* @__PURE__ */ i("div", { className: "p-6 text-center", children: [
|
|
1228
1250
|
/* @__PURE__ */ e("div", { className: "mx-auto mb-4 flex h-16 w-16 items-center justify-center rounded-full bg-sand", children: /* @__PURE__ */ e(Ne, { className: "h-8 w-8 text-charcoal" }) }),
|
|
1229
|
-
/* @__PURE__ */ e("h3", { className: "text-sm font-semibold text-charcoal mb-2", children: f ? `No ${a} found` :
|
|
1230
|
-
/* @__PURE__ */ e("p", { className: "text-xs text-stone", children: f ? "Try a different search term" :
|
|
1251
|
+
/* @__PURE__ */ e("h3", { className: "text-sm font-semibold text-charcoal mb-2", children: f ? `No ${a} found` : N.length > 0 ? `Already chatting with all ${a}` : `No ${a} yet` }),
|
|
1252
|
+
/* @__PURE__ */ e("p", { className: "text-xs text-stone", children: f ? "Try a different search term" : N.length > 0 ? `You have existing conversations with all your ${a}` : `${a.charAt(0).toUpperCase() + a.slice(1)} will appear here` })
|
|
1231
1253
|
] }) : /* @__PURE__ */ i("ul", { className: "space-y-0", children: [
|
|
1232
|
-
S.map((
|
|
1233
|
-
const
|
|
1254
|
+
S.map((d) => {
|
|
1255
|
+
const m = d.name || d.email || d.id, x = d.email && d.name ? d.email : d.phone;
|
|
1234
1256
|
return /* @__PURE__ */ e("li", { children: /* @__PURE__ */ e(
|
|
1235
1257
|
"button",
|
|
1236
1258
|
{
|
|
1237
1259
|
type: "button",
|
|
1238
|
-
onClick: () => p(
|
|
1239
|
-
onKeyDown: (B) => T(B,
|
|
1260
|
+
onClick: () => p(d),
|
|
1261
|
+
onKeyDown: (B) => T(B, d),
|
|
1240
1262
|
className: "w-full px-4 py-3 hover:bg-sand transition-colors border-b border-sand text-left focus:outline-none focus:ring-2 focus:ring-black",
|
|
1241
1263
|
children: /* @__PURE__ */ i("div", { className: "flex items-center justify-between", children: [
|
|
1242
1264
|
/* @__PURE__ */ i("div", { className: "flex items-center space-x-3 flex-1 min-w-0", children: [
|
|
1243
1265
|
/* @__PURE__ */ e(
|
|
1244
1266
|
Z,
|
|
1245
1267
|
{
|
|
1246
|
-
id:
|
|
1247
|
-
name:
|
|
1248
|
-
image:
|
|
1268
|
+
id: d.id,
|
|
1269
|
+
name: m,
|
|
1270
|
+
image: d.image,
|
|
1249
1271
|
size: 40
|
|
1250
1272
|
}
|
|
1251
1273
|
),
|
|
1252
1274
|
/* @__PURE__ */ i("div", { className: "flex-1 min-w-0", children: [
|
|
1253
|
-
/* @__PURE__ */ e("h4", { className: "text-sm font-medium text-charcoal truncate", children:
|
|
1275
|
+
/* @__PURE__ */ e("h4", { className: "text-sm font-medium text-charcoal truncate", children: m }),
|
|
1254
1276
|
x && /* @__PURE__ */ e("p", { className: "text-xs text-stone truncate", children: x })
|
|
1255
1277
|
] })
|
|
1256
1278
|
] }),
|
|
1257
|
-
/* @__PURE__ */ e("div", { className: "flex-shrink-0", children:
|
|
1279
|
+
/* @__PURE__ */ e("div", { className: "flex-shrink-0", children: C === d.id ? /* @__PURE__ */ e(re, { className: "h-5 w-5 text-primary animate-spin" }) : /* @__PURE__ */ e(Ne, { className: "h-5 w-5 text-stone" }) })
|
|
1258
1280
|
] })
|
|
1259
1281
|
}
|
|
1260
|
-
) },
|
|
1282
|
+
) }, d.id);
|
|
1261
1283
|
}),
|
|
1262
1284
|
E && /* @__PURE__ */ e("li", { className: "p-4 flex justify-center", children: /* @__PURE__ */ i("div", { className: "flex items-center space-x-2", children: [
|
|
1263
1285
|
/* @__PURE__ */ e("div", { className: "w-4 h-4 animate-spin rounded-full border-2 border-primary border-t-transparent" }),
|
|
@@ -1399,7 +1421,7 @@ const Ss = ({
|
|
|
1399
1421
|
] })
|
|
1400
1422
|
]
|
|
1401
1423
|
}
|
|
1402
|
-
), Fe =
|
|
1424
|
+
), Fe = U.memo(
|
|
1403
1425
|
({ hasChannels: t, channelsLoaded: s }) => /* @__PURE__ */ e("div", { className: "messaging-empty-state flex items-center justify-center h-full p-8 text-balance", children: /* @__PURE__ */ i("div", { className: "flex flex-col items-center max-w-sm text-center", children: [
|
|
1404
1426
|
/* @__PURE__ */ e(ps, {}),
|
|
1405
1427
|
s && !t && /* @__PURE__ */ i("div", { className: "mt-8", children: [
|
|
@@ -1409,7 +1431,7 @@ const Ss = ({
|
|
|
1409
1431
|
] }) })
|
|
1410
1432
|
);
|
|
1411
1433
|
Fe.displayName = "EmptyState";
|
|
1412
|
-
const le =
|
|
1434
|
+
const le = U.memo(({ message: t, onBack: s }) => /* @__PURE__ */ e("div", { className: "messaging-error-state flex items-center justify-center h-full p-8", children: /* @__PURE__ */ i("div", { className: "text-center max-w-sm", children: [
|
|
1413
1435
|
/* @__PURE__ */ e("div", { className: "w-24 h-24 bg-danger-alt/20 rounded-full flex items-center justify-center mx-auto mb-6", children: /* @__PURE__ */ e("span", { className: "text-4xl", children: "โ ๏ธ" }) }),
|
|
1414
1436
|
/* @__PURE__ */ e("h2", { className: "font-semibold text-charcoal mb-2", children: "Oops!" }),
|
|
1415
1437
|
/* @__PURE__ */ e("p", { className: "text-stone text-sm mb-6", children: t }),
|
|
@@ -1424,7 +1446,7 @@ const le = P.memo(({ message: t, onBack: s }) => /* @__PURE__ */ e("div", { clas
|
|
|
1424
1446
|
)
|
|
1425
1447
|
] }) }));
|
|
1426
1448
|
le.displayName = "ErrorState";
|
|
1427
|
-
const
|
|
1449
|
+
const Ps = ({
|
|
1428
1450
|
capabilities: t = {},
|
|
1429
1451
|
className: s,
|
|
1430
1452
|
renderMessageInputActions: n,
|
|
@@ -1435,48 +1457,48 @@ const Us = ({
|
|
|
1435
1457
|
CustomChannelEmptyState: h,
|
|
1436
1458
|
showChannelList: f = !0,
|
|
1437
1459
|
filters: g,
|
|
1438
|
-
channelListCustomEmptyStateIndicator:
|
|
1439
|
-
onDeleteConversationClick:
|
|
1460
|
+
channelListCustomEmptyStateIndicator: N,
|
|
1461
|
+
onDeleteConversationClick: c,
|
|
1440
1462
|
onBlockParticipantClick: E,
|
|
1441
1463
|
onReportParticipantClick: R,
|
|
1442
1464
|
pendingAttachment: I,
|
|
1443
1465
|
onClearPendingAttachment: w
|
|
1444
1466
|
}) => {
|
|
1445
1467
|
const {
|
|
1446
|
-
service:
|
|
1468
|
+
service: C,
|
|
1447
1469
|
client: u,
|
|
1448
1470
|
isConnected: b,
|
|
1449
1471
|
isLoading: S,
|
|
1450
1472
|
error: p,
|
|
1451
1473
|
refreshConnection: T,
|
|
1452
|
-
debug:
|
|
1453
|
-
} = os(), [
|
|
1474
|
+
debug: d
|
|
1475
|
+
} = os(), [m, x] = y(null), [B, A] = y(!1), [H, J] = y(!1), [he, q] = y(!1), [Q, X] = y(/* @__PURE__ */ new Set()), [K, ce] = y(0), [j, V] = y(!1), [F, _] = y(null), P = z(null), {
|
|
1454
1476
|
participantSource: $,
|
|
1455
1477
|
participantLabel: Y = "participants",
|
|
1456
1478
|
showDeleteConversation: Te = !0
|
|
1457
|
-
} = t, Le =
|
|
1458
|
-
const
|
|
1479
|
+
} = t, Le = U.useMemo(() => {
|
|
1480
|
+
const v = u == null ? void 0 : u.userID;
|
|
1459
1481
|
return {
|
|
1460
1482
|
...{
|
|
1461
1483
|
type: "messaging",
|
|
1462
1484
|
last_message_at: { $exists: !0 },
|
|
1463
|
-
...
|
|
1464
|
-
members: { $in: [
|
|
1485
|
+
...v && {
|
|
1486
|
+
members: { $in: [v] },
|
|
1465
1487
|
hidden: !1
|
|
1466
1488
|
}
|
|
1467
1489
|
},
|
|
1468
1490
|
...g
|
|
1469
1491
|
};
|
|
1470
|
-
}, [g, u == null ? void 0 : u.userID]), ee = z(null), W =
|
|
1492
|
+
}, [g, u == null ? void 0 : u.userID]), ee = z(null), W = D(async () => {
|
|
1471
1493
|
if (!u || !b) return;
|
|
1472
|
-
const
|
|
1473
|
-
if (
|
|
1494
|
+
const v = u.userID;
|
|
1495
|
+
if (v)
|
|
1474
1496
|
try {
|
|
1475
|
-
|
|
1497
|
+
d && console.log("[MessagingShell] Syncing channels for user:", v);
|
|
1476
1498
|
const O = await u.queryChannels(
|
|
1477
1499
|
{
|
|
1478
1500
|
type: "messaging",
|
|
1479
|
-
members: { $in: [
|
|
1501
|
+
members: { $in: [v] }
|
|
1480
1502
|
},
|
|
1481
1503
|
{},
|
|
1482
1504
|
{ limit: 100 }
|
|
@@ -1486,27 +1508,27 @@ const Us = ({
|
|
|
1486
1508
|
Object.values(de).forEach((Be) => {
|
|
1487
1509
|
var fe;
|
|
1488
1510
|
const me = (fe = Be.user) == null ? void 0 : fe.id;
|
|
1489
|
-
me && me !==
|
|
1511
|
+
me && me !== v && M.add(me);
|
|
1490
1512
|
});
|
|
1491
|
-
}), X((L) => L.size === M.size && [...L].every((de) => M.has(de)) ? L : M), A(O.length > 0), J(!0), ee.current =
|
|
1513
|
+
}), X((L) => L.size === M.size && [...L].every((de) => M.has(de)) ? L : M), A(O.length > 0), J(!0), ee.current = v, d && console.log("[MessagingShell] Channels synced successfully:", {
|
|
1492
1514
|
channelCount: O.length,
|
|
1493
1515
|
memberCount: M.size
|
|
1494
1516
|
});
|
|
1495
1517
|
} catch (O) {
|
|
1496
1518
|
console.error("[MessagingShell] Failed to sync channels:", O);
|
|
1497
1519
|
}
|
|
1498
|
-
}, [u, b,
|
|
1520
|
+
}, [u, b, d]);
|
|
1499
1521
|
G(() => {
|
|
1500
1522
|
if (!u || !b) return;
|
|
1501
|
-
const
|
|
1502
|
-
|
|
1523
|
+
const v = u.userID;
|
|
1524
|
+
v && ee.current !== v && W();
|
|
1503
1525
|
}, [u, b, W]), G(() => {
|
|
1504
1526
|
if (!o || !u || !b) return;
|
|
1505
1527
|
(async () => {
|
|
1506
1528
|
const O = u.userID;
|
|
1507
1529
|
if (O)
|
|
1508
1530
|
try {
|
|
1509
|
-
|
|
1531
|
+
d && console.log(
|
|
1510
1532
|
"[MessagingShell] Loading initial conversation with:",
|
|
1511
1533
|
o
|
|
1512
1534
|
);
|
|
@@ -1519,23 +1541,23 @@ const Us = ({
|
|
|
1519
1541
|
{ limit: 1 }
|
|
1520
1542
|
);
|
|
1521
1543
|
if (M.length > 0)
|
|
1522
|
-
x(M[0]), V(!0),
|
|
1544
|
+
x(M[0]), V(!0), _(null), r && r(M[0]), d && console.log(
|
|
1523
1545
|
"[MessagingShell] Initial conversation loaded:",
|
|
1524
1546
|
M[0].id
|
|
1525
1547
|
);
|
|
1526
|
-
else if (l &&
|
|
1527
|
-
|
|
1548
|
+
else if (l && C) {
|
|
1549
|
+
d && console.log(
|
|
1528
1550
|
"[MessagingShell] No conversation found, creating one for:",
|
|
1529
1551
|
l
|
|
1530
1552
|
);
|
|
1531
1553
|
try {
|
|
1532
|
-
const L = await
|
|
1554
|
+
const L = await C.startChannelWithParticipant({
|
|
1533
1555
|
id: l.id,
|
|
1534
1556
|
name: l.name,
|
|
1535
1557
|
email: l.email,
|
|
1536
1558
|
phone: l.phone
|
|
1537
1559
|
});
|
|
1538
|
-
x(L), V(!0),
|
|
1560
|
+
x(L), V(!0), _(null), r && r(L), d && console.log(
|
|
1539
1561
|
"[MessagingShell] Channel created and loaded:",
|
|
1540
1562
|
L.id
|
|
1541
1563
|
);
|
|
@@ -1543,12 +1565,12 @@ const Us = ({
|
|
|
1543
1565
|
console.error(
|
|
1544
1566
|
"[MessagingShell] Failed to create conversation:",
|
|
1545
1567
|
L
|
|
1546
|
-
),
|
|
1568
|
+
), _("Failed to create conversation");
|
|
1547
1569
|
}
|
|
1548
1570
|
} else
|
|
1549
|
-
|
|
1571
|
+
_(
|
|
1550
1572
|
"No conversation found with this account"
|
|
1551
|
-
),
|
|
1573
|
+
), d && console.log(
|
|
1552
1574
|
"[MessagingShell] No conversation found for:",
|
|
1553
1575
|
o
|
|
1554
1576
|
);
|
|
@@ -1556,7 +1578,7 @@ const Us = ({
|
|
|
1556
1578
|
console.error(
|
|
1557
1579
|
"[MessagingShell] Failed to load initial conversation:",
|
|
1558
1580
|
M
|
|
1559
|
-
),
|
|
1581
|
+
), _("Failed to load conversation");
|
|
1560
1582
|
}
|
|
1561
1583
|
})();
|
|
1562
1584
|
}, [
|
|
@@ -1564,62 +1586,62 @@ const Us = ({
|
|
|
1564
1586
|
l,
|
|
1565
1587
|
u,
|
|
1566
1588
|
b,
|
|
1567
|
-
|
|
1568
|
-
|
|
1589
|
+
C,
|
|
1590
|
+
d,
|
|
1569
1591
|
r
|
|
1570
1592
|
]);
|
|
1571
|
-
const
|
|
1572
|
-
(
|
|
1573
|
-
x(
|
|
1593
|
+
const Ue = D(
|
|
1594
|
+
(v) => {
|
|
1595
|
+
x(v), r == null || r(v);
|
|
1574
1596
|
},
|
|
1575
1597
|
[r]
|
|
1576
|
-
),
|
|
1598
|
+
), Pe = D(() => {
|
|
1577
1599
|
j || x(null);
|
|
1578
|
-
}, [j]), Oe =
|
|
1579
|
-
async (
|
|
1600
|
+
}, [j]), Oe = D(
|
|
1601
|
+
async (v) => {
|
|
1580
1602
|
var O;
|
|
1581
|
-
if (
|
|
1603
|
+
if (C)
|
|
1582
1604
|
try {
|
|
1583
|
-
|
|
1605
|
+
d && console.log(
|
|
1584
1606
|
"[MessagingShell] Starting conversation with:",
|
|
1585
|
-
|
|
1607
|
+
v.id
|
|
1586
1608
|
);
|
|
1587
|
-
const M = await
|
|
1588
|
-
id:
|
|
1589
|
-
name:
|
|
1590
|
-
email:
|
|
1591
|
-
phone:
|
|
1609
|
+
const M = await C.startChannelWithParticipant({
|
|
1610
|
+
id: v.id,
|
|
1611
|
+
name: v.name,
|
|
1612
|
+
email: v.email,
|
|
1613
|
+
phone: v.phone
|
|
1592
1614
|
});
|
|
1593
1615
|
try {
|
|
1594
1616
|
await M.show();
|
|
1595
1617
|
} catch (L) {
|
|
1596
1618
|
console.warn("[MessagingShell] Failed to unhide channel:", L);
|
|
1597
1619
|
}
|
|
1598
|
-
x(M), q(!1), (O =
|
|
1620
|
+
x(M), q(!1), (O = P.current) == null || O.close(), a == null || a(v);
|
|
1599
1621
|
} catch (M) {
|
|
1600
1622
|
console.error("[MessagingShell] Failed to start conversation:", M);
|
|
1601
1623
|
}
|
|
1602
1624
|
},
|
|
1603
|
-
[
|
|
1604
|
-
), se =
|
|
1605
|
-
var
|
|
1606
|
-
q(!1), (
|
|
1607
|
-
}, []), je =
|
|
1608
|
-
(
|
|
1609
|
-
|
|
1625
|
+
[C, a, d]
|
|
1626
|
+
), se = D(() => {
|
|
1627
|
+
var v;
|
|
1628
|
+
q(!1), (v = P.current) == null || v.close();
|
|
1629
|
+
}, []), je = D(
|
|
1630
|
+
(v) => {
|
|
1631
|
+
v.target === P.current && se();
|
|
1610
1632
|
},
|
|
1611
1633
|
[se]
|
|
1612
|
-
), Ae =
|
|
1613
|
-
async (
|
|
1614
|
-
|
|
1634
|
+
), Ae = D(
|
|
1635
|
+
async (v) => {
|
|
1636
|
+
d && console.log("[MessagingShell] Leaving conversation:", v.id), x(null), V(!1), ee.current = null, await W();
|
|
1615
1637
|
},
|
|
1616
|
-
[W,
|
|
1617
|
-
), ze =
|
|
1618
|
-
async (
|
|
1619
|
-
|
|
1638
|
+
[W, d]
|
|
1639
|
+
), ze = D(
|
|
1640
|
+
async (v) => {
|
|
1641
|
+
d && console.log("[MessagingShell] Blocking participant:", v), x(null), V(!1), ee.current = null, await W();
|
|
1620
1642
|
},
|
|
1621
|
-
[W,
|
|
1622
|
-
), te = !!
|
|
1643
|
+
[W, d]
|
|
1644
|
+
), te = !!m;
|
|
1623
1645
|
return S ? /* @__PURE__ */ e("div", { className: k("h-full", s), children: /* @__PURE__ */ e(ae, {}) }) : p ? /* @__PURE__ */ e("div", { className: k("h-full", s), children: /* @__PURE__ */ e(le, { message: p, onBack: T }) }) : !b || !u ? /* @__PURE__ */ e("div", { className: k("h-full", s), children: /* @__PURE__ */ e(
|
|
1624
1646
|
le,
|
|
1625
1647
|
{
|
|
@@ -1651,10 +1673,10 @@ const Us = ({
|
|
|
1651
1673
|
children: /* @__PURE__ */ e(
|
|
1652
1674
|
ke,
|
|
1653
1675
|
{
|
|
1654
|
-
onChannelSelect:
|
|
1655
|
-
selectedChannel:
|
|
1676
|
+
onChannelSelect: Ue,
|
|
1677
|
+
selectedChannel: m || void 0,
|
|
1656
1678
|
filters: Le,
|
|
1657
|
-
customEmptyStateIndicator:
|
|
1679
|
+
customEmptyStateIndicator: N
|
|
1658
1680
|
}
|
|
1659
1681
|
)
|
|
1660
1682
|
}
|
|
@@ -1671,24 +1693,24 @@ const Us = ({
|
|
|
1671
1693
|
"hidden lg:flex": !j && !te && !o
|
|
1672
1694
|
}
|
|
1673
1695
|
),
|
|
1674
|
-
children:
|
|
1696
|
+
children: m ? /* @__PURE__ */ e("div", { className: "flex-1 min-h-0 flex flex-col", children: /* @__PURE__ */ e(
|
|
1675
1697
|
Me,
|
|
1676
1698
|
{
|
|
1677
|
-
channel:
|
|
1678
|
-
onBack:
|
|
1699
|
+
channel: m,
|
|
1700
|
+
onBack: Pe,
|
|
1679
1701
|
showBackButton: !j,
|
|
1680
1702
|
renderMessageInputActions: n,
|
|
1681
1703
|
onLeaveConversation: Ae,
|
|
1682
1704
|
onBlockParticipant: ze,
|
|
1683
1705
|
CustomChannelEmptyState: h,
|
|
1684
1706
|
showDeleteConversation: Te,
|
|
1685
|
-
onDeleteConversationClick:
|
|
1707
|
+
onDeleteConversationClick: c,
|
|
1686
1708
|
onBlockParticipantClick: E,
|
|
1687
1709
|
onReportParticipantClick: R,
|
|
1688
1710
|
pendingAttachment: I,
|
|
1689
1711
|
onClearPendingAttachment: w
|
|
1690
1712
|
},
|
|
1691
|
-
|
|
1713
|
+
m.id
|
|
1692
1714
|
) }) : o ? (
|
|
1693
1715
|
// Show loading while creating/loading direct conversation channel
|
|
1694
1716
|
/* @__PURE__ */ e(ae, {})
|
|
@@ -1706,7 +1728,7 @@ const Us = ({
|
|
|
1706
1728
|
/* @__PURE__ */ e(
|
|
1707
1729
|
"dialog",
|
|
1708
1730
|
{
|
|
1709
|
-
ref:
|
|
1731
|
+
ref: P,
|
|
1710
1732
|
className: "mes-dialog",
|
|
1711
1733
|
onClick: je,
|
|
1712
1734
|
onClose: se,
|
|
@@ -1791,39 +1813,39 @@ const Us = ({
|
|
|
1791
1813
|
)
|
|
1792
1814
|
] }) });
|
|
1793
1815
|
}, js = (t, s = {}) => {
|
|
1794
|
-
const { initialSearch: n = "", pageSize: r = 20 } = s, [a, o] = y([]), [l, h] = y(!1), [f, g] = y(null), [
|
|
1816
|
+
const { initialSearch: n = "", pageSize: r = 20 } = s, [a, o] = y([]), [l, h] = y(!1), [f, g] = y(null), [N, c] = y(n), [E, R] = y(!0), [I, w] = y(), C = D(async (p = !1, T) => {
|
|
1795
1817
|
if (l) return;
|
|
1796
|
-
const
|
|
1818
|
+
const d = T !== void 0 ? T : N;
|
|
1797
1819
|
h(!0), g(null);
|
|
1798
1820
|
try {
|
|
1799
|
-
const
|
|
1800
|
-
search:
|
|
1821
|
+
const m = await t.loadParticipants({
|
|
1822
|
+
search: d || void 0,
|
|
1801
1823
|
limit: r,
|
|
1802
1824
|
cursor: p ? void 0 : I
|
|
1803
1825
|
});
|
|
1804
1826
|
o(
|
|
1805
|
-
(x) => p ?
|
|
1806
|
-
), R(
|
|
1807
|
-
} catch (
|
|
1808
|
-
const x =
|
|
1809
|
-
g(x), console.error("[useParticipants] Load error:",
|
|
1827
|
+
(x) => p ? m.participants : [...x, ...m.participants]
|
|
1828
|
+
), R(m.hasMore), w(m.nextCursor);
|
|
1829
|
+
} catch (m) {
|
|
1830
|
+
const x = m instanceof Error ? m.message : "Failed to load participants";
|
|
1831
|
+
g(x), console.error("[useParticipants] Load error:", m);
|
|
1810
1832
|
} finally {
|
|
1811
1833
|
h(!1);
|
|
1812
1834
|
}
|
|
1813
|
-
}, [t,
|
|
1814
|
-
E && !l &&
|
|
1815
|
-
}, [E, l,
|
|
1816
|
-
|
|
1817
|
-
}, [
|
|
1818
|
-
w(void 0),
|
|
1819
|
-
}, [
|
|
1835
|
+
}, [t, N, I, r, l]), u = D(() => {
|
|
1836
|
+
E && !l && C(!1);
|
|
1837
|
+
}, [E, l, C]), b = D((p) => {
|
|
1838
|
+
c(p), w(void 0), C(!0, p);
|
|
1839
|
+
}, [C]), S = D(() => {
|
|
1840
|
+
w(void 0), C(!0);
|
|
1841
|
+
}, [C]);
|
|
1820
1842
|
return G(() => {
|
|
1821
|
-
|
|
1843
|
+
C(!0);
|
|
1822
1844
|
}, [t.loadParticipants]), {
|
|
1823
1845
|
participants: a,
|
|
1824
1846
|
loading: l,
|
|
1825
1847
|
error: f,
|
|
1826
|
-
searchQuery:
|
|
1848
|
+
searchQuery: N,
|
|
1827
1849
|
hasMore: E,
|
|
1828
1850
|
totalCount: t.totalCount,
|
|
1829
1851
|
loadMore: u,
|
|
@@ -1838,8 +1860,8 @@ export {
|
|
|
1838
1860
|
Me as ChannelView,
|
|
1839
1861
|
Os as FaqList,
|
|
1840
1862
|
ks as FaqListItem,
|
|
1841
|
-
|
|
1842
|
-
|
|
1863
|
+
Us as MessagingProvider,
|
|
1864
|
+
Ps as MessagingShell,
|
|
1843
1865
|
Ss as ParticipantPicker,
|
|
1844
1866
|
cs as formatRelativeTime,
|
|
1845
1867
|
os as useMessaging,
|