@linktr.ee/messaging-react 1.6.4 โ 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 +245 -219
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/components/ChannelList/index.tsx +7 -2
- 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,7 +37,7 @@ 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,
|
|
@@ -48,19 +48,19 @@ const fe = we({
|
|
|
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 $ =
|
|
136
|
+
} catch (L) {
|
|
137
|
+
const $ = L instanceof Error ? L.message : "Connection failed";
|
|
138
138
|
S($), l("โ USER CONNECTION ERROR", {
|
|
139
139
|
userId: s.id,
|
|
140
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
|
{
|
|
@@ -316,16 +316,16 @@ const J = ({
|
|
|
316
316
|
)
|
|
317
317
|
}
|
|
318
318
|
);
|
|
319
|
-
},
|
|
320
|
-
var h, v, S,
|
|
319
|
+
}, _e = ({ channel: t, selectedChannel: s, onChannelSelect: n, debug: o = !1, unread: i }) => {
|
|
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 }),
|
|
@@ -379,7 +379,7 @@ const J = ({
|
|
|
379
379
|
] })
|
|
380
380
|
}
|
|
381
381
|
);
|
|
382
|
-
},
|
|
382
|
+
}, $e = ({
|
|
383
383
|
onChannelSelect: t,
|
|
384
384
|
selectedChannel: s,
|
|
385
385
|
showStartConversation: n = !1,
|
|
@@ -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,
|
|
@@ -405,7 +405,12 @@ const J = ({
|
|
|
405
405
|
clientConnected: (u = r == null ? void 0 : r.wsConnection) == null ? void 0 : u.isHealthy
|
|
406
406
|
});
|
|
407
407
|
const b = X.useMemo(() => {
|
|
408
|
-
const g = r.userID, m = g ? {
|
|
408
|
+
const g = r.userID, m = g ? {
|
|
409
|
+
type: "messaging",
|
|
410
|
+
members: { $in: [g] },
|
|
411
|
+
hidden: !1,
|
|
412
|
+
last_message_at: { $exists: !0 }
|
|
413
|
+
} : { type: "messaging", last_message_at: { $exists: !0 } };
|
|
409
414
|
return l && console.log("๐บ [ChannelList] ๐ FILTERS MEMOIZED", {
|
|
410
415
|
renderCount: a.current,
|
|
411
416
|
userId: g,
|
|
@@ -438,19 +443,19 @@ const J = ({
|
|
|
438
443
|
hasClient: !!r,
|
|
439
444
|
clientUserId: r == null ? void 0 : r.userID
|
|
440
445
|
}), /* @__PURE__ */ e(
|
|
441
|
-
|
|
446
|
+
ke,
|
|
442
447
|
{
|
|
443
448
|
filters: b,
|
|
444
449
|
sort: { last_message_at: -1 },
|
|
445
450
|
options: { limit: 30 },
|
|
446
451
|
Preview: (g) => {
|
|
447
|
-
var m,
|
|
452
|
+
var m, y;
|
|
448
453
|
return l && console.log("๐บ [ChannelList] ๐ CHANNEL PREVIEW RENDER", {
|
|
449
454
|
channelId: (m = g.channel) == null ? void 0 : m.id,
|
|
450
455
|
selectedChannelId: s == null ? void 0 : s.id,
|
|
451
|
-
isSelected: (s == null ? void 0 : s.id) === ((
|
|
456
|
+
isSelected: (s == null ? void 0 : s.id) === ((y = g.channel) == null ? void 0 : y.id)
|
|
452
457
|
}), /* @__PURE__ */ e(
|
|
453
|
-
|
|
458
|
+
_e,
|
|
454
459
|
{
|
|
455
460
|
...g,
|
|
456
461
|
selectedChannel: s,
|
|
@@ -485,15 +490,18 @@ const J = ({
|
|
|
485
490
|
function ge({ onClick: t }) {
|
|
486
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" }) });
|
|
487
492
|
}
|
|
488
|
-
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: [
|
|
489
497
|
t && t(),
|
|
490
|
-
/* @__PURE__ */ e("div", { className: "flex-1", children: /* @__PURE__ */ e(
|
|
491
|
-
] }),
|
|
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 }) => {
|
|
492
500
|
var r, b, u, g;
|
|
493
501
|
const { channel: i } = me(), c = X.useMemo(() => Object.values(i.state.members || {}).find(
|
|
494
|
-
(
|
|
502
|
+
(y) => {
|
|
495
503
|
var N;
|
|
496
|
-
return ((N =
|
|
504
|
+
return ((N = y.user) == null ? void 0 : N.id) && y.user.id !== i._client.userID;
|
|
497
505
|
}
|
|
498
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;
|
|
499
507
|
return /* @__PURE__ */ d("div", { className: "flex items-center justify-between gap-3 min-h-12", children: [
|
|
@@ -519,9 +527,9 @@ const $e = ({ renderActions: t }) => /* @__PURE__ */ d("div", { className: "mess
|
|
|
519
527
|
),
|
|
520
528
|
/* @__PURE__ */ e("div", { className: "min-w-0", children: /* @__PURE__ */ e("h1", { className: "text-lg font-semibold text-charcoal truncate", children: a }) })
|
|
521
529
|
] }),
|
|
522
|
-
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" }) })
|
|
523
531
|
] });
|
|
524
|
-
},
|
|
532
|
+
}, We = ({
|
|
525
533
|
isOpen: t,
|
|
526
534
|
onClose: s,
|
|
527
535
|
participant: n,
|
|
@@ -530,13 +538,13 @@ const $e = ({ renderActions: t }) => /* @__PURE__ */ d("div", { className: "mess
|
|
|
530
538
|
onLeaveConversation: c,
|
|
531
539
|
onBlockParticipant: a
|
|
532
540
|
}) => {
|
|
533
|
-
var
|
|
534
|
-
const { service: l, debug: r } = se(), b = H(null), [u, g] = E(!1), [m,
|
|
535
|
-
|
|
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
|
+
_(() => {
|
|
536
544
|
const R = b.current;
|
|
537
545
|
R && (t ? R.showModal() : R.close());
|
|
538
546
|
}, [t]);
|
|
539
|
-
const v =
|
|
547
|
+
const v = M(async () => {
|
|
540
548
|
var R;
|
|
541
549
|
if (!(!l || !((R = n == null ? void 0 : n.user) != null && R.id)))
|
|
542
550
|
try {
|
|
@@ -547,47 +555,47 @@ const $e = ({ renderActions: t }) => /* @__PURE__ */ d("div", { className: "mess
|
|
|
547
555
|
}
|
|
548
556
|
);
|
|
549
557
|
g(A);
|
|
550
|
-
} catch (
|
|
558
|
+
} catch (T) {
|
|
551
559
|
console.error(
|
|
552
560
|
"[ChannelInfoDialog] Failed to check blocked status:",
|
|
553
|
-
|
|
561
|
+
T
|
|
554
562
|
);
|
|
555
563
|
}
|
|
556
|
-
}, [l, (
|
|
557
|
-
|
|
564
|
+
}, [l, (L = n == null ? void 0 : n.user) == null ? void 0 : L.id]);
|
|
565
|
+
_(() => {
|
|
558
566
|
t && v();
|
|
559
567
|
}, [t, v]);
|
|
560
568
|
const S = async () => {
|
|
561
569
|
var R;
|
|
562
570
|
if (!m) {
|
|
563
|
-
r && console.log("[ChannelInfoDialog] Leave conversation", o.cid),
|
|
571
|
+
r && console.log("[ChannelInfoDialog] Leave conversation", o.cid), y(!0);
|
|
564
572
|
try {
|
|
565
|
-
const
|
|
566
|
-
await o.hide(
|
|
567
|
-
} catch (
|
|
568
|
-
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);
|
|
569
577
|
} finally {
|
|
570
|
-
|
|
578
|
+
y(!1);
|
|
571
579
|
}
|
|
572
580
|
}
|
|
573
|
-
},
|
|
574
|
-
var R,
|
|
581
|
+
}, O = async () => {
|
|
582
|
+
var R, T, A;
|
|
575
583
|
if (!(N || !l)) {
|
|
576
584
|
r && console.log("[ChannelInfoDialog] Block member", (R = n == null ? void 0 : n.user) == null ? void 0 : R.id), h(!0);
|
|
577
585
|
try {
|
|
578
|
-
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();
|
|
579
587
|
} catch (q) {
|
|
580
588
|
console.error("[ChannelInfoDialog] Failed to block member", q);
|
|
581
589
|
} finally {
|
|
582
590
|
h(!1);
|
|
583
591
|
}
|
|
584
592
|
}
|
|
585
|
-
},
|
|
586
|
-
var R,
|
|
593
|
+
}, I = async () => {
|
|
594
|
+
var R, T, A;
|
|
587
595
|
if (!(N || !l)) {
|
|
588
596
|
r && console.log("[ChannelInfoDialog] Unblock member", (R = n == null ? void 0 : n.user) == null ? void 0 : R.id), h(!0);
|
|
589
597
|
try {
|
|
590
|
-
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();
|
|
591
599
|
} catch (q) {
|
|
592
600
|
console.error("[ChannelInfoDialog] Failed to unblock member", q);
|
|
593
601
|
} finally {
|
|
@@ -602,7 +610,7 @@ const $e = ({ renderActions: t }) => /* @__PURE__ */ d("div", { className: "mess
|
|
|
602
610
|
);
|
|
603
611
|
};
|
|
604
612
|
if (!n) return null;
|
|
605
|
-
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";
|
|
606
614
|
return (
|
|
607
615
|
// eslint-disable-next-line jsx-a11y/click-events-have-key-events, jsx-a11y/no-noninteractive-element-interactions
|
|
608
616
|
/* @__PURE__ */ e(
|
|
@@ -619,21 +627,35 @@ const $e = ({ renderActions: t }) => /* @__PURE__ */ d("div", { className: "mess
|
|
|
619
627
|
/* @__PURE__ */ e("h2", { className: "text-base font-semibold text-charcoal", children: "Chat info" }),
|
|
620
628
|
/* @__PURE__ */ e(ge, { onClick: s })
|
|
621
629
|
] }),
|
|
622
|
-
/* @__PURE__ */ d("div", { className: "flex-1 overflow-y-auto
|
|
623
|
-
/* @__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: [
|
|
624
632
|
/* @__PURE__ */ e(
|
|
625
633
|
J,
|
|
626
634
|
{
|
|
627
|
-
id:
|
|
628
|
-
name:
|
|
635
|
+
id: U,
|
|
636
|
+
name: F,
|
|
629
637
|
image: f,
|
|
630
|
-
size:
|
|
638
|
+
size: 88,
|
|
639
|
+
className: "!rounded-full"
|
|
631
640
|
}
|
|
632
641
|
),
|
|
633
|
-
/* @__PURE__ */ d("div", { className: "min-w-0 flex-1", children: [
|
|
634
|
-
/* @__PURE__ */ e("p", { className: "truncate text-base font-semibold text-charcoal", children:
|
|
635
|
-
|
|
636
|
-
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
|
+
)
|
|
637
659
|
] })
|
|
638
660
|
] }) }),
|
|
639
661
|
/* @__PURE__ */ d("ul", { className: "flex flex-col gap-2 mt-2", children: [
|
|
@@ -652,7 +674,7 @@ const $e = ({ renderActions: t }) => /* @__PURE__ */ d("div", { className: "mess
|
|
|
652
674
|
/* @__PURE__ */ e("li", { children: u ? /* @__PURE__ */ d(
|
|
653
675
|
K,
|
|
654
676
|
{
|
|
655
|
-
onClick:
|
|
677
|
+
onClick: I,
|
|
656
678
|
disabled: N,
|
|
657
679
|
"aria-busy": N,
|
|
658
680
|
children: [
|
|
@@ -663,7 +685,7 @@ const $e = ({ renderActions: t }) => /* @__PURE__ */ d("div", { className: "mess
|
|
|
663
685
|
) : /* @__PURE__ */ d(
|
|
664
686
|
K,
|
|
665
687
|
{
|
|
666
|
-
onClick:
|
|
688
|
+
onClick: O,
|
|
667
689
|
disabled: N,
|
|
668
690
|
"aria-busy": N,
|
|
669
691
|
children: [
|
|
@@ -682,28 +704,31 @@ const $e = ({ renderActions: t }) => /* @__PURE__ */ d("div", { className: "mess
|
|
|
682
704
|
}
|
|
683
705
|
)
|
|
684
706
|
);
|
|
685
|
-
},
|
|
707
|
+
}, ze = ({
|
|
686
708
|
onBack: t,
|
|
687
709
|
showBackButton: s,
|
|
688
710
|
renderMessageInputActions: n,
|
|
689
711
|
onLeaveConversation: o,
|
|
690
712
|
onBlockParticipant: i,
|
|
691
|
-
CustomChannelEmptyState: c
|
|
713
|
+
CustomChannelEmptyState: c = xe
|
|
692
714
|
}) => {
|
|
693
|
-
var m,
|
|
694
|
-
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(
|
|
695
717
|
(h) => {
|
|
696
718
|
var v;
|
|
697
719
|
return ((v = h.user) == null ? void 0 : v.id) && h.user.id !== a._client.userID;
|
|
698
720
|
}
|
|
699
721
|
), [a._client.userID, a.state.members]), g = X.useMemo(() => {
|
|
700
722
|
const N = a.data ?? {};
|
|
701
|
-
|
|
723
|
+
if (N.followerStatus)
|
|
724
|
+
return String(N.followerStatus);
|
|
725
|
+
if (N.isFollower !== void 0)
|
|
726
|
+
return N.isFollower ? "Subscribed to you" : "Not subscribed";
|
|
702
727
|
}, [a.data]);
|
|
703
728
|
return /* @__PURE__ */ d(oe, { children: [
|
|
704
729
|
/* @__PURE__ */ d(Te, { children: [
|
|
705
730
|
/* @__PURE__ */ e("div", { className: "border-b border-sand bg-white px-4 py-3", children: /* @__PURE__ */ e(
|
|
706
|
-
|
|
731
|
+
Ve,
|
|
707
732
|
{
|
|
708
733
|
onBack: t,
|
|
709
734
|
showBackButton: s,
|
|
@@ -712,18 +737,18 @@ const $e = ({ renderActions: t }) => /* @__PURE__ */ d("div", { className: "mess
|
|
|
712
737
|
}
|
|
713
738
|
) }),
|
|
714
739
|
/* @__PURE__ */ d("div", { className: "flex-1 overflow-hidden relative", children: [
|
|
715
|
-
/* @__PURE__ */ e(
|
|
716
|
-
!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, {}) })
|
|
717
742
|
] }),
|
|
718
743
|
/* @__PURE__ */ e(
|
|
719
|
-
|
|
744
|
+
Ge,
|
|
720
745
|
{
|
|
721
746
|
renderActions: () => n == null ? void 0 : n(a)
|
|
722
747
|
}
|
|
723
748
|
)
|
|
724
749
|
] }),
|
|
725
750
|
/* @__PURE__ */ e(
|
|
726
|
-
|
|
751
|
+
We,
|
|
727
752
|
{
|
|
728
753
|
isOpen: l,
|
|
729
754
|
onClose: () => r(!1),
|
|
@@ -735,7 +760,7 @@ const $e = ({ renderActions: t }) => /* @__PURE__ */ d("div", { className: "mess
|
|
|
735
760
|
}
|
|
736
761
|
)
|
|
737
762
|
] });
|
|
738
|
-
},
|
|
763
|
+
}, qe = ({
|
|
739
764
|
channel: t,
|
|
740
765
|
onBack: s,
|
|
741
766
|
showBackButton: n = !1,
|
|
@@ -743,7 +768,7 @@ const $e = ({ renderActions: t }) => /* @__PURE__ */ d("div", { className: "mess
|
|
|
743
768
|
onLeaveConversation: i,
|
|
744
769
|
onBlockParticipant: c,
|
|
745
770
|
className: a,
|
|
746
|
-
CustomChannelEmptyState: l
|
|
771
|
+
CustomChannelEmptyState: l = xe
|
|
747
772
|
}) => /* @__PURE__ */ e(
|
|
748
773
|
"div",
|
|
749
774
|
{
|
|
@@ -751,8 +776,8 @@ const $e = ({ renderActions: t }) => /* @__PURE__ */ d("div", { className: "mess
|
|
|
751
776
|
"messaging-channel-view h-full flex flex-col",
|
|
752
777
|
a
|
|
753
778
|
),
|
|
754
|
-
children: /* @__PURE__ */ e(
|
|
755
|
-
|
|
779
|
+
children: /* @__PURE__ */ e(Fe, { channel: t, children: /* @__PURE__ */ e(
|
|
780
|
+
ze,
|
|
756
781
|
{
|
|
757
782
|
onBack: s,
|
|
758
783
|
showBackButton: n,
|
|
@@ -764,7 +789,7 @@ const $e = ({ renderActions: t }) => /* @__PURE__ */ d("div", { className: "mess
|
|
|
764
789
|
) })
|
|
765
790
|
}
|
|
766
791
|
);
|
|
767
|
-
function
|
|
792
|
+
function Xe({
|
|
768
793
|
searchQuery: t,
|
|
769
794
|
setSearchQuery: s,
|
|
770
795
|
placeholder: n
|
|
@@ -772,7 +797,7 @@ function qe({
|
|
|
772
797
|
const o = H(null);
|
|
773
798
|
return /* @__PURE__ */ d("div", { className: "relative", children: [
|
|
774
799
|
/* @__PURE__ */ e(
|
|
775
|
-
|
|
800
|
+
je,
|
|
776
801
|
{
|
|
777
802
|
className: "pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-stone",
|
|
778
803
|
weight: "bold"
|
|
@@ -803,7 +828,7 @@ function qe({
|
|
|
803
828
|
)
|
|
804
829
|
] });
|
|
805
830
|
}
|
|
806
|
-
const
|
|
831
|
+
const Qe = ({
|
|
807
832
|
participantSource: t,
|
|
808
833
|
onSelectParticipant: s,
|
|
809
834
|
onClose: n,
|
|
@@ -812,26 +837,26 @@ const Xe = ({
|
|
|
812
837
|
searchPlaceholder: c = "Search participants...",
|
|
813
838
|
className: a
|
|
814
839
|
}) => {
|
|
815
|
-
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(
|
|
816
841
|
null
|
|
817
|
-
),
|
|
818
|
-
|
|
842
|
+
), O = H(!1);
|
|
843
|
+
_(() => {
|
|
819
844
|
if (t.loading) {
|
|
820
845
|
l && console.log(
|
|
821
846
|
"[ParticipantPicker] Waiting for participant source to finish loading..."
|
|
822
847
|
);
|
|
823
848
|
return;
|
|
824
849
|
}
|
|
825
|
-
if (
|
|
850
|
+
if (O.current) return;
|
|
826
851
|
(async () => {
|
|
827
|
-
l && console.log("[ParticipantPicker] Loading initial participants..."),
|
|
852
|
+
l && console.log("[ParticipantPicker] Loading initial participants..."), y(!0), h(null);
|
|
828
853
|
try {
|
|
829
854
|
const x = await t.loadParticipants({
|
|
830
855
|
search: "",
|
|
831
856
|
// Load all participants initially
|
|
832
857
|
limit: 100
|
|
833
858
|
});
|
|
834
|
-
g(x.participants),
|
|
859
|
+
g(x.participants), O.current = !0, l && console.log(
|
|
835
860
|
"[ParticipantPicker] Participants loaded successfully:",
|
|
836
861
|
x.participants.length
|
|
837
862
|
);
|
|
@@ -839,16 +864,16 @@ const Xe = ({
|
|
|
839
864
|
const w = x instanceof Error ? x.message : "Failed to load participants";
|
|
840
865
|
h(w), console.error("[ParticipantPicker] Failed to load participants:", x);
|
|
841
866
|
} finally {
|
|
842
|
-
|
|
867
|
+
y(!1);
|
|
843
868
|
}
|
|
844
869
|
})();
|
|
845
870
|
}, [t.loading, l]);
|
|
846
|
-
const
|
|
871
|
+
const I = u.filter((f) => !o.has(f.id)).filter((f) => {
|
|
847
872
|
var w;
|
|
848
873
|
if (!r) return !0;
|
|
849
874
|
const x = r.toLowerCase();
|
|
850
875
|
return f.name.toLowerCase().includes(x) || ((w = f.email) == null ? void 0 : w.toLowerCase().includes(x)) || !1;
|
|
851
|
-
}), k =
|
|
876
|
+
}), k = M(
|
|
852
877
|
async (f) => {
|
|
853
878
|
if (!v) {
|
|
854
879
|
S(f.id);
|
|
@@ -860,7 +885,7 @@ const Xe = ({
|
|
|
860
885
|
}
|
|
861
886
|
},
|
|
862
887
|
[s, v]
|
|
863
|
-
),
|
|
888
|
+
), F = (f, x) => {
|
|
864
889
|
(f.key === "Enter" || f.key === " ") && (f.preventDefault(), k(x));
|
|
865
890
|
};
|
|
866
891
|
return /* @__PURE__ */ d("div", { className: D("flex flex-col h-full", a), children: [
|
|
@@ -873,12 +898,12 @@ const Xe = ({
|
|
|
873
898
|
"Select a ",
|
|
874
899
|
i.slice(0, -1),
|
|
875
900
|
" to start messaging (",
|
|
876
|
-
|
|
901
|
+
I.length,
|
|
877
902
|
" available)",
|
|
878
903
|
t.totalCount !== void 0 && ` โข ${t.totalCount} ${i} total`
|
|
879
904
|
] }),
|
|
880
905
|
/* @__PURE__ */ e(
|
|
881
|
-
|
|
906
|
+
Xe,
|
|
882
907
|
{
|
|
883
908
|
searchQuery: r,
|
|
884
909
|
setSearchQuery: b,
|
|
@@ -892,26 +917,26 @@ const Xe = ({
|
|
|
892
917
|
": ",
|
|
893
918
|
N
|
|
894
919
|
] }),
|
|
895
|
-
/* @__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: [
|
|
896
921
|
/* @__PURE__ */ e("div", { className: "w-4 h-4 animate-spin rounded-full border-2 border-primary border-t-transparent" }),
|
|
897
922
|
/* @__PURE__ */ d("span", { className: "text-sm text-stone", children: [
|
|
898
923
|
"Loading ",
|
|
899
924
|
i,
|
|
900
925
|
"..."
|
|
901
926
|
] })
|
|
902
|
-
] }) }) :
|
|
927
|
+
] }) }) : I.length === 0 ? /* @__PURE__ */ d("div", { className: "p-6 text-center", children: [
|
|
903
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" }) }),
|
|
904
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` }),
|
|
905
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` })
|
|
906
931
|
] }) : /* @__PURE__ */ d("ul", { className: "space-y-0", children: [
|
|
907
|
-
|
|
932
|
+
I.map((f) => {
|
|
908
933
|
const x = f.name || f.email || f.id, w = f.email && f.name ? f.email : f.phone;
|
|
909
934
|
return /* @__PURE__ */ e("li", { children: /* @__PURE__ */ e(
|
|
910
935
|
"button",
|
|
911
936
|
{
|
|
912
937
|
type: "button",
|
|
913
938
|
onClick: () => k(f),
|
|
914
|
-
onKeyDown: (
|
|
939
|
+
onKeyDown: (P) => F(P, f),
|
|
915
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",
|
|
916
941
|
children: /* @__PURE__ */ d("div", { className: "flex items-center justify-between", children: [
|
|
917
942
|
/* @__PURE__ */ d("div", { className: "flex items-center space-x-3 flex-1 min-w-0", children: [
|
|
@@ -940,7 +965,7 @@ const Xe = ({
|
|
|
940
965
|
] }) })
|
|
941
966
|
] }) })
|
|
942
967
|
] });
|
|
943
|
-
},
|
|
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: [
|
|
944
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: "๐ฌ" }) }),
|
|
945
970
|
/* @__PURE__ */ e("h2", { className: "font-semibold text-charcoal", children: "Welcome to Messages" }),
|
|
946
971
|
/* @__PURE__ */ e("p", { className: "text-stone text-sm mb-6", children: t ? /* @__PURE__ */ d(oe, { children: [
|
|
@@ -983,7 +1008,7 @@ const Xe = ({
|
|
|
983
1008
|
children: "Go Back"
|
|
984
1009
|
}
|
|
985
1010
|
)
|
|
986
|
-
] }) }),
|
|
1011
|
+
] }) }), Je = ({ className: t, message: s }) => /* @__PURE__ */ d(
|
|
987
1012
|
"div",
|
|
988
1013
|
{
|
|
989
1014
|
className: D("flex items-center justify-center h-full", t),
|
|
@@ -1026,10 +1051,10 @@ const Xe = ({
|
|
|
1026
1051
|
s && /* @__PURE__ */ e("span", { className: "text-stone", children: s })
|
|
1027
1052
|
]
|
|
1028
1053
|
}
|
|
1029
|
-
),
|
|
1030
|
-
/* @__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" }),
|
|
1031
1056
|
/* @__PURE__ */ e("span", { className: "text-sm text-stone", children: "Loading messages" })
|
|
1032
|
-
] }) }),
|
|
1057
|
+
] }) }), as = ({
|
|
1033
1058
|
capabilities: t = {},
|
|
1034
1059
|
className: s,
|
|
1035
1060
|
renderMessageInputActions: n,
|
|
@@ -1045,14 +1070,14 @@ const Xe = ({
|
|
|
1045
1070
|
client: u,
|
|
1046
1071
|
isConnected: g,
|
|
1047
1072
|
isLoading: m,
|
|
1048
|
-
error:
|
|
1073
|
+
error: y,
|
|
1049
1074
|
refreshConnection: N,
|
|
1050
1075
|
debug: h
|
|
1051
|
-
} =
|
|
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), {
|
|
1052
1077
|
showStartConversation: Q = !1,
|
|
1053
1078
|
participantSource: W,
|
|
1054
1079
|
participantLabel: z = "participants"
|
|
1055
|
-
} = t, R = H(null),
|
|
1080
|
+
} = t, R = H(null), T = M(async () => {
|
|
1056
1081
|
if (!u || !g) return;
|
|
1057
1082
|
const C = u.userID;
|
|
1058
1083
|
if (C)
|
|
@@ -1065,27 +1090,27 @@ const Xe = ({
|
|
|
1065
1090
|
},
|
|
1066
1091
|
{},
|
|
1067
1092
|
{ limit: 100 }
|
|
1068
|
-
),
|
|
1093
|
+
), p = /* @__PURE__ */ new Set();
|
|
1069
1094
|
j.forEach((B) => {
|
|
1070
|
-
const
|
|
1071
|
-
Object.values(
|
|
1095
|
+
const ve = B.state.members;
|
|
1096
|
+
Object.values(ve).forEach((we) => {
|
|
1072
1097
|
var ae;
|
|
1073
|
-
const re = (ae =
|
|
1074
|
-
re && re !== C &&
|
|
1098
|
+
const re = (ae = we.user) == null ? void 0 : ae.id;
|
|
1099
|
+
re && re !== C && p.add(re);
|
|
1075
1100
|
});
|
|
1076
|
-
}), x(
|
|
1101
|
+
}), x(p), I(j.length > 0), R.current = C, h && console.log("[MessagingShell] Channels synced successfully:", {
|
|
1077
1102
|
channelCount: j.length,
|
|
1078
|
-
memberCount:
|
|
1103
|
+
memberCount: p.size
|
|
1079
1104
|
});
|
|
1080
1105
|
} catch (j) {
|
|
1081
1106
|
console.error("[MessagingShell] Failed to sync channels:", j);
|
|
1082
1107
|
}
|
|
1083
1108
|
}, [u, g, h]);
|
|
1084
|
-
|
|
1109
|
+
_(() => {
|
|
1085
1110
|
if (!u || !g) return;
|
|
1086
1111
|
const C = u.userID;
|
|
1087
|
-
C && R.current !== C &&
|
|
1088
|
-
}, [u, g,
|
|
1112
|
+
C && R.current !== C && T();
|
|
1113
|
+
}, [u, g, T]), _(() => {
|
|
1089
1114
|
if (!c || !u || !g) return;
|
|
1090
1115
|
(async () => {
|
|
1091
1116
|
const j = u.userID;
|
|
@@ -1095,7 +1120,7 @@ const Xe = ({
|
|
|
1095
1120
|
"[MessagingShell] Loading initial conversation with:",
|
|
1096
1121
|
c
|
|
1097
1122
|
);
|
|
1098
|
-
const
|
|
1123
|
+
const p = await u.queryChannels(
|
|
1099
1124
|
{
|
|
1100
1125
|
type: "messaging",
|
|
1101
1126
|
members: { $eq: [j, c] }
|
|
@@ -1103,10 +1128,10 @@ const Xe = ({
|
|
|
1103
1128
|
{},
|
|
1104
1129
|
{ limit: 1 }
|
|
1105
1130
|
);
|
|
1106
|
-
if (
|
|
1107
|
-
S(
|
|
1131
|
+
if (p.length > 0)
|
|
1132
|
+
S(p[0]), L(!0), G(null), o && o(p[0]), h && console.log(
|
|
1108
1133
|
"[MessagingShell] Initial conversation loaded:",
|
|
1109
|
-
|
|
1134
|
+
p[0].id
|
|
1110
1135
|
);
|
|
1111
1136
|
else if (a && b) {
|
|
1112
1137
|
h && console.log(
|
|
@@ -1120,7 +1145,7 @@ const Xe = ({
|
|
|
1120
1145
|
email: a.email,
|
|
1121
1146
|
phone: a.phone
|
|
1122
1147
|
});
|
|
1123
|
-
S(B),
|
|
1148
|
+
S(B), L(!0), G(null), o && o(B), h && console.log(
|
|
1124
1149
|
"[MessagingShell] Channel created and loaded:",
|
|
1125
1150
|
B.id
|
|
1126
1151
|
);
|
|
@@ -1128,20 +1153,20 @@ const Xe = ({
|
|
|
1128
1153
|
console.error(
|
|
1129
1154
|
"[MessagingShell] Failed to create conversation:",
|
|
1130
1155
|
B
|
|
1131
|
-
),
|
|
1156
|
+
), G("Failed to create conversation");
|
|
1132
1157
|
}
|
|
1133
1158
|
} else
|
|
1134
|
-
|
|
1159
|
+
G(
|
|
1135
1160
|
"No conversation found with this account"
|
|
1136
1161
|
), h && console.log(
|
|
1137
1162
|
"[MessagingShell] No conversation found for:",
|
|
1138
1163
|
c
|
|
1139
1164
|
);
|
|
1140
|
-
} catch (
|
|
1165
|
+
} catch (p) {
|
|
1141
1166
|
console.error(
|
|
1142
1167
|
"[MessagingShell] Failed to load initial conversation:",
|
|
1143
|
-
|
|
1144
|
-
),
|
|
1168
|
+
p
|
|
1169
|
+
), G("Failed to load conversation");
|
|
1145
1170
|
}
|
|
1146
1171
|
})();
|
|
1147
1172
|
}, [
|
|
@@ -1153,17 +1178,17 @@ const Xe = ({
|
|
|
1153
1178
|
h,
|
|
1154
1179
|
o
|
|
1155
1180
|
]);
|
|
1156
|
-
const A =
|
|
1181
|
+
const A = M(
|
|
1157
1182
|
(C) => {
|
|
1158
1183
|
S(C), o == null || o(C);
|
|
1159
1184
|
},
|
|
1160
1185
|
[o]
|
|
1161
|
-
), q =
|
|
1162
|
-
|
|
1163
|
-
}, [
|
|
1186
|
+
), q = M(() => {
|
|
1187
|
+
U || S(null);
|
|
1188
|
+
}, [U]), Z = M(() => {
|
|
1164
1189
|
var C;
|
|
1165
|
-
W && (
|
|
1166
|
-
}, [W]),
|
|
1190
|
+
W && (P((j) => j + 1), F(!0), (C = V.current) == null || C.showModal());
|
|
1191
|
+
}, [W]), Ne = M(
|
|
1167
1192
|
async (C) => {
|
|
1168
1193
|
var j;
|
|
1169
1194
|
if (b)
|
|
@@ -1172,38 +1197,38 @@ const Xe = ({
|
|
|
1172
1197
|
"[MessagingShell] Starting conversation with:",
|
|
1173
1198
|
C.id
|
|
1174
1199
|
);
|
|
1175
|
-
const
|
|
1200
|
+
const p = await b.startChannelWithParticipant({
|
|
1176
1201
|
id: C.id,
|
|
1177
1202
|
name: C.name,
|
|
1178
1203
|
email: C.email,
|
|
1179
1204
|
phone: C.phone
|
|
1180
1205
|
});
|
|
1181
1206
|
try {
|
|
1182
|
-
await
|
|
1207
|
+
await p.show();
|
|
1183
1208
|
} catch (B) {
|
|
1184
1209
|
console.warn("[MessagingShell] Failed to unhide channel:", B);
|
|
1185
1210
|
}
|
|
1186
|
-
S(
|
|
1187
|
-
} catch (
|
|
1188
|
-
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);
|
|
1189
1214
|
}
|
|
1190
1215
|
},
|
|
1191
1216
|
[b, i, h]
|
|
1192
|
-
), te =
|
|
1217
|
+
), te = M(() => {
|
|
1193
1218
|
var C;
|
|
1194
|
-
|
|
1195
|
-
}, []),
|
|
1219
|
+
F(!1), (C = V.current) == null || C.close();
|
|
1220
|
+
}, []), be = M(
|
|
1196
1221
|
async (C) => {
|
|
1197
|
-
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();
|
|
1198
1223
|
},
|
|
1199
|
-
[
|
|
1200
|
-
),
|
|
1224
|
+
[T, h]
|
|
1225
|
+
), Ce = M(
|
|
1201
1226
|
async (C) => {
|
|
1202
|
-
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();
|
|
1203
1228
|
},
|
|
1204
|
-
[
|
|
1229
|
+
[T, h]
|
|
1205
1230
|
), Y = !!v;
|
|
1206
|
-
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(
|
|
1207
1232
|
le,
|
|
1208
1233
|
{
|
|
1209
1234
|
message: "Not connected to messaging service",
|
|
@@ -1225,15 +1250,15 @@ const Xe = ({
|
|
|
1225
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",
|
|
1226
1251
|
{
|
|
1227
1252
|
// Explicitly hidden via prop or in direct conversation mode
|
|
1228
|
-
"!hidden": r === !1 ||
|
|
1253
|
+
"!hidden": r === !1 || U,
|
|
1229
1254
|
// Normal mode: hide on mobile when channel selected, show on desktop
|
|
1230
|
-
"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,
|
|
1231
1256
|
// Normal mode: show when no channel selected
|
|
1232
|
-
"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
|
|
1233
1258
|
}
|
|
1234
1259
|
),
|
|
1235
1260
|
children: /* @__PURE__ */ e(
|
|
1236
|
-
|
|
1261
|
+
$e,
|
|
1237
1262
|
{
|
|
1238
1263
|
onChannelSelect: A,
|
|
1239
1264
|
selectedChannel: v || void 0,
|
|
@@ -1251,27 +1276,27 @@ const Xe = ({
|
|
|
1251
1276
|
"messaging-conversation-view flex-1 flex-col min-w-0 min-h-0",
|
|
1252
1277
|
{
|
|
1253
1278
|
// In direct conversation mode, always show (full width)
|
|
1254
|
-
flex:
|
|
1279
|
+
flex: U || Y,
|
|
1255
1280
|
// Normal mode: hide on mobile when no channel selected
|
|
1256
|
-
"hidden lg:flex": !
|
|
1281
|
+
"hidden lg:flex": !U && !Y
|
|
1257
1282
|
}
|
|
1258
1283
|
),
|
|
1259
1284
|
children: v ? /* @__PURE__ */ e("div", { className: "flex-1 min-h-0 flex flex-col", children: /* @__PURE__ */ e(
|
|
1260
|
-
|
|
1285
|
+
qe,
|
|
1261
1286
|
{
|
|
1262
1287
|
channel: v,
|
|
1263
1288
|
onBack: q,
|
|
1264
|
-
showBackButton: !
|
|
1289
|
+
showBackButton: !U,
|
|
1265
1290
|
renderMessageInputActions: n,
|
|
1266
|
-
onLeaveConversation:
|
|
1267
|
-
onBlockParticipant:
|
|
1291
|
+
onLeaveConversation: be,
|
|
1292
|
+
onBlockParticipant: Ce,
|
|
1268
1293
|
CustomChannelEmptyState: l
|
|
1269
1294
|
},
|
|
1270
1295
|
v.id
|
|
1271
1296
|
) }) : /* @__PURE__ */ e(
|
|
1272
|
-
|
|
1297
|
+
Ze,
|
|
1273
1298
|
{
|
|
1274
|
-
hasChannels:
|
|
1299
|
+
hasChannels: O,
|
|
1275
1300
|
onStartConversation: Q ? Z : void 0,
|
|
1276
1301
|
participantLabel: z
|
|
1277
1302
|
}
|
|
@@ -1290,10 +1315,10 @@ const Xe = ({
|
|
|
1290
1315
|
},
|
|
1291
1316
|
onClose: te,
|
|
1292
1317
|
children: /* @__PURE__ */ e("div", { className: "h-full w-full bg-white shadow-max-elevation-light", children: /* @__PURE__ */ e(
|
|
1293
|
-
|
|
1318
|
+
Qe,
|
|
1294
1319
|
{
|
|
1295
1320
|
participantSource: W,
|
|
1296
|
-
onSelectParticipant:
|
|
1321
|
+
onSelectParticipant: Ne,
|
|
1297
1322
|
onClose: te,
|
|
1298
1323
|
existingParticipantIds: f,
|
|
1299
1324
|
participantLabel: z,
|
|
@@ -1306,7 +1331,7 @@ const Xe = ({
|
|
|
1306
1331
|
]
|
|
1307
1332
|
}
|
|
1308
1333
|
);
|
|
1309
|
-
},
|
|
1334
|
+
}, Ke = ({
|
|
1310
1335
|
question: t,
|
|
1311
1336
|
onClick: s,
|
|
1312
1337
|
loading: n = !1,
|
|
@@ -1328,7 +1353,7 @@ const Xe = ({
|
|
|
1328
1353
|
),
|
|
1329
1354
|
children: t
|
|
1330
1355
|
}
|
|
1331
|
-
),
|
|
1356
|
+
), is = ({
|
|
1332
1357
|
faqs: t,
|
|
1333
1358
|
onFaqClick: s,
|
|
1334
1359
|
loadingFaqId: n,
|
|
@@ -1356,7 +1381,7 @@ const Xe = ({
|
|
|
1356
1381
|
children: [
|
|
1357
1382
|
o && /* @__PURE__ */ e("p", { className: "text-md text-charcoal mb-4", children: o }),
|
|
1358
1383
|
l.map((r) => /* @__PURE__ */ e(
|
|
1359
|
-
|
|
1384
|
+
Ke,
|
|
1360
1385
|
{
|
|
1361
1386
|
question: r.question,
|
|
1362
1387
|
onClick: () => s(r.id),
|
|
@@ -1368,10 +1393,10 @@ const Xe = ({
|
|
|
1368
1393
|
}
|
|
1369
1394
|
)
|
|
1370
1395
|
] }) });
|
|
1371
|
-
},
|
|
1372
|
-
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) => {
|
|
1373
1398
|
if (a) return;
|
|
1374
|
-
const f =
|
|
1399
|
+
const f = F !== void 0 ? F : u;
|
|
1375
1400
|
l(!0), b(null);
|
|
1376
1401
|
try {
|
|
1377
1402
|
const x = await t.loadParticipants({
|
|
@@ -1381,21 +1406,21 @@ const Xe = ({
|
|
|
1381
1406
|
});
|
|
1382
1407
|
c(
|
|
1383
1408
|
(w) => k ? x.participants : [...w, ...x.participants]
|
|
1384
|
-
),
|
|
1409
|
+
), y(x.hasMore), h(x.nextCursor);
|
|
1385
1410
|
} catch (x) {
|
|
1386
1411
|
const w = x instanceof Error ? x.message : "Failed to load participants";
|
|
1387
1412
|
b(w), console.error("[useParticipants] Load error:", x);
|
|
1388
1413
|
} finally {
|
|
1389
1414
|
l(!1);
|
|
1390
1415
|
}
|
|
1391
|
-
}, [t, u, N, o, a]), S =
|
|
1416
|
+
}, [t, u, N, o, a]), S = M(() => {
|
|
1392
1417
|
m && !a && v(!1);
|
|
1393
|
-
}, [m, a, v]),
|
|
1418
|
+
}, [m, a, v]), O = M((k) => {
|
|
1394
1419
|
g(k), h(void 0), v(!0, k);
|
|
1395
|
-
}, [v]),
|
|
1420
|
+
}, [v]), I = M(() => {
|
|
1396
1421
|
h(void 0), v(!0);
|
|
1397
1422
|
}, [v]);
|
|
1398
|
-
return
|
|
1423
|
+
return _(() => {
|
|
1399
1424
|
v(!0);
|
|
1400
1425
|
}, [t.loadParticipants]), {
|
|
1401
1426
|
participants: i,
|
|
@@ -1405,20 +1430,21 @@ const Xe = ({
|
|
|
1405
1430
|
hasMore: m,
|
|
1406
1431
|
totalCount: t.totalCount,
|
|
1407
1432
|
loadMore: S,
|
|
1408
|
-
search:
|
|
1409
|
-
refresh:
|
|
1433
|
+
search: O,
|
|
1434
|
+
refresh: I
|
|
1410
1435
|
};
|
|
1411
1436
|
};
|
|
1412
1437
|
export {
|
|
1413
1438
|
J as Avatar,
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
os as
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1439
|
+
xe as ChannelEmptyState,
|
|
1440
|
+
$e as ChannelList,
|
|
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
|
|
1423
1449
|
};
|
|
1424
1450
|
//# sourceMappingURL=index.js.map
|