@linktr.ee/messaging-react 1.6.5 โ 1.6.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/dist/index.d.ts +5 -0
- package/dist/index.js +236 -215
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/components/ChannelView.stories.tsx +365 -0
- package/src/components/ChannelView.tsx +32 -15
- package/src/components/MessagingShell/ChannelEmptyState.tsx +17 -0
- package/src/index.ts +1 -0
package/dist/index.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { jsx as e, jsxs as d, Fragment as oe } from "react/jsx-runtime";
|
|
2
2
|
import D from "classnames";
|
|
3
|
-
import X, { createContext as
|
|
3
|
+
import X, { createContext as Ee, useContext as ye, useCallback as M, useState as E, useRef as H, useEffect as _ } from "react";
|
|
4
4
|
import { StreamChatService as Ie } from "@linktr.ee/messaging-core";
|
|
5
|
-
import { Chat as
|
|
6
|
-
import { NotePencilIcon as Oe, XIcon as he, ArrowLeftIcon as Me, DotsThreeIcon as
|
|
7
|
-
const fe =
|
|
5
|
+
import { Chat as Se, useChatContext as Re, ChannelList as ke, Channel as Fe, useChannelStateContext as me, Window as Te, MessageList as De, MessageInput as Pe } from "stream-chat-react";
|
|
6
|
+
import { NotePencilIcon as Oe, XIcon as he, ArrowLeftIcon as Me, DotsThreeIcon as pe, SpinnerGapIcon as ee, SignOutIcon as Ue, ProhibitInsetIcon as ie, FlagIcon as Le, MagnifyingGlassIcon as je, ChatCircleDotsIcon as ce } from "@phosphor-icons/react";
|
|
7
|
+
const fe = Ee({
|
|
8
8
|
service: null,
|
|
9
9
|
client: null,
|
|
10
10
|
isConnected: !1,
|
|
@@ -15,7 +15,7 @@ const fe = we({
|
|
|
15
15
|
refreshConnection: async () => {
|
|
16
16
|
},
|
|
17
17
|
debug: !1
|
|
18
|
-
}), se = () =>
|
|
18
|
+
}), se = () => ye(fe), os = ({
|
|
19
19
|
children: t,
|
|
20
20
|
user: s,
|
|
21
21
|
serviceConfig: n,
|
|
@@ -24,9 +24,9 @@ const fe = we({
|
|
|
24
24
|
customization: c = {},
|
|
25
25
|
debug: a = !1
|
|
26
26
|
}) => {
|
|
27
|
-
const l =
|
|
28
|
-
(w, ...
|
|
29
|
-
a && console.log(`๐ฅ [MessagingProvider] ${w}`, ...
|
|
27
|
+
const l = M(
|
|
28
|
+
(w, ...P) => {
|
|
29
|
+
a && console.log(`๐ฅ [MessagingProvider] ${w}`, ...P);
|
|
30
30
|
},
|
|
31
31
|
[a]
|
|
32
32
|
);
|
|
@@ -37,30 +37,30 @@ const fe = we({
|
|
|
37
37
|
capabilities: Object.keys(i),
|
|
38
38
|
customization: Object.keys(c)
|
|
39
39
|
});
|
|
40
|
-
const [r, b] = E(null), [u, g] = E(null), [m,
|
|
40
|
+
const [r, b] = E(null), [u, g] = E(null), [m, y] = E(!1), [N, h] = E(!1), [v, S] = E(null), O = H(!1), I = H({
|
|
41
41
|
userId: s == null ? void 0 : s.id,
|
|
42
42
|
apiKey: o,
|
|
43
43
|
serviceConfig: n,
|
|
44
44
|
capabilities: i,
|
|
45
45
|
customization: c
|
|
46
|
-
}), k =
|
|
46
|
+
}), k = H(0);
|
|
47
47
|
k.current++, l("๐ RENDER INFO", {
|
|
48
48
|
renderCount: k.current,
|
|
49
49
|
currentProps: { userId: s == null ? void 0 : s.id, apiKey: (o == null ? void 0 : o.substring(0, 8)) + "..." },
|
|
50
50
|
propChanges: {
|
|
51
|
-
userChanged:
|
|
52
|
-
apiKeyChanged:
|
|
53
|
-
serviceConfigChanged:
|
|
54
|
-
capabilitiesChanged:
|
|
55
|
-
customizationChanged:
|
|
51
|
+
userChanged: I.current.userId !== (s == null ? void 0 : s.id),
|
|
52
|
+
apiKeyChanged: I.current.apiKey !== o,
|
|
53
|
+
serviceConfigChanged: I.current.serviceConfig !== n,
|
|
54
|
+
capabilitiesChanged: I.current.capabilities !== i,
|
|
55
|
+
customizationChanged: I.current.customization !== c
|
|
56
56
|
}
|
|
57
|
-
}),
|
|
57
|
+
}), I.current = {
|
|
58
58
|
userId: s == null ? void 0 : s.id,
|
|
59
59
|
apiKey: o,
|
|
60
60
|
serviceConfig: n,
|
|
61
61
|
capabilities: i,
|
|
62
62
|
customization: c
|
|
63
|
-
},
|
|
63
|
+
}, _(() => {
|
|
64
64
|
const w = k.current;
|
|
65
65
|
if (l("๐ง SERVICE INIT EFFECT TRIGGERED", {
|
|
66
66
|
renderCount: w,
|
|
@@ -69,8 +69,8 @@ const fe = we({
|
|
|
69
69
|
dependencies: {
|
|
70
70
|
apiKey: (o == null ? void 0 : o.substring(0, 8)) + "...",
|
|
71
71
|
serviceConfigRef: n,
|
|
72
|
-
serviceConfigStable:
|
|
73
|
-
apiKeyStable:
|
|
72
|
+
serviceConfigStable: I.current.serviceConfig === n,
|
|
73
|
+
apiKeyStable: I.current.apiKey === o
|
|
74
74
|
}
|
|
75
75
|
}), !o || !n) {
|
|
76
76
|
l("โ ๏ธ SERVICE INIT SKIPPED", {
|
|
@@ -82,42 +82,42 @@ const fe = we({
|
|
|
82
82
|
l("๐ CREATING NEW SERVICE", {
|
|
83
83
|
renderCount: w,
|
|
84
84
|
apiKey: (o == null ? void 0 : o.substring(0, 8)) + "...",
|
|
85
|
-
serviceConfigChanged:
|
|
85
|
+
serviceConfigChanged: I.current.serviceConfig !== n
|
|
86
86
|
});
|
|
87
|
-
const
|
|
87
|
+
const P = new Ie({
|
|
88
88
|
...n,
|
|
89
89
|
apiKey: o,
|
|
90
90
|
debug: a
|
|
91
91
|
});
|
|
92
|
-
return b(
|
|
92
|
+
return b(P), l("โ
SERVICE SET", {
|
|
93
93
|
renderCount: w,
|
|
94
|
-
serviceInstance: !!
|
|
94
|
+
serviceInstance: !!P
|
|
95
95
|
}), () => {
|
|
96
96
|
l("๐งน SERVICE CLEANUP", {
|
|
97
97
|
renderCount: w,
|
|
98
98
|
reason: "Effect cleanup"
|
|
99
|
-
}),
|
|
99
|
+
}), P.disconnectUser().catch(console.error);
|
|
100
100
|
};
|
|
101
101
|
}, [o, n, a, l]);
|
|
102
|
-
const
|
|
103
|
-
|
|
104
|
-
var
|
|
102
|
+
const F = H(null);
|
|
103
|
+
_(() => {
|
|
104
|
+
var P, U;
|
|
105
105
|
if (l("๐ USER CONNECTION EFFECT TRIGGERED", {
|
|
106
106
|
hasService: !!r,
|
|
107
107
|
hasUser: !!s,
|
|
108
108
|
userId: s == null ? void 0 : s.id,
|
|
109
|
-
isConnecting:
|
|
109
|
+
isConnecting: O.current,
|
|
110
110
|
isConnected: m,
|
|
111
111
|
dependencies: { service: !!r, userId: s == null ? void 0 : s.id }
|
|
112
112
|
}), !r || !s) {
|
|
113
113
|
l("โ ๏ธ USER CONNECTION SKIPPED", "Missing service or user");
|
|
114
114
|
return;
|
|
115
115
|
}
|
|
116
|
-
if (
|
|
116
|
+
if (O.current) {
|
|
117
117
|
l("โ ๏ธ USER CONNECTION SKIPPED", "Already connecting");
|
|
118
118
|
return;
|
|
119
119
|
}
|
|
120
|
-
if (((
|
|
120
|
+
if (((P = F.current) == null ? void 0 : P.serviceId) === r && ((U = F.current) == null ? void 0 : U.userId) === s.id) {
|
|
121
121
|
l(
|
|
122
122
|
"โ ๏ธ USER CONNECTION SKIPPED",
|
|
123
123
|
"Already connected this user with this service"
|
|
@@ -125,40 +125,40 @@ const fe = we({
|
|
|
125
125
|
return;
|
|
126
126
|
}
|
|
127
127
|
(async () => {
|
|
128
|
-
l("๐ STARTING USER CONNECTION", { userId: s.id }),
|
|
128
|
+
l("๐ STARTING USER CONNECTION", { userId: s.id }), O.current = !0, h(!0), S(null);
|
|
129
129
|
try {
|
|
130
130
|
l("๐ CALLING SERVICE.CONNECTUSER", { userId: s.id });
|
|
131
|
-
const
|
|
132
|
-
g(
|
|
131
|
+
const L = await r.connectUser(s);
|
|
132
|
+
g(L), y(!0), F.current = { serviceId: r, userId: s.id }, l("โ
USER CONNECTION SUCCESS", {
|
|
133
133
|
userId: s.id,
|
|
134
|
-
clientId:
|
|
134
|
+
clientId: L.userID
|
|
135
135
|
});
|
|
136
|
-
} catch (
|
|
137
|
-
const
|
|
138
|
-
S(
|
|
136
|
+
} catch (L) {
|
|
137
|
+
const $ = L instanceof Error ? L.message : "Connection failed";
|
|
138
|
+
S($), l("โ USER CONNECTION ERROR", {
|
|
139
139
|
userId: s.id,
|
|
140
|
-
error:
|
|
140
|
+
error: $
|
|
141
141
|
});
|
|
142
142
|
} finally {
|
|
143
|
-
h(!1),
|
|
143
|
+
h(!1), O.current = !1, l("๐ USER CONNECTION FINISHED", {
|
|
144
144
|
userId: s.id,
|
|
145
145
|
isConnected: m
|
|
146
146
|
});
|
|
147
147
|
}
|
|
148
148
|
})();
|
|
149
|
-
}, [r, s, l, m]),
|
|
149
|
+
}, [r, s, l, m]), _(() => (l("๐ CLEANUP EFFECT REGISTERED", {
|
|
150
150
|
hasService: !!r,
|
|
151
151
|
isConnected: m
|
|
152
152
|
}), () => {
|
|
153
153
|
r && m ? (l(
|
|
154
154
|
"๐งน CLEANUP EFFECT TRIGGERED",
|
|
155
155
|
"Cleaning up connection on unmount"
|
|
156
|
-
),
|
|
156
|
+
), F.current = null, r.disconnectUser().catch(console.error)) : l("๐ CLEANUP EFFECT SKIPPED", {
|
|
157
157
|
hasService: !!r,
|
|
158
158
|
isConnected: m
|
|
159
159
|
});
|
|
160
160
|
}), [r, m, l]);
|
|
161
|
-
const f =
|
|
161
|
+
const f = M(async () => {
|
|
162
162
|
if (l("๐ REFRESH CONNECTION CALLED", {
|
|
163
163
|
hasService: !!r,
|
|
164
164
|
hasUser: !!s
|
|
@@ -170,12 +170,12 @@ const fe = we({
|
|
|
170
170
|
try {
|
|
171
171
|
l("๐ DISCONNECTING FOR REFRESH"), await r.disconnectUser(), l("๐ RECONNECTING FOR REFRESH");
|
|
172
172
|
const w = await r.connectUser(s);
|
|
173
|
-
g(w),
|
|
173
|
+
g(w), y(!0), S(null), l("โ
CONNECTION REFRESH SUCCESS", { userId: s.id });
|
|
174
174
|
} catch (w) {
|
|
175
|
-
const
|
|
176
|
-
S(
|
|
175
|
+
const P = w instanceof Error ? w.message : "Refresh failed";
|
|
176
|
+
S(P), l("โ CONNECTION REFRESH ERROR", {
|
|
177
177
|
userId: s.id,
|
|
178
|
-
error:
|
|
178
|
+
error: P
|
|
179
179
|
});
|
|
180
180
|
} finally {
|
|
181
181
|
h(!1), l("๐ CONNECTION REFRESH FINISHED", { userId: s.id });
|
|
@@ -214,8 +214,8 @@ const fe = we({
|
|
|
214
214
|
renderCount: k.current,
|
|
215
215
|
willRenderChat: !!(u && m),
|
|
216
216
|
contextValueReady: !!x
|
|
217
|
-
}), /* @__PURE__ */ e(fe.Provider, { value: x, children: u && m ? /* @__PURE__ */ e(
|
|
218
|
-
},
|
|
217
|
+
}), /* @__PURE__ */ e(fe.Provider, { value: x, children: u && m ? /* @__PURE__ */ e(Se, { client: u, children: t }) : t });
|
|
218
|
+
}, Ae = () => se();
|
|
219
219
|
function ne({ label: t, className: s, children: n, ...o }) {
|
|
220
220
|
return /* @__PURE__ */ d(
|
|
221
221
|
"button",
|
|
@@ -265,7 +265,7 @@ const de = [
|
|
|
265
265
|
"๐"
|
|
266
266
|
// Melon
|
|
267
267
|
];
|
|
268
|
-
function
|
|
268
|
+
function Be(t) {
|
|
269
269
|
let s = 0;
|
|
270
270
|
for (let n = 0; n < t.length; n++) {
|
|
271
271
|
const o = t.charCodeAt(n);
|
|
@@ -273,8 +273,8 @@ function Ae(t) {
|
|
|
273
273
|
}
|
|
274
274
|
return Math.abs(s);
|
|
275
275
|
}
|
|
276
|
-
function
|
|
277
|
-
const n =
|
|
276
|
+
function He(t) {
|
|
277
|
+
const n = Be(t) % de.length;
|
|
278
278
|
return de[n];
|
|
279
279
|
}
|
|
280
280
|
const J = ({
|
|
@@ -283,7 +283,7 @@ const J = ({
|
|
|
283
283
|
size: n = 40,
|
|
284
284
|
className: o
|
|
285
285
|
}) => {
|
|
286
|
-
const i =
|
|
286
|
+
const i = He(t), c = "#FBFAF9", l = n < 32 ? "text-xs" : n < 56 ? "text-sm" : "text-lg";
|
|
287
287
|
return /* @__PURE__ */ e(
|
|
288
288
|
"div",
|
|
289
289
|
{
|
|
@@ -317,15 +317,15 @@ const J = ({
|
|
|
317
317
|
}
|
|
318
318
|
);
|
|
319
319
|
}, _e = ({ channel: t, selectedChannel: s, onChannelSelect: n, debug: o = !1, unread: i }) => {
|
|
320
|
-
var h, v, S,
|
|
320
|
+
var h, v, S, O, I, k;
|
|
321
321
|
const c = (s == null ? void 0 : s.id) === (t == null ? void 0 : t.id), a = () => {
|
|
322
322
|
t && n(t);
|
|
323
323
|
}, r = Object.values(((h = t == null ? void 0 : t.state) == null ? void 0 : h.members) || {}).find(
|
|
324
|
-
(
|
|
324
|
+
(F) => {
|
|
325
325
|
var f, x;
|
|
326
|
-
return ((f =
|
|
326
|
+
return ((f = F.user) == null ? void 0 : f.id) && F.user.id !== ((x = t == null ? void 0 : t._client) == null ? void 0 : x.userID);
|
|
327
327
|
}
|
|
328
|
-
), b = ((v = r == null ? void 0 : r.user) == null ? void 0 : v.name) || "Conversation", u = (S = r == null ? void 0 : r.user) == null ? void 0 : S.image, g = (
|
|
328
|
+
), b = ((v = r == null ? void 0 : r.user) == null ? void 0 : v.name) || "Conversation", u = (S = r == null ? void 0 : r.user) == null ? void 0 : S.image, g = (I = (O = t == null ? void 0 : t.state) == null ? void 0 : O.messages) == null ? void 0 : I[t.state.messages.length - 1], m = (g == null ? void 0 : g.text) || "No messages yet", y = g != null && g.created_at ? new Date(g.created_at).toLocaleTimeString([], {
|
|
329
329
|
hour: "2-digit",
|
|
330
330
|
minute: "2-digit"
|
|
331
331
|
}) : "", N = i ?? 0;
|
|
@@ -334,7 +334,7 @@ const J = ({
|
|
|
334
334
|
isSelected: c,
|
|
335
335
|
participantName: b,
|
|
336
336
|
unreadCount: N,
|
|
337
|
-
hasTimestamp: !!
|
|
337
|
+
hasTimestamp: !!y
|
|
338
338
|
}), /* @__PURE__ */ e(
|
|
339
339
|
"button",
|
|
340
340
|
{
|
|
@@ -369,7 +369,7 @@ const J = ({
|
|
|
369
369
|
children: b
|
|
370
370
|
}
|
|
371
371
|
),
|
|
372
|
-
|
|
372
|
+
y && /* @__PURE__ */ e("span", { className: "text-xs text-stone flex-shrink-0", children: y })
|
|
373
373
|
] }),
|
|
374
374
|
/* @__PURE__ */ d("div", { className: "flex items-center justify-between gap-2 min-w-0", children: [
|
|
375
375
|
/* @__PURE__ */ e("p", { className: "text-xs text-stone mr-2 flex-1 line-clamp-2", children: m }),
|
|
@@ -397,7 +397,7 @@ const J = ({
|
|
|
397
397
|
showStartConversation: n,
|
|
398
398
|
participantLabel: i
|
|
399
399
|
});
|
|
400
|
-
const { client: r } =
|
|
400
|
+
const { client: r } = Re();
|
|
401
401
|
l && console.log("๐บ [ChannelList] ๐ก CHAT CONTEXT", {
|
|
402
402
|
renderCount: a.current,
|
|
403
403
|
hasClient: !!r,
|
|
@@ -443,17 +443,17 @@ const J = ({
|
|
|
443
443
|
hasClient: !!r,
|
|
444
444
|
clientUserId: r == null ? void 0 : r.userID
|
|
445
445
|
}), /* @__PURE__ */ e(
|
|
446
|
-
|
|
446
|
+
ke,
|
|
447
447
|
{
|
|
448
448
|
filters: b,
|
|
449
449
|
sort: { last_message_at: -1 },
|
|
450
450
|
options: { limit: 30 },
|
|
451
451
|
Preview: (g) => {
|
|
452
|
-
var m,
|
|
452
|
+
var m, y;
|
|
453
453
|
return l && console.log("๐บ [ChannelList] ๐ CHANNEL PREVIEW RENDER", {
|
|
454
454
|
channelId: (m = g.channel) == null ? void 0 : m.id,
|
|
455
455
|
selectedChannelId: s == null ? void 0 : s.id,
|
|
456
|
-
isSelected: (s == null ? void 0 : s.id) === ((
|
|
456
|
+
isSelected: (s == null ? void 0 : s.id) === ((y = g.channel) == null ? void 0 : y.id)
|
|
457
457
|
}), /* @__PURE__ */ e(
|
|
458
458
|
_e,
|
|
459
459
|
{
|
|
@@ -490,15 +490,18 @@ const J = ({
|
|
|
490
490
|
function ge({ onClick: t }) {
|
|
491
491
|
return /* @__PURE__ */ e(ne, { label: "Close", onClick: t, className: "p-1", children: /* @__PURE__ */ e(he, { className: "h-5 w-5 text-stone", weight: "bold" }) });
|
|
492
492
|
}
|
|
493
|
-
const
|
|
493
|
+
const xe = () => /* @__PURE__ */ e("div", { className: "messaging-channel-empty-state flex items-center justify-center h-full p-8 text-balance", children: /* @__PURE__ */ d("div", { className: "text-center max-w-sm", children: [
|
|
494
|
+
/* @__PURE__ */ e("h2", { className: "font-semibold text-charcoal mb-2", children: "No messages yet ๐" }),
|
|
495
|
+
/* @__PURE__ */ e("p", { className: "text-stone text-xs", children: "Share to social media to generate more conversations" })
|
|
496
|
+
] }) }), Ge = ({ renderActions: t }) => /* @__PURE__ */ d("div", { className: "message-input flex items-center gap-2 p-4", children: [
|
|
494
497
|
t && t(),
|
|
495
|
-
/* @__PURE__ */ e("div", { className: "flex-1", children: /* @__PURE__ */ e(
|
|
496
|
-
] }),
|
|
498
|
+
/* @__PURE__ */ e("div", { className: "flex-1", children: /* @__PURE__ */ e(Pe, { focus: !0, maxRows: 4 }) })
|
|
499
|
+
] }), Ve = ({ onBack: t, showBackButton: s, onShowInfo: n, canShowInfo: o }) => {
|
|
497
500
|
var r, b, u, g;
|
|
498
501
|
const { channel: i } = me(), c = X.useMemo(() => Object.values(i.state.members || {}).find(
|
|
499
|
-
(
|
|
502
|
+
(y) => {
|
|
500
503
|
var N;
|
|
501
|
-
return ((N =
|
|
504
|
+
return ((N = y.user) == null ? void 0 : N.id) && y.user.id !== i._client.userID;
|
|
502
505
|
}
|
|
503
506
|
), [i._client.userID, i.state.members]), a = ((r = c == null ? void 0 : c.user) == null ? void 0 : r.name) || ((b = c == null ? void 0 : c.user) == null ? void 0 : b.id) || "Unknown member", l = (u = c == null ? void 0 : c.user) == null ? void 0 : u.image;
|
|
504
507
|
return /* @__PURE__ */ d("div", { className: "flex items-center justify-between gap-3 min-h-12", children: [
|
|
@@ -524,9 +527,9 @@ const He = ({ renderActions: t }) => /* @__PURE__ */ d("div", { className: "mess
|
|
|
524
527
|
),
|
|
525
528
|
/* @__PURE__ */ e("div", { className: "min-w-0", children: /* @__PURE__ */ e("h1", { className: "text-lg font-semibold text-charcoal truncate", children: a }) })
|
|
526
529
|
] }),
|
|
527
|
-
o && n && /* @__PURE__ */ e(ne, { label: "Chat info", onClick: n, children: /* @__PURE__ */ e(
|
|
530
|
+
o && n && /* @__PURE__ */ e(ne, { label: "Chat info", onClick: n, children: /* @__PURE__ */ e(pe, { className: "h-6 w-6 text-charcoal", weight: "bold" }) })
|
|
528
531
|
] });
|
|
529
|
-
},
|
|
532
|
+
}, We = ({
|
|
530
533
|
isOpen: t,
|
|
531
534
|
onClose: s,
|
|
532
535
|
participant: n,
|
|
@@ -535,13 +538,13 @@ const He = ({ renderActions: t }) => /* @__PURE__ */ d("div", { className: "mess
|
|
|
535
538
|
onLeaveConversation: c,
|
|
536
539
|
onBlockParticipant: a
|
|
537
540
|
}) => {
|
|
538
|
-
var
|
|
539
|
-
const { service: l, debug: r } = se(), b =
|
|
540
|
-
|
|
541
|
+
var L, $, G, V, Q, W, z;
|
|
542
|
+
const { service: l, debug: r } = se(), b = H(null), [u, g] = E(!1), [m, y] = E(!1), [N, h] = E(!1);
|
|
543
|
+
_(() => {
|
|
541
544
|
const R = b.current;
|
|
542
545
|
R && (t ? R.showModal() : R.close());
|
|
543
546
|
}, [t]);
|
|
544
|
-
const v =
|
|
547
|
+
const v = M(async () => {
|
|
545
548
|
var R;
|
|
546
549
|
if (!(!l || !((R = n == null ? void 0 : n.user) != null && R.id)))
|
|
547
550
|
try {
|
|
@@ -552,47 +555,47 @@ const He = ({ renderActions: t }) => /* @__PURE__ */ d("div", { className: "mess
|
|
|
552
555
|
}
|
|
553
556
|
);
|
|
554
557
|
g(A);
|
|
555
|
-
} catch (
|
|
558
|
+
} catch (T) {
|
|
556
559
|
console.error(
|
|
557
560
|
"[ChannelInfoDialog] Failed to check blocked status:",
|
|
558
|
-
|
|
561
|
+
T
|
|
559
562
|
);
|
|
560
563
|
}
|
|
561
|
-
}, [l, (
|
|
562
|
-
|
|
564
|
+
}, [l, (L = n == null ? void 0 : n.user) == null ? void 0 : L.id]);
|
|
565
|
+
_(() => {
|
|
563
566
|
t && v();
|
|
564
567
|
}, [t, v]);
|
|
565
568
|
const S = async () => {
|
|
566
569
|
var R;
|
|
567
570
|
if (!m) {
|
|
568
|
-
r && console.log("[ChannelInfoDialog] Leave conversation", o.cid),
|
|
571
|
+
r && console.log("[ChannelInfoDialog] Leave conversation", o.cid), y(!0);
|
|
569
572
|
try {
|
|
570
|
-
const
|
|
571
|
-
await o.hide(
|
|
572
|
-
} catch (
|
|
573
|
-
console.error("[ChannelInfoDialog] Failed to leave conversation",
|
|
573
|
+
const T = ((R = o._client) == null ? void 0 : R.userID) ?? null;
|
|
574
|
+
await o.hide(T, !1), c && await c(o), s();
|
|
575
|
+
} catch (T) {
|
|
576
|
+
console.error("[ChannelInfoDialog] Failed to leave conversation", T);
|
|
574
577
|
} finally {
|
|
575
|
-
|
|
578
|
+
y(!1);
|
|
576
579
|
}
|
|
577
580
|
}
|
|
578
|
-
},
|
|
579
|
-
var R,
|
|
581
|
+
}, O = async () => {
|
|
582
|
+
var R, T, A;
|
|
580
583
|
if (!(N || !l)) {
|
|
581
584
|
r && console.log("[ChannelInfoDialog] Block member", (R = n == null ? void 0 : n.user) == null ? void 0 : R.id), h(!0);
|
|
582
585
|
try {
|
|
583
|
-
await l.blockUser((
|
|
586
|
+
await l.blockUser((T = n == null ? void 0 : n.user) == null ? void 0 : T.id), a && await a((A = n == null ? void 0 : n.user) == null ? void 0 : A.id), s();
|
|
584
587
|
} catch (q) {
|
|
585
588
|
console.error("[ChannelInfoDialog] Failed to block member", q);
|
|
586
589
|
} finally {
|
|
587
590
|
h(!1);
|
|
588
591
|
}
|
|
589
592
|
}
|
|
590
|
-
},
|
|
591
|
-
var R,
|
|
593
|
+
}, I = async () => {
|
|
594
|
+
var R, T, A;
|
|
592
595
|
if (!(N || !l)) {
|
|
593
596
|
r && console.log("[ChannelInfoDialog] Unblock member", (R = n == null ? void 0 : n.user) == null ? void 0 : R.id), h(!0);
|
|
594
597
|
try {
|
|
595
|
-
await l.unBlockUser((
|
|
598
|
+
await l.unBlockUser((T = n == null ? void 0 : n.user) == null ? void 0 : T.id), a && await a((A = n == null ? void 0 : n.user) == null ? void 0 : A.id), s();
|
|
596
599
|
} catch (q) {
|
|
597
600
|
console.error("[ChannelInfoDialog] Failed to unblock member", q);
|
|
598
601
|
} finally {
|
|
@@ -607,7 +610,7 @@ const He = ({ renderActions: t }) => /* @__PURE__ */ d("div", { className: "mess
|
|
|
607
610
|
);
|
|
608
611
|
};
|
|
609
612
|
if (!n) return null;
|
|
610
|
-
const
|
|
613
|
+
const F = (($ = n.user) == null ? void 0 : $.name) || ((G = n.user) == null ? void 0 : G.id) || "Unknown member", f = (V = n.user) == null ? void 0 : V.image, x = (Q = n.user) == null ? void 0 : Q.email, w = (W = n.user) == null ? void 0 : W.username, P = x || (w ? `linktr.ee/${w}` : void 0), U = ((z = n.user) == null ? void 0 : z.id) || "unknown";
|
|
611
614
|
return (
|
|
612
615
|
// eslint-disable-next-line jsx-a11y/click-events-have-key-events, jsx-a11y/no-noninteractive-element-interactions
|
|
613
616
|
/* @__PURE__ */ e(
|
|
@@ -624,21 +627,35 @@ const He = ({ renderActions: t }) => /* @__PURE__ */ d("div", { className: "mess
|
|
|
624
627
|
/* @__PURE__ */ e("h2", { className: "text-base font-semibold text-charcoal", children: "Chat info" }),
|
|
625
628
|
/* @__PURE__ */ e(ge, { onClick: s })
|
|
626
629
|
] }),
|
|
627
|
-
/* @__PURE__ */ d("div", { className: "flex-1 overflow-y-auto
|
|
628
|
-
/* @__PURE__ */ e("div", { className: "
|
|
630
|
+
/* @__PURE__ */ d("div", { className: "flex-1 px-2 overflow-y-auto w-full", children: [
|
|
631
|
+
/* @__PURE__ */ e("div", { className: "flex flex-col items-center gap-3 self-stretch px-4 py-2 mt-6 rounded-lg border border-black/[0.04]", style: { backgroundColor: "#FBFAF9" }, children: /* @__PURE__ */ d("div", { className: "flex items-center gap-3 w-full", children: [
|
|
629
632
|
/* @__PURE__ */ e(
|
|
630
633
|
J,
|
|
631
634
|
{
|
|
632
|
-
id:
|
|
633
|
-
name:
|
|
635
|
+
id: U,
|
|
636
|
+
name: F,
|
|
634
637
|
image: f,
|
|
635
|
-
size:
|
|
638
|
+
size: 88,
|
|
639
|
+
className: "!rounded-full"
|
|
636
640
|
}
|
|
637
641
|
),
|
|
638
|
-
/* @__PURE__ */ d("div", { className: "min-w-0 flex-1", children: [
|
|
639
|
-
/* @__PURE__ */ e("p", { className: "truncate text-base font-semibold text-charcoal", children:
|
|
640
|
-
|
|
641
|
-
i && /* @__PURE__ */ e(
|
|
642
|
+
/* @__PURE__ */ d("div", { className: "flex flex-col min-w-0 flex-1", children: [
|
|
643
|
+
/* @__PURE__ */ e("p", { className: "truncate text-base font-semibold text-charcoal", children: F }),
|
|
644
|
+
P && /* @__PURE__ */ e("p", { className: "truncate text-sm text-[#00000055]", children: P }),
|
|
645
|
+
i && /* @__PURE__ */ e(
|
|
646
|
+
"span",
|
|
647
|
+
{
|
|
648
|
+
className: "mt-1 rounded-full text-xs font-normal w-fit",
|
|
649
|
+
style: {
|
|
650
|
+
padding: "4px 8px",
|
|
651
|
+
backgroundColor: i === "Subscribed to you" ? "#DCFCE7" : "#F5F5F4",
|
|
652
|
+
color: i === "Subscribed to you" ? "#008236" : "#78716C",
|
|
653
|
+
lineHeight: "133.333%",
|
|
654
|
+
letterSpacing: "0.21px"
|
|
655
|
+
},
|
|
656
|
+
children: i
|
|
657
|
+
}
|
|
658
|
+
)
|
|
642
659
|
] })
|
|
643
660
|
] }) }),
|
|
644
661
|
/* @__PURE__ */ d("ul", { className: "flex flex-col gap-2 mt-2", children: [
|
|
@@ -657,7 +674,7 @@ const He = ({ renderActions: t }) => /* @__PURE__ */ d("div", { className: "mess
|
|
|
657
674
|
/* @__PURE__ */ e("li", { children: u ? /* @__PURE__ */ d(
|
|
658
675
|
K,
|
|
659
676
|
{
|
|
660
|
-
onClick:
|
|
677
|
+
onClick: I,
|
|
661
678
|
disabled: N,
|
|
662
679
|
"aria-busy": N,
|
|
663
680
|
children: [
|
|
@@ -668,7 +685,7 @@ const He = ({ renderActions: t }) => /* @__PURE__ */ d("div", { className: "mess
|
|
|
668
685
|
) : /* @__PURE__ */ d(
|
|
669
686
|
K,
|
|
670
687
|
{
|
|
671
|
-
onClick:
|
|
688
|
+
onClick: O,
|
|
672
689
|
disabled: N,
|
|
673
690
|
"aria-busy": N,
|
|
674
691
|
children: [
|
|
@@ -687,28 +704,31 @@ const He = ({ renderActions: t }) => /* @__PURE__ */ d("div", { className: "mess
|
|
|
687
704
|
}
|
|
688
705
|
)
|
|
689
706
|
);
|
|
690
|
-
},
|
|
707
|
+
}, ze = ({
|
|
691
708
|
onBack: t,
|
|
692
709
|
showBackButton: s,
|
|
693
710
|
renderMessageInputActions: n,
|
|
694
711
|
onLeaveConversation: o,
|
|
695
712
|
onBlockParticipant: i,
|
|
696
|
-
CustomChannelEmptyState: c
|
|
713
|
+
CustomChannelEmptyState: c = xe
|
|
697
714
|
}) => {
|
|
698
|
-
var m,
|
|
699
|
-
const { channel: a } = me(), [l, r] = E(!1), b = (((
|
|
715
|
+
var m, y;
|
|
716
|
+
const { channel: a } = me(), [l, r] = E(!1), b = (((y = (m = a == null ? void 0 : a.state) == null ? void 0 : m.messages) == null ? void 0 : y.length) ?? 0) > 0, u = X.useMemo(() => Object.values(a.state.members || {}).find(
|
|
700
717
|
(h) => {
|
|
701
718
|
var v;
|
|
702
719
|
return ((v = h.user) == null ? void 0 : v.id) && h.user.id !== a._client.userID;
|
|
703
720
|
}
|
|
704
721
|
), [a._client.userID, a.state.members]), g = X.useMemo(() => {
|
|
705
722
|
const N = a.data ?? {};
|
|
706
|
-
|
|
723
|
+
if (N.followerStatus)
|
|
724
|
+
return String(N.followerStatus);
|
|
725
|
+
if (N.isFollower !== void 0)
|
|
726
|
+
return N.isFollower ? "Subscribed to you" : "Not subscribed";
|
|
707
727
|
}, [a.data]);
|
|
708
728
|
return /* @__PURE__ */ d(oe, { children: [
|
|
709
729
|
/* @__PURE__ */ d(Te, { children: [
|
|
710
730
|
/* @__PURE__ */ e("div", { className: "border-b border-sand bg-white px-4 py-3", children: /* @__PURE__ */ e(
|
|
711
|
-
|
|
731
|
+
Ve,
|
|
712
732
|
{
|
|
713
733
|
onBack: t,
|
|
714
734
|
showBackButton: s,
|
|
@@ -717,18 +737,18 @@ const He = ({ renderActions: t }) => /* @__PURE__ */ d("div", { className: "mess
|
|
|
717
737
|
}
|
|
718
738
|
) }),
|
|
719
739
|
/* @__PURE__ */ d("div", { className: "flex-1 overflow-hidden relative", children: [
|
|
720
|
-
/* @__PURE__ */ e(
|
|
721
|
-
!b && c && /* @__PURE__ */ e("div", { className: "absolute inset-0
|
|
740
|
+
/* @__PURE__ */ e(De, { hideDeletedMessages: !0, hideNewMessageSeparator: !1 }),
|
|
741
|
+
!b && c && /* @__PURE__ */ e("div", { className: "absolute inset-0 w-full h-full bg-white", children: /* @__PURE__ */ e(c, {}) })
|
|
722
742
|
] }),
|
|
723
743
|
/* @__PURE__ */ e(
|
|
724
|
-
|
|
744
|
+
Ge,
|
|
725
745
|
{
|
|
726
746
|
renderActions: () => n == null ? void 0 : n(a)
|
|
727
747
|
}
|
|
728
748
|
)
|
|
729
749
|
] }),
|
|
730
750
|
/* @__PURE__ */ e(
|
|
731
|
-
|
|
751
|
+
We,
|
|
732
752
|
{
|
|
733
753
|
isOpen: l,
|
|
734
754
|
onClose: () => r(!1),
|
|
@@ -740,7 +760,7 @@ const He = ({ renderActions: t }) => /* @__PURE__ */ d("div", { className: "mess
|
|
|
740
760
|
}
|
|
741
761
|
)
|
|
742
762
|
] });
|
|
743
|
-
},
|
|
763
|
+
}, qe = ({
|
|
744
764
|
channel: t,
|
|
745
765
|
onBack: s,
|
|
746
766
|
showBackButton: n = !1,
|
|
@@ -748,7 +768,7 @@ const He = ({ renderActions: t }) => /* @__PURE__ */ d("div", { className: "mess
|
|
|
748
768
|
onLeaveConversation: i,
|
|
749
769
|
onBlockParticipant: c,
|
|
750
770
|
className: a,
|
|
751
|
-
CustomChannelEmptyState: l
|
|
771
|
+
CustomChannelEmptyState: l = xe
|
|
752
772
|
}) => /* @__PURE__ */ e(
|
|
753
773
|
"div",
|
|
754
774
|
{
|
|
@@ -756,8 +776,8 @@ const He = ({ renderActions: t }) => /* @__PURE__ */ d("div", { className: "mess
|
|
|
756
776
|
"messaging-channel-view h-full flex flex-col",
|
|
757
777
|
a
|
|
758
778
|
),
|
|
759
|
-
children: /* @__PURE__ */ e(
|
|
760
|
-
|
|
779
|
+
children: /* @__PURE__ */ e(Fe, { channel: t, children: /* @__PURE__ */ e(
|
|
780
|
+
ze,
|
|
761
781
|
{
|
|
762
782
|
onBack: s,
|
|
763
783
|
showBackButton: n,
|
|
@@ -769,15 +789,15 @@ const He = ({ renderActions: t }) => /* @__PURE__ */ d("div", { className: "mess
|
|
|
769
789
|
) })
|
|
770
790
|
}
|
|
771
791
|
);
|
|
772
|
-
function
|
|
792
|
+
function Xe({
|
|
773
793
|
searchQuery: t,
|
|
774
794
|
setSearchQuery: s,
|
|
775
795
|
placeholder: n
|
|
776
796
|
}) {
|
|
777
|
-
const o =
|
|
797
|
+
const o = H(null);
|
|
778
798
|
return /* @__PURE__ */ d("div", { className: "relative", children: [
|
|
779
799
|
/* @__PURE__ */ e(
|
|
780
|
-
|
|
800
|
+
je,
|
|
781
801
|
{
|
|
782
802
|
className: "pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-stone",
|
|
783
803
|
weight: "bold"
|
|
@@ -808,7 +828,7 @@ function qe({
|
|
|
808
828
|
)
|
|
809
829
|
] });
|
|
810
830
|
}
|
|
811
|
-
const
|
|
831
|
+
const Qe = ({
|
|
812
832
|
participantSource: t,
|
|
813
833
|
onSelectParticipant: s,
|
|
814
834
|
onClose: n,
|
|
@@ -817,26 +837,26 @@ const Xe = ({
|
|
|
817
837
|
searchPlaceholder: c = "Search participants...",
|
|
818
838
|
className: a
|
|
819
839
|
}) => {
|
|
820
|
-
const { debug: l } = se(), [r, b] = E(""), [u, g] = E([]), [m,
|
|
840
|
+
const { debug: l } = se(), [r, b] = E(""), [u, g] = E([]), [m, y] = E(!1), [N, h] = E(null), [v, S] = E(
|
|
821
841
|
null
|
|
822
|
-
),
|
|
823
|
-
|
|
842
|
+
), O = H(!1);
|
|
843
|
+
_(() => {
|
|
824
844
|
if (t.loading) {
|
|
825
845
|
l && console.log(
|
|
826
846
|
"[ParticipantPicker] Waiting for participant source to finish loading..."
|
|
827
847
|
);
|
|
828
848
|
return;
|
|
829
849
|
}
|
|
830
|
-
if (
|
|
850
|
+
if (O.current) return;
|
|
831
851
|
(async () => {
|
|
832
|
-
l && console.log("[ParticipantPicker] Loading initial participants..."),
|
|
852
|
+
l && console.log("[ParticipantPicker] Loading initial participants..."), y(!0), h(null);
|
|
833
853
|
try {
|
|
834
854
|
const x = await t.loadParticipants({
|
|
835
855
|
search: "",
|
|
836
856
|
// Load all participants initially
|
|
837
857
|
limit: 100
|
|
838
858
|
});
|
|
839
|
-
g(x.participants),
|
|
859
|
+
g(x.participants), O.current = !0, l && console.log(
|
|
840
860
|
"[ParticipantPicker] Participants loaded successfully:",
|
|
841
861
|
x.participants.length
|
|
842
862
|
);
|
|
@@ -844,16 +864,16 @@ const Xe = ({
|
|
|
844
864
|
const w = x instanceof Error ? x.message : "Failed to load participants";
|
|
845
865
|
h(w), console.error("[ParticipantPicker] Failed to load participants:", x);
|
|
846
866
|
} finally {
|
|
847
|
-
|
|
867
|
+
y(!1);
|
|
848
868
|
}
|
|
849
869
|
})();
|
|
850
870
|
}, [t.loading, l]);
|
|
851
|
-
const
|
|
871
|
+
const I = u.filter((f) => !o.has(f.id)).filter((f) => {
|
|
852
872
|
var w;
|
|
853
873
|
if (!r) return !0;
|
|
854
874
|
const x = r.toLowerCase();
|
|
855
875
|
return f.name.toLowerCase().includes(x) || ((w = f.email) == null ? void 0 : w.toLowerCase().includes(x)) || !1;
|
|
856
|
-
}), k =
|
|
876
|
+
}), k = M(
|
|
857
877
|
async (f) => {
|
|
858
878
|
if (!v) {
|
|
859
879
|
S(f.id);
|
|
@@ -865,7 +885,7 @@ const Xe = ({
|
|
|
865
885
|
}
|
|
866
886
|
},
|
|
867
887
|
[s, v]
|
|
868
|
-
),
|
|
888
|
+
), F = (f, x) => {
|
|
869
889
|
(f.key === "Enter" || f.key === " ") && (f.preventDefault(), k(x));
|
|
870
890
|
};
|
|
871
891
|
return /* @__PURE__ */ d("div", { className: D("flex flex-col h-full", a), children: [
|
|
@@ -878,12 +898,12 @@ const Xe = ({
|
|
|
878
898
|
"Select a ",
|
|
879
899
|
i.slice(0, -1),
|
|
880
900
|
" to start messaging (",
|
|
881
|
-
|
|
901
|
+
I.length,
|
|
882
902
|
" available)",
|
|
883
903
|
t.totalCount !== void 0 && ` โข ${t.totalCount} ${i} total`
|
|
884
904
|
] }),
|
|
885
905
|
/* @__PURE__ */ e(
|
|
886
|
-
|
|
906
|
+
Xe,
|
|
887
907
|
{
|
|
888
908
|
searchQuery: r,
|
|
889
909
|
setSearchQuery: b,
|
|
@@ -897,26 +917,26 @@ const Xe = ({
|
|
|
897
917
|
": ",
|
|
898
918
|
N
|
|
899
919
|
] }),
|
|
900
|
-
/* @__PURE__ */ e("div", { className: "flex-1 overflow-auto", children: m &&
|
|
920
|
+
/* @__PURE__ */ e("div", { className: "flex-1 overflow-auto", children: m && I.length === 0 ? /* @__PURE__ */ e("div", { className: "h-32 flex items-center justify-center", children: /* @__PURE__ */ d("div", { className: "flex items-center space-x-2", children: [
|
|
901
921
|
/* @__PURE__ */ e("div", { className: "w-4 h-4 animate-spin rounded-full border-2 border-primary border-t-transparent" }),
|
|
902
922
|
/* @__PURE__ */ d("span", { className: "text-sm text-stone", children: [
|
|
903
923
|
"Loading ",
|
|
904
924
|
i,
|
|
905
925
|
"..."
|
|
906
926
|
] })
|
|
907
|
-
] }) }) :
|
|
927
|
+
] }) }) : I.length === 0 ? /* @__PURE__ */ d("div", { className: "p-6 text-center", children: [
|
|
908
928
|
/* @__PURE__ */ e("div", { className: "mx-auto mb-4 flex h-16 w-16 items-center justify-center rounded-full bg-sand", children: /* @__PURE__ */ e(ce, { className: "h-8 w-8 text-charcoal" }) }),
|
|
909
929
|
/* @__PURE__ */ e("h3", { className: "text-sm font-semibold text-charcoal mb-2", children: r ? `No ${i} found` : u.length > 0 ? `Already chatting with all ${i}` : `No ${i} yet` }),
|
|
910
930
|
/* @__PURE__ */ e("p", { className: "text-xs text-stone", children: r ? "Try a different search term" : u.length > 0 ? `You have existing conversations with all your ${i}` : `${i.charAt(0).toUpperCase() + i.slice(1)} will appear here` })
|
|
911
931
|
] }) : /* @__PURE__ */ d("ul", { className: "space-y-0", children: [
|
|
912
|
-
|
|
932
|
+
I.map((f) => {
|
|
913
933
|
const x = f.name || f.email || f.id, w = f.email && f.name ? f.email : f.phone;
|
|
914
934
|
return /* @__PURE__ */ e("li", { children: /* @__PURE__ */ e(
|
|
915
935
|
"button",
|
|
916
936
|
{
|
|
917
937
|
type: "button",
|
|
918
938
|
onClick: () => k(f),
|
|
919
|
-
onKeyDown: (
|
|
939
|
+
onKeyDown: (P) => F(P, f),
|
|
920
940
|
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",
|
|
921
941
|
children: /* @__PURE__ */ d("div", { className: "flex items-center justify-between", children: [
|
|
922
942
|
/* @__PURE__ */ d("div", { className: "flex items-center space-x-3 flex-1 min-w-0", children: [
|
|
@@ -945,7 +965,7 @@ const Xe = ({
|
|
|
945
965
|
] }) })
|
|
946
966
|
] }) })
|
|
947
967
|
] });
|
|
948
|
-
},
|
|
968
|
+
}, Ze = ({ hasChannels: t, onStartConversation: s, participantLabel: n }) => /* @__PURE__ */ e("div", { className: "messaging-empty-state flex items-center justify-center h-full p-8 text-balance", children: /* @__PURE__ */ d("div", { className: "text-center max-w-sm", children: [
|
|
949
969
|
/* @__PURE__ */ e("div", { className: "w-24 h-24 bg-primary-alt/10 rounded-full flex items-center justify-center mx-auto mb-6", children: /* @__PURE__ */ e("span", { className: "text-4xl", children: "๐ฌ" }) }),
|
|
950
970
|
/* @__PURE__ */ e("h2", { className: "font-semibold text-charcoal", children: "Welcome to Messages" }),
|
|
951
971
|
/* @__PURE__ */ e("p", { className: "text-stone text-sm mb-6", children: t ? /* @__PURE__ */ d(oe, { children: [
|
|
@@ -988,7 +1008,7 @@ const Xe = ({
|
|
|
988
1008
|
children: "Go Back"
|
|
989
1009
|
}
|
|
990
1010
|
)
|
|
991
|
-
] }) }),
|
|
1011
|
+
] }) }), Je = ({ className: t, message: s }) => /* @__PURE__ */ d(
|
|
992
1012
|
"div",
|
|
993
1013
|
{
|
|
994
1014
|
className: D("flex items-center justify-center h-full", t),
|
|
@@ -1031,10 +1051,10 @@ const Xe = ({
|
|
|
1031
1051
|
s && /* @__PURE__ */ e("span", { className: "text-stone", children: s })
|
|
1032
1052
|
]
|
|
1033
1053
|
}
|
|
1034
|
-
),
|
|
1035
|
-
/* @__PURE__ */ e(
|
|
1054
|
+
), Ye = () => /* @__PURE__ */ e("div", { className: "messaging-loading-state flex items-center justify-center h-full", children: /* @__PURE__ */ d("div", { className: "flex items-center", children: [
|
|
1055
|
+
/* @__PURE__ */ e(Je, { className: "w-6 h-6" }),
|
|
1036
1056
|
/* @__PURE__ */ e("span", { className: "text-sm text-stone", children: "Loading messages" })
|
|
1037
|
-
] }) }),
|
|
1057
|
+
] }) }), as = ({
|
|
1038
1058
|
capabilities: t = {},
|
|
1039
1059
|
className: s,
|
|
1040
1060
|
renderMessageInputActions: n,
|
|
@@ -1050,14 +1070,14 @@ const Xe = ({
|
|
|
1050
1070
|
client: u,
|
|
1051
1071
|
isConnected: g,
|
|
1052
1072
|
isLoading: m,
|
|
1053
|
-
error:
|
|
1073
|
+
error: y,
|
|
1054
1074
|
refreshConnection: N,
|
|
1055
1075
|
debug: h
|
|
1056
|
-
} =
|
|
1076
|
+
} = Ae(), [v, S] = E(null), [O, I] = E(!1), [k, F] = E(!1), [f, x] = E(/* @__PURE__ */ new Set()), [w, P] = E(0), [U, L] = E(!1), [$, G] = E(null), V = H(null), {
|
|
1057
1077
|
showStartConversation: Q = !1,
|
|
1058
1078
|
participantSource: W,
|
|
1059
1079
|
participantLabel: z = "participants"
|
|
1060
|
-
} = t, R =
|
|
1080
|
+
} = t, R = H(null), T = M(async () => {
|
|
1061
1081
|
if (!u || !g) return;
|
|
1062
1082
|
const C = u.userID;
|
|
1063
1083
|
if (C)
|
|
@@ -1070,27 +1090,27 @@ const Xe = ({
|
|
|
1070
1090
|
},
|
|
1071
1091
|
{},
|
|
1072
1092
|
{ limit: 100 }
|
|
1073
|
-
),
|
|
1093
|
+
), p = /* @__PURE__ */ new Set();
|
|
1074
1094
|
j.forEach((B) => {
|
|
1075
|
-
const
|
|
1076
|
-
Object.values(
|
|
1095
|
+
const ve = B.state.members;
|
|
1096
|
+
Object.values(ve).forEach((we) => {
|
|
1077
1097
|
var ae;
|
|
1078
|
-
const re = (ae =
|
|
1079
|
-
re && re !== C &&
|
|
1098
|
+
const re = (ae = we.user) == null ? void 0 : ae.id;
|
|
1099
|
+
re && re !== C && p.add(re);
|
|
1080
1100
|
});
|
|
1081
|
-
}), x(
|
|
1101
|
+
}), x(p), I(j.length > 0), R.current = C, h && console.log("[MessagingShell] Channels synced successfully:", {
|
|
1082
1102
|
channelCount: j.length,
|
|
1083
|
-
memberCount:
|
|
1103
|
+
memberCount: p.size
|
|
1084
1104
|
});
|
|
1085
1105
|
} catch (j) {
|
|
1086
1106
|
console.error("[MessagingShell] Failed to sync channels:", j);
|
|
1087
1107
|
}
|
|
1088
1108
|
}, [u, g, h]);
|
|
1089
|
-
|
|
1109
|
+
_(() => {
|
|
1090
1110
|
if (!u || !g) return;
|
|
1091
1111
|
const C = u.userID;
|
|
1092
|
-
C && R.current !== C &&
|
|
1093
|
-
}, [u, g,
|
|
1112
|
+
C && R.current !== C && T();
|
|
1113
|
+
}, [u, g, T]), _(() => {
|
|
1094
1114
|
if (!c || !u || !g) return;
|
|
1095
1115
|
(async () => {
|
|
1096
1116
|
const j = u.userID;
|
|
@@ -1100,7 +1120,7 @@ const Xe = ({
|
|
|
1100
1120
|
"[MessagingShell] Loading initial conversation with:",
|
|
1101
1121
|
c
|
|
1102
1122
|
);
|
|
1103
|
-
const
|
|
1123
|
+
const p = await u.queryChannels(
|
|
1104
1124
|
{
|
|
1105
1125
|
type: "messaging",
|
|
1106
1126
|
members: { $eq: [j, c] }
|
|
@@ -1108,10 +1128,10 @@ const Xe = ({
|
|
|
1108
1128
|
{},
|
|
1109
1129
|
{ limit: 1 }
|
|
1110
1130
|
);
|
|
1111
|
-
if (
|
|
1112
|
-
S(
|
|
1131
|
+
if (p.length > 0)
|
|
1132
|
+
S(p[0]), L(!0), G(null), o && o(p[0]), h && console.log(
|
|
1113
1133
|
"[MessagingShell] Initial conversation loaded:",
|
|
1114
|
-
|
|
1134
|
+
p[0].id
|
|
1115
1135
|
);
|
|
1116
1136
|
else if (a && b) {
|
|
1117
1137
|
h && console.log(
|
|
@@ -1125,7 +1145,7 @@ const Xe = ({
|
|
|
1125
1145
|
email: a.email,
|
|
1126
1146
|
phone: a.phone
|
|
1127
1147
|
});
|
|
1128
|
-
S(B),
|
|
1148
|
+
S(B), L(!0), G(null), o && o(B), h && console.log(
|
|
1129
1149
|
"[MessagingShell] Channel created and loaded:",
|
|
1130
1150
|
B.id
|
|
1131
1151
|
);
|
|
@@ -1142,10 +1162,10 @@ const Xe = ({
|
|
|
1142
1162
|
"[MessagingShell] No conversation found for:",
|
|
1143
1163
|
c
|
|
1144
1164
|
);
|
|
1145
|
-
} catch (
|
|
1165
|
+
} catch (p) {
|
|
1146
1166
|
console.error(
|
|
1147
1167
|
"[MessagingShell] Failed to load initial conversation:",
|
|
1148
|
-
|
|
1168
|
+
p
|
|
1149
1169
|
), G("Failed to load conversation");
|
|
1150
1170
|
}
|
|
1151
1171
|
})();
|
|
@@ -1158,17 +1178,17 @@ const Xe = ({
|
|
|
1158
1178
|
h,
|
|
1159
1179
|
o
|
|
1160
1180
|
]);
|
|
1161
|
-
const A =
|
|
1181
|
+
const A = M(
|
|
1162
1182
|
(C) => {
|
|
1163
1183
|
S(C), o == null || o(C);
|
|
1164
1184
|
},
|
|
1165
1185
|
[o]
|
|
1166
|
-
), q =
|
|
1167
|
-
|
|
1168
|
-
}, [
|
|
1186
|
+
), q = M(() => {
|
|
1187
|
+
U || S(null);
|
|
1188
|
+
}, [U]), Z = M(() => {
|
|
1169
1189
|
var C;
|
|
1170
|
-
W && (
|
|
1171
|
-
}, [W]),
|
|
1190
|
+
W && (P((j) => j + 1), F(!0), (C = V.current) == null || C.showModal());
|
|
1191
|
+
}, [W]), Ne = M(
|
|
1172
1192
|
async (C) => {
|
|
1173
1193
|
var j;
|
|
1174
1194
|
if (b)
|
|
@@ -1177,44 +1197,44 @@ const Xe = ({
|
|
|
1177
1197
|
"[MessagingShell] Starting conversation with:",
|
|
1178
1198
|
C.id
|
|
1179
1199
|
);
|
|
1180
|
-
const
|
|
1200
|
+
const p = await b.startChannelWithParticipant({
|
|
1181
1201
|
id: C.id,
|
|
1182
1202
|
name: C.name,
|
|
1183
1203
|
email: C.email,
|
|
1184
1204
|
phone: C.phone
|
|
1185
1205
|
});
|
|
1186
1206
|
try {
|
|
1187
|
-
await
|
|
1207
|
+
await p.show();
|
|
1188
1208
|
} catch (B) {
|
|
1189
1209
|
console.warn("[MessagingShell] Failed to unhide channel:", B);
|
|
1190
1210
|
}
|
|
1191
|
-
S(
|
|
1192
|
-
} catch (
|
|
1193
|
-
console.error("[MessagingShell] Failed to start conversation:",
|
|
1211
|
+
S(p), F(!1), (j = V.current) == null || j.close(), i == null || i(C);
|
|
1212
|
+
} catch (p) {
|
|
1213
|
+
console.error("[MessagingShell] Failed to start conversation:", p);
|
|
1194
1214
|
}
|
|
1195
1215
|
},
|
|
1196
1216
|
[b, i, h]
|
|
1197
|
-
), te =
|
|
1217
|
+
), te = M(() => {
|
|
1198
1218
|
var C;
|
|
1199
|
-
|
|
1200
|
-
}, []),
|
|
1219
|
+
F(!1), (C = V.current) == null || C.close();
|
|
1220
|
+
}, []), be = M(
|
|
1201
1221
|
async (C) => {
|
|
1202
|
-
h && console.log("[MessagingShell] Leaving conversation:", C.id), S(null),
|
|
1222
|
+
h && console.log("[MessagingShell] Leaving conversation:", C.id), S(null), L(!1), R.current = null, await T();
|
|
1203
1223
|
},
|
|
1204
|
-
[
|
|
1205
|
-
),
|
|
1224
|
+
[T, h]
|
|
1225
|
+
), Ce = M(
|
|
1206
1226
|
async (C) => {
|
|
1207
|
-
h && console.log("[MessagingShell] Blocking participant:", C), S(null),
|
|
1227
|
+
h && console.log("[MessagingShell] Blocking participant:", C), S(null), L(!1), R.current = null, await T();
|
|
1208
1228
|
},
|
|
1209
|
-
[
|
|
1229
|
+
[T, h]
|
|
1210
1230
|
), Y = !!v;
|
|
1211
|
-
return m ? /* @__PURE__ */ e("div", { className: D("h-full", s), children: /* @__PURE__ */ e(
|
|
1231
|
+
return m ? /* @__PURE__ */ e("div", { className: D("h-full", s), children: /* @__PURE__ */ e(Ye, {}) }) : y ? /* @__PURE__ */ e("div", { className: D("h-full", s), children: /* @__PURE__ */ e(le, { message: y, onBack: N }) }) : !g || !u ? /* @__PURE__ */ e("div", { className: D("h-full", s), children: /* @__PURE__ */ e(
|
|
1212
1232
|
le,
|
|
1213
1233
|
{
|
|
1214
1234
|
message: "Not connected to messaging service",
|
|
1215
1235
|
onBack: N
|
|
1216
1236
|
}
|
|
1217
|
-
) }) :
|
|
1237
|
+
) }) : $ ? /* @__PURE__ */ e("div", { className: D("h-full", s), children: /* @__PURE__ */ e(le, { message: $ }) }) : /* @__PURE__ */ d(
|
|
1218
1238
|
"div",
|
|
1219
1239
|
{
|
|
1220
1240
|
className: D(
|
|
@@ -1230,11 +1250,11 @@ const Xe = ({
|
|
|
1230
1250
|
"messaging-channel-list-sidebar min-h-0 min-w-0 bg-white lg:bg-chalk lg:flex lg:flex-col lg:border-r lg:border-sand",
|
|
1231
1251
|
{
|
|
1232
1252
|
// Explicitly hidden via prop or in direct conversation mode
|
|
1233
|
-
"!hidden": r === !1 ||
|
|
1253
|
+
"!hidden": r === !1 || U,
|
|
1234
1254
|
// Normal mode: hide on mobile when channel selected, show on desktop
|
|
1235
|
-
"hidden lg:flex lg:w-80 lg:min-w-[280px] lg:max-w-[360px]": r !== !1 && !
|
|
1255
|
+
"hidden lg:flex lg:w-80 lg:min-w-[280px] lg:max-w-[360px]": r !== !1 && !U && Y,
|
|
1236
1256
|
// Normal mode: show when no channel selected
|
|
1237
|
-
"flex flex-col w-full lg:flex-1 lg:max-w-2xl": r !== !1 && !
|
|
1257
|
+
"flex flex-col w-full lg:flex-1 lg:max-w-2xl": r !== !1 && !U && !Y
|
|
1238
1258
|
}
|
|
1239
1259
|
),
|
|
1240
1260
|
children: /* @__PURE__ */ e(
|
|
@@ -1256,27 +1276,27 @@ const Xe = ({
|
|
|
1256
1276
|
"messaging-conversation-view flex-1 flex-col min-w-0 min-h-0",
|
|
1257
1277
|
{
|
|
1258
1278
|
// In direct conversation mode, always show (full width)
|
|
1259
|
-
flex:
|
|
1279
|
+
flex: U || Y,
|
|
1260
1280
|
// Normal mode: hide on mobile when no channel selected
|
|
1261
|
-
"hidden lg:flex": !
|
|
1281
|
+
"hidden lg:flex": !U && !Y
|
|
1262
1282
|
}
|
|
1263
1283
|
),
|
|
1264
1284
|
children: v ? /* @__PURE__ */ e("div", { className: "flex-1 min-h-0 flex flex-col", children: /* @__PURE__ */ e(
|
|
1265
|
-
|
|
1285
|
+
qe,
|
|
1266
1286
|
{
|
|
1267
1287
|
channel: v,
|
|
1268
1288
|
onBack: q,
|
|
1269
|
-
showBackButton: !
|
|
1289
|
+
showBackButton: !U,
|
|
1270
1290
|
renderMessageInputActions: n,
|
|
1271
|
-
onLeaveConversation:
|
|
1272
|
-
onBlockParticipant:
|
|
1291
|
+
onLeaveConversation: be,
|
|
1292
|
+
onBlockParticipant: Ce,
|
|
1273
1293
|
CustomChannelEmptyState: l
|
|
1274
1294
|
},
|
|
1275
1295
|
v.id
|
|
1276
1296
|
) }) : /* @__PURE__ */ e(
|
|
1277
|
-
|
|
1297
|
+
Ze,
|
|
1278
1298
|
{
|
|
1279
|
-
hasChannels:
|
|
1299
|
+
hasChannels: O,
|
|
1280
1300
|
onStartConversation: Q ? Z : void 0,
|
|
1281
1301
|
participantLabel: z
|
|
1282
1302
|
}
|
|
@@ -1295,10 +1315,10 @@ const Xe = ({
|
|
|
1295
1315
|
},
|
|
1296
1316
|
onClose: te,
|
|
1297
1317
|
children: /* @__PURE__ */ e("div", { className: "h-full w-full bg-white shadow-max-elevation-light", children: /* @__PURE__ */ e(
|
|
1298
|
-
|
|
1318
|
+
Qe,
|
|
1299
1319
|
{
|
|
1300
1320
|
participantSource: W,
|
|
1301
|
-
onSelectParticipant:
|
|
1321
|
+
onSelectParticipant: Ne,
|
|
1302
1322
|
onClose: te,
|
|
1303
1323
|
existingParticipantIds: f,
|
|
1304
1324
|
participantLabel: z,
|
|
@@ -1311,7 +1331,7 @@ const Xe = ({
|
|
|
1311
1331
|
]
|
|
1312
1332
|
}
|
|
1313
1333
|
);
|
|
1314
|
-
},
|
|
1334
|
+
}, Ke = ({
|
|
1315
1335
|
question: t,
|
|
1316
1336
|
onClick: s,
|
|
1317
1337
|
loading: n = !1,
|
|
@@ -1333,7 +1353,7 @@ const Xe = ({
|
|
|
1333
1353
|
),
|
|
1334
1354
|
children: t
|
|
1335
1355
|
}
|
|
1336
|
-
),
|
|
1356
|
+
), is = ({
|
|
1337
1357
|
faqs: t,
|
|
1338
1358
|
onFaqClick: s,
|
|
1339
1359
|
loadingFaqId: n,
|
|
@@ -1361,7 +1381,7 @@ const Xe = ({
|
|
|
1361
1381
|
children: [
|
|
1362
1382
|
o && /* @__PURE__ */ e("p", { className: "text-md text-charcoal mb-4", children: o }),
|
|
1363
1383
|
l.map((r) => /* @__PURE__ */ e(
|
|
1364
|
-
|
|
1384
|
+
Ke,
|
|
1365
1385
|
{
|
|
1366
1386
|
question: r.question,
|
|
1367
1387
|
onClick: () => s(r.id),
|
|
@@ -1373,10 +1393,10 @@ const Xe = ({
|
|
|
1373
1393
|
}
|
|
1374
1394
|
)
|
|
1375
1395
|
] }) });
|
|
1376
|
-
},
|
|
1377
|
-
const { initialSearch: n = "", pageSize: o = 20 } = s, [i, c] = E([]), [a, l] = E(!1), [r, b] = E(null), [u, g] = E(n), [m,
|
|
1396
|
+
}, cs = (t, s = {}) => {
|
|
1397
|
+
const { initialSearch: n = "", pageSize: o = 20 } = s, [i, c] = E([]), [a, l] = E(!1), [r, b] = E(null), [u, g] = E(n), [m, y] = E(!0), [N, h] = E(), v = M(async (k = !1, F) => {
|
|
1378
1398
|
if (a) return;
|
|
1379
|
-
const f =
|
|
1399
|
+
const f = F !== void 0 ? F : u;
|
|
1380
1400
|
l(!0), b(null);
|
|
1381
1401
|
try {
|
|
1382
1402
|
const x = await t.loadParticipants({
|
|
@@ -1386,21 +1406,21 @@ const Xe = ({
|
|
|
1386
1406
|
});
|
|
1387
1407
|
c(
|
|
1388
1408
|
(w) => k ? x.participants : [...w, ...x.participants]
|
|
1389
|
-
),
|
|
1409
|
+
), y(x.hasMore), h(x.nextCursor);
|
|
1390
1410
|
} catch (x) {
|
|
1391
1411
|
const w = x instanceof Error ? x.message : "Failed to load participants";
|
|
1392
1412
|
b(w), console.error("[useParticipants] Load error:", x);
|
|
1393
1413
|
} finally {
|
|
1394
1414
|
l(!1);
|
|
1395
1415
|
}
|
|
1396
|
-
}, [t, u, N, o, a]), S =
|
|
1416
|
+
}, [t, u, N, o, a]), S = M(() => {
|
|
1397
1417
|
m && !a && v(!1);
|
|
1398
|
-
}, [m, a, v]),
|
|
1418
|
+
}, [m, a, v]), O = M((k) => {
|
|
1399
1419
|
g(k), h(void 0), v(!0, k);
|
|
1400
|
-
}, [v]),
|
|
1420
|
+
}, [v]), I = M(() => {
|
|
1401
1421
|
h(void 0), v(!0);
|
|
1402
1422
|
}, [v]);
|
|
1403
|
-
return
|
|
1423
|
+
return _(() => {
|
|
1404
1424
|
v(!0);
|
|
1405
1425
|
}, [t.loadParticipants]), {
|
|
1406
1426
|
participants: i,
|
|
@@ -1410,20 +1430,21 @@ const Xe = ({
|
|
|
1410
1430
|
hasMore: m,
|
|
1411
1431
|
totalCount: t.totalCount,
|
|
1412
1432
|
loadMore: S,
|
|
1413
|
-
search:
|
|
1414
|
-
refresh:
|
|
1433
|
+
search: O,
|
|
1434
|
+
refresh: I
|
|
1415
1435
|
};
|
|
1416
1436
|
};
|
|
1417
1437
|
export {
|
|
1418
1438
|
J as Avatar,
|
|
1439
|
+
xe as ChannelEmptyState,
|
|
1419
1440
|
$e as ChannelList,
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1441
|
+
qe as ChannelView,
|
|
1442
|
+
is as FaqList,
|
|
1443
|
+
Ke as FaqListItem,
|
|
1444
|
+
os as MessagingProvider,
|
|
1445
|
+
as as MessagingShell,
|
|
1446
|
+
Qe as ParticipantPicker,
|
|
1447
|
+
Ae as useMessaging,
|
|
1448
|
+
cs as useParticipants
|
|
1428
1449
|
};
|
|
1429
1450
|
//# sourceMappingURL=index.js.map
|