@linktr.ee/messaging-react 1.6.0 โ 1.6.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { jsx as e, jsxs as
|
|
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 ve, useContext as we, useCallback as U, useState as
|
|
3
|
+
import X, { createContext as ve, useContext as we, useCallback as U, useState as E, useRef as H, useEffect as G } from "react";
|
|
4
4
|
import { StreamChatService as Ee } from "@linktr.ee/messaging-core";
|
|
5
5
|
import { Chat as Ie, useChatContext as ye, ChannelList as Se, Channel as Re, useChannelStateContext as ue, Window as ke, MessageList as Te, MessageInput as Pe } from "stream-chat-react";
|
|
6
6
|
import { NotePencilIcon as De, XIcon as me, ArrowLeftIcon as Me, DotsThreeIcon as Oe, SpinnerGapIcon as ee, SignOutIcon as Ue, ProhibitInsetIcon as ie, FlagIcon as Fe, MagnifyingGlassIcon as pe, ChatCircleDotsIcon as ce } from "@phosphor-icons/react";
|
|
@@ -20,50 +20,50 @@ const he = ve({
|
|
|
20
20
|
user: s,
|
|
21
21
|
serviceConfig: n,
|
|
22
22
|
apiKey: l,
|
|
23
|
-
capabilities:
|
|
24
|
-
customization:
|
|
25
|
-
debug:
|
|
23
|
+
capabilities: i = {},
|
|
24
|
+
customization: c = {},
|
|
25
|
+
debug: a = !1
|
|
26
26
|
}) => {
|
|
27
|
-
const
|
|
28
|
-
(
|
|
29
|
-
|
|
27
|
+
const o = U(
|
|
28
|
+
(w, ...M) => {
|
|
29
|
+
a && console.log(`๐ฅ [MessagingProvider] ${w}`, ...M);
|
|
30
30
|
},
|
|
31
|
-
[
|
|
31
|
+
[a]
|
|
32
32
|
);
|
|
33
|
-
|
|
33
|
+
o("๐ RENDER START", {
|
|
34
34
|
userId: s == null ? void 0 : s.id,
|
|
35
35
|
apiKey: (l == null ? void 0 : l.substring(0, 8)) + "...",
|
|
36
36
|
serviceConfig: !!n,
|
|
37
|
-
capabilities: Object.keys(
|
|
38
|
-
customization: Object.keys(
|
|
37
|
+
capabilities: Object.keys(i),
|
|
38
|
+
customization: Object.keys(c)
|
|
39
39
|
});
|
|
40
|
-
const [
|
|
40
|
+
const [r, b] = E(null), [u, g] = E(null), [m, I] = E(!1), [N, h] = E(!1), [v, S] = E(null), O = H(!1), y = H({
|
|
41
41
|
userId: s == null ? void 0 : s.id,
|
|
42
42
|
apiKey: l,
|
|
43
43
|
serviceConfig: n,
|
|
44
|
-
capabilities:
|
|
45
|
-
customization:
|
|
44
|
+
capabilities: i,
|
|
45
|
+
customization: c
|
|
46
46
|
}), k = H(0);
|
|
47
|
-
k.current++,
|
|
47
|
+
k.current++, o("๐ RENDER INFO", {
|
|
48
48
|
renderCount: k.current,
|
|
49
49
|
currentProps: { userId: s == null ? void 0 : s.id, apiKey: (l == null ? void 0 : l.substring(0, 8)) + "..." },
|
|
50
50
|
propChanges: {
|
|
51
51
|
userChanged: y.current.userId !== (s == null ? void 0 : s.id),
|
|
52
52
|
apiKeyChanged: y.current.apiKey !== l,
|
|
53
53
|
serviceConfigChanged: y.current.serviceConfig !== n,
|
|
54
|
-
capabilitiesChanged: y.current.capabilities !==
|
|
55
|
-
customizationChanged: y.current.customization !==
|
|
54
|
+
capabilitiesChanged: y.current.capabilities !== i,
|
|
55
|
+
customizationChanged: y.current.customization !== c
|
|
56
56
|
}
|
|
57
57
|
}), y.current = {
|
|
58
58
|
userId: s == null ? void 0 : s.id,
|
|
59
59
|
apiKey: l,
|
|
60
60
|
serviceConfig: n,
|
|
61
|
-
capabilities:
|
|
62
|
-
customization:
|
|
61
|
+
capabilities: i,
|
|
62
|
+
customization: c
|
|
63
63
|
}, G(() => {
|
|
64
|
-
const
|
|
65
|
-
if (
|
|
66
|
-
renderCount:
|
|
64
|
+
const w = k.current;
|
|
65
|
+
if (o("๐ง SERVICE INIT EFFECT TRIGGERED", {
|
|
66
|
+
renderCount: w,
|
|
67
67
|
apiKey: !!l,
|
|
68
68
|
serviceConfig: !!n,
|
|
69
69
|
dependencies: {
|
|
@@ -73,151 +73,151 @@ const he = ve({
|
|
|
73
73
|
apiKeyStable: y.current.apiKey === l
|
|
74
74
|
}
|
|
75
75
|
}), !l || !n) {
|
|
76
|
-
|
|
77
|
-
renderCount:
|
|
76
|
+
o("โ ๏ธ SERVICE INIT SKIPPED", {
|
|
77
|
+
renderCount: w,
|
|
78
78
|
reason: "Missing apiKey or serviceConfig"
|
|
79
79
|
});
|
|
80
80
|
return;
|
|
81
81
|
}
|
|
82
|
-
|
|
83
|
-
renderCount:
|
|
82
|
+
o("๐ CREATING NEW SERVICE", {
|
|
83
|
+
renderCount: w,
|
|
84
84
|
apiKey: (l == null ? void 0 : l.substring(0, 8)) + "...",
|
|
85
85
|
serviceConfigChanged: y.current.serviceConfig !== n
|
|
86
86
|
});
|
|
87
87
|
const M = new Ee({
|
|
88
88
|
...n,
|
|
89
89
|
apiKey: l,
|
|
90
|
-
debug:
|
|
90
|
+
debug: a
|
|
91
91
|
});
|
|
92
|
-
return
|
|
93
|
-
renderCount:
|
|
92
|
+
return b(M), o("โ
SERVICE SET", {
|
|
93
|
+
renderCount: w,
|
|
94
94
|
serviceInstance: !!M
|
|
95
95
|
}), () => {
|
|
96
|
-
|
|
97
|
-
renderCount:
|
|
96
|
+
o("๐งน SERVICE CLEANUP", {
|
|
97
|
+
renderCount: w,
|
|
98
98
|
reason: "Effect cleanup"
|
|
99
99
|
}), M.disconnectUser().catch(console.error);
|
|
100
100
|
};
|
|
101
|
-
}, [l, n,
|
|
101
|
+
}, [l, n, a, o]);
|
|
102
102
|
const T = H(null);
|
|
103
103
|
G(() => {
|
|
104
104
|
var M, p;
|
|
105
|
-
if (
|
|
106
|
-
hasService: !!
|
|
105
|
+
if (o("๐ USER CONNECTION EFFECT TRIGGERED", {
|
|
106
|
+
hasService: !!r,
|
|
107
107
|
hasUser: !!s,
|
|
108
108
|
userId: s == null ? void 0 : s.id,
|
|
109
109
|
isConnecting: O.current,
|
|
110
110
|
isConnected: m,
|
|
111
|
-
dependencies: { service: !!
|
|
112
|
-
}), !
|
|
113
|
-
|
|
111
|
+
dependencies: { service: !!r, userId: s == null ? void 0 : s.id }
|
|
112
|
+
}), !r || !s) {
|
|
113
|
+
o("โ ๏ธ USER CONNECTION SKIPPED", "Missing service or user");
|
|
114
114
|
return;
|
|
115
115
|
}
|
|
116
116
|
if (O.current) {
|
|
117
|
-
|
|
117
|
+
o("โ ๏ธ USER CONNECTION SKIPPED", "Already connecting");
|
|
118
118
|
return;
|
|
119
119
|
}
|
|
120
|
-
if (((M = T.current) == null ? void 0 : M.serviceId) ===
|
|
121
|
-
|
|
120
|
+
if (((M = T.current) == null ? void 0 : M.serviceId) === r && ((p = T.current) == null ? void 0 : p.userId) === s.id) {
|
|
121
|
+
o(
|
|
122
122
|
"โ ๏ธ USER CONNECTION SKIPPED",
|
|
123
123
|
"Already connected this user with this service"
|
|
124
124
|
);
|
|
125
125
|
return;
|
|
126
126
|
}
|
|
127
127
|
(async () => {
|
|
128
|
-
|
|
128
|
+
o("๐ STARTING USER CONNECTION", { userId: s.id }), O.current = !0, h(!0), S(null);
|
|
129
129
|
try {
|
|
130
|
-
|
|
131
|
-
const L = await
|
|
132
|
-
|
|
130
|
+
o("๐ CALLING SERVICE.CONNECTUSER", { userId: s.id });
|
|
131
|
+
const L = await r.connectUser(s);
|
|
132
|
+
g(L), I(!0), T.current = { serviceId: r, userId: s.id }, o("โ
USER CONNECTION SUCCESS", {
|
|
133
133
|
userId: s.id,
|
|
134
134
|
clientId: L.userID
|
|
135
135
|
});
|
|
136
136
|
} catch (L) {
|
|
137
137
|
const $ = L instanceof Error ? L.message : "Connection failed";
|
|
138
|
-
S($),
|
|
138
|
+
S($), o("โ USER CONNECTION ERROR", {
|
|
139
139
|
userId: s.id,
|
|
140
140
|
error: $
|
|
141
141
|
});
|
|
142
142
|
} finally {
|
|
143
|
-
h(!1), O.current = !1,
|
|
143
|
+
h(!1), O.current = !1, o("๐ USER CONNECTION FINISHED", {
|
|
144
144
|
userId: s.id,
|
|
145
145
|
isConnected: m
|
|
146
146
|
});
|
|
147
147
|
}
|
|
148
148
|
})();
|
|
149
|
-
}, [
|
|
150
|
-
hasService: !!
|
|
149
|
+
}, [r, s, o, m]), G(() => (o("๐ CLEANUP EFFECT REGISTERED", {
|
|
150
|
+
hasService: !!r,
|
|
151
151
|
isConnected: m
|
|
152
152
|
}), () => {
|
|
153
|
-
|
|
153
|
+
r && m ? (o(
|
|
154
154
|
"๐งน CLEANUP EFFECT TRIGGERED",
|
|
155
155
|
"Cleaning up connection on unmount"
|
|
156
|
-
), T.current = null,
|
|
157
|
-
hasService: !!
|
|
156
|
+
), T.current = null, r.disconnectUser().catch(console.error)) : o("๐ CLEANUP EFFECT SKIPPED", {
|
|
157
|
+
hasService: !!r,
|
|
158
158
|
isConnected: m
|
|
159
159
|
});
|
|
160
|
-
}), [
|
|
160
|
+
}), [r, m, o]);
|
|
161
161
|
const f = U(async () => {
|
|
162
|
-
if (
|
|
163
|
-
hasService: !!
|
|
162
|
+
if (o("๐ REFRESH CONNECTION CALLED", {
|
|
163
|
+
hasService: !!r,
|
|
164
164
|
hasUser: !!s
|
|
165
|
-
}), !
|
|
166
|
-
|
|
165
|
+
}), !r || !s) {
|
|
166
|
+
o("โ ๏ธ REFRESH CONNECTION SKIPPED", "Missing service or user");
|
|
167
167
|
return;
|
|
168
168
|
}
|
|
169
|
-
|
|
169
|
+
o("๐ STARTING CONNECTION REFRESH", { userId: s.id }), h(!0);
|
|
170
170
|
try {
|
|
171
|
-
|
|
172
|
-
const
|
|
173
|
-
|
|
174
|
-
} catch (
|
|
175
|
-
const M =
|
|
176
|
-
S(M),
|
|
171
|
+
o("๐ DISCONNECTING FOR REFRESH"), await r.disconnectUser(), o("๐ RECONNECTING FOR REFRESH");
|
|
172
|
+
const w = await r.connectUser(s);
|
|
173
|
+
g(w), I(!0), S(null), o("โ
CONNECTION REFRESH SUCCESS", { userId: s.id });
|
|
174
|
+
} catch (w) {
|
|
175
|
+
const M = w instanceof Error ? w.message : "Refresh failed";
|
|
176
|
+
S(M), o("โ CONNECTION REFRESH ERROR", {
|
|
177
177
|
userId: s.id,
|
|
178
178
|
error: M
|
|
179
179
|
});
|
|
180
180
|
} finally {
|
|
181
|
-
h(!1),
|
|
181
|
+
h(!1), o("๐ CONNECTION REFRESH FINISHED", { userId: s.id });
|
|
182
182
|
}
|
|
183
|
-
}, [
|
|
184
|
-
hasService: !!
|
|
183
|
+
}, [r, s, o]), x = X.useMemo(() => (o("๐ซ CONTEXT VALUE MEMOIZATION", {
|
|
184
|
+
hasService: !!r,
|
|
185
185
|
hasClient: !!u,
|
|
186
186
|
isConnected: m,
|
|
187
|
-
isLoading:
|
|
188
|
-
hasError: !!
|
|
189
|
-
capabilitiesKeys: Object.keys(
|
|
190
|
-
customizationKeys: Object.keys(
|
|
187
|
+
isLoading: N,
|
|
188
|
+
hasError: !!v,
|
|
189
|
+
capabilitiesKeys: Object.keys(i),
|
|
190
|
+
customizationKeys: Object.keys(c)
|
|
191
191
|
}), {
|
|
192
|
-
service:
|
|
192
|
+
service: r,
|
|
193
193
|
client: u,
|
|
194
194
|
isConnected: m,
|
|
195
|
-
isLoading:
|
|
196
|
-
error:
|
|
197
|
-
capabilities:
|
|
198
|
-
customization:
|
|
195
|
+
isLoading: N,
|
|
196
|
+
error: v,
|
|
197
|
+
capabilities: i,
|
|
198
|
+
customization: c,
|
|
199
199
|
refreshConnection: f,
|
|
200
|
-
debug:
|
|
200
|
+
debug: a
|
|
201
201
|
}), [
|
|
202
|
-
|
|
202
|
+
r,
|
|
203
203
|
u,
|
|
204
204
|
m,
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
a,
|
|
208
|
-
d,
|
|
209
|
-
f,
|
|
205
|
+
N,
|
|
206
|
+
v,
|
|
210
207
|
i,
|
|
211
|
-
|
|
208
|
+
c,
|
|
209
|
+
f,
|
|
210
|
+
a,
|
|
211
|
+
o
|
|
212
212
|
]);
|
|
213
|
-
return
|
|
213
|
+
return o("๐ RENDER END", {
|
|
214
214
|
renderCount: k.current,
|
|
215
215
|
willRenderChat: !!(u && m),
|
|
216
|
-
contextValueReady: !!
|
|
217
|
-
}), /* @__PURE__ */ e(he.Provider, { value:
|
|
216
|
+
contextValueReady: !!x
|
|
217
|
+
}), /* @__PURE__ */ e(he.Provider, { value: x, children: u && m ? /* @__PURE__ */ e(Ie, { client: u, children: t }) : t });
|
|
218
218
|
}, Le = () => se();
|
|
219
219
|
function ne({ label: t, className: s, children: n, ...l }) {
|
|
220
|
-
return /* @__PURE__ */
|
|
220
|
+
return /* @__PURE__ */ d(
|
|
221
221
|
"button",
|
|
222
222
|
{
|
|
223
223
|
type: "button",
|
|
@@ -265,8 +265,8 @@ function je(t) {
|
|
|
265
265
|
// olive green
|
|
266
266
|
];
|
|
267
267
|
let n = 0;
|
|
268
|
-
for (let
|
|
269
|
-
n = (n << 5) - n + t.charCodeAt(
|
|
268
|
+
for (let i = 0; i < t.length; i++)
|
|
269
|
+
n = (n << 5) - n + t.charCodeAt(i), n = n & n;
|
|
270
270
|
const l = Math.abs(n) % s.length;
|
|
271
271
|
return s[l];
|
|
272
272
|
}
|
|
@@ -275,15 +275,15 @@ const Y = ({
|
|
|
275
275
|
name: s,
|
|
276
276
|
image: n,
|
|
277
277
|
size: l = 40,
|
|
278
|
-
className:
|
|
278
|
+
className: i
|
|
279
279
|
}) => {
|
|
280
|
-
const { color:
|
|
280
|
+
const { color: c } = je(t), a = s.charAt(0).toUpperCase(), r = l < 32 ? "text-xs" : l < 56 ? "text-sm" : "text-lg";
|
|
281
281
|
return /* @__PURE__ */ e(
|
|
282
282
|
"div",
|
|
283
283
|
{
|
|
284
284
|
className: D(
|
|
285
285
|
"flex-shrink-0 overflow-hidden rounded-full",
|
|
286
|
-
|
|
286
|
+
i
|
|
287
287
|
),
|
|
288
288
|
style: { width: `${l}px`, height: `${l}px` },
|
|
289
289
|
children: n ? /* @__PURE__ */ e(
|
|
@@ -299,75 +299,75 @@ const Y = ({
|
|
|
299
299
|
"aria-hidden": "true",
|
|
300
300
|
className: D(
|
|
301
301
|
"flex h-full w-full items-center justify-center font-semibold",
|
|
302
|
-
|
|
302
|
+
r
|
|
303
303
|
),
|
|
304
304
|
style: {
|
|
305
|
-
color:
|
|
306
|
-
backgroundColor: `color-mix(in srgb, ${
|
|
305
|
+
color: c,
|
|
306
|
+
backgroundColor: `color-mix(in srgb, ${c} 20%, transparent)`
|
|
307
307
|
},
|
|
308
|
-
children:
|
|
308
|
+
children: a
|
|
309
309
|
}
|
|
310
310
|
)
|
|
311
311
|
}
|
|
312
312
|
);
|
|
313
|
-
}, Ae = ({ channel: t, selectedChannel: s, onChannelSelect: n, debug: l = !1 }) => {
|
|
314
|
-
var
|
|
315
|
-
const
|
|
313
|
+
}, Ae = ({ channel: t, selectedChannel: s, onChannelSelect: n, debug: l = !1, unread: i }) => {
|
|
314
|
+
var h, v, S, O, y, k;
|
|
315
|
+
const c = (s == null ? void 0 : s.id) === (t == null ? void 0 : t.id), a = () => {
|
|
316
316
|
t && n(t);
|
|
317
|
-
}, r = Object.values(((
|
|
317
|
+
}, r = Object.values(((h = t == null ? void 0 : t.state) == null ? void 0 : h.members) || {}).find(
|
|
318
318
|
(T) => {
|
|
319
|
-
var f,
|
|
320
|
-
return ((f = T.user) == null ? void 0 : f.id) && T.user.id !== ((
|
|
319
|
+
var f, x;
|
|
320
|
+
return ((f = T.user) == null ? void 0 : f.id) && T.user.id !== ((x = t == null ? void 0 : t._client) == null ? void 0 : x.userID);
|
|
321
321
|
}
|
|
322
|
-
),
|
|
322
|
+
), 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 = (y = (O = t == null ? void 0 : t.state) == null ? void 0 : O.messages) == null ? void 0 : y[t.state.messages.length - 1], m = (g == null ? void 0 : g.text) || "No messages yet", I = g != null && g.created_at ? new Date(g.created_at).toLocaleTimeString([], {
|
|
323
323
|
hour: "2-digit",
|
|
324
324
|
minute: "2-digit"
|
|
325
|
-
}) : "",
|
|
325
|
+
}) : "", N = i ?? 0;
|
|
326
326
|
return l && console.log("๐บ [ChannelList] ๐ CHANNEL PREVIEW RENDER", {
|
|
327
327
|
channelId: t == null ? void 0 : t.id,
|
|
328
|
-
isSelected:
|
|
329
|
-
participantName:
|
|
330
|
-
|
|
331
|
-
hasTimestamp: !!
|
|
328
|
+
isSelected: c,
|
|
329
|
+
participantName: b,
|
|
330
|
+
unreadCount: N,
|
|
331
|
+
hasTimestamp: !!I
|
|
332
332
|
}), /* @__PURE__ */ e(
|
|
333
333
|
"button",
|
|
334
334
|
{
|
|
335
335
|
type: "button",
|
|
336
|
-
onClick:
|
|
336
|
+
onClick: a,
|
|
337
337
|
className: D(
|
|
338
338
|
"w-full px-4 py-3 transition-colors border-b border-sand text-left max-w-full overflow-hidden focus-ring",
|
|
339
339
|
{
|
|
340
|
-
"bg-primary-alt/10 border-l-4 border-l-primary":
|
|
341
|
-
"hover:bg-sand": !
|
|
340
|
+
"bg-primary-alt/10 border-l-4 border-l-primary": c,
|
|
341
|
+
"hover:bg-sand": !c
|
|
342
342
|
}
|
|
343
343
|
),
|
|
344
|
-
children: /* @__PURE__ */
|
|
344
|
+
children: /* @__PURE__ */ d("div", { className: "flex items-start gap-3", children: [
|
|
345
345
|
/* @__PURE__ */ e(
|
|
346
346
|
Y,
|
|
347
347
|
{
|
|
348
348
|
id: ((k = r == null ? void 0 : r.user) == null ? void 0 : k.id) || t.id || "unknown",
|
|
349
|
-
name:
|
|
350
|
-
image:
|
|
349
|
+
name: b,
|
|
350
|
+
image: u,
|
|
351
351
|
size: 44
|
|
352
352
|
}
|
|
353
353
|
),
|
|
354
|
-
/* @__PURE__ */
|
|
355
|
-
/* @__PURE__ */
|
|
354
|
+
/* @__PURE__ */ d("div", { className: "flex-1 min-w-0 flex flex-col gap-1", children: [
|
|
355
|
+
/* @__PURE__ */ d("div", { className: "flex items-center justify-between gap-2", children: [
|
|
356
356
|
/* @__PURE__ */ e(
|
|
357
357
|
"h3",
|
|
358
358
|
{
|
|
359
359
|
className: D(
|
|
360
360
|
"text-sm font-medium truncate",
|
|
361
|
-
|
|
361
|
+
c ? "text-primary" : "text-charcoal"
|
|
362
362
|
),
|
|
363
|
-
children:
|
|
363
|
+
children: b
|
|
364
364
|
}
|
|
365
365
|
),
|
|
366
|
-
|
|
366
|
+
I && /* @__PURE__ */ e("span", { className: "text-xs text-stone flex-shrink-0", children: I })
|
|
367
367
|
] }),
|
|
368
|
-
/* @__PURE__ */
|
|
369
|
-
/* @__PURE__ */ e("p", { className: "text-xs text-stone mr-2 flex-1 line-clamp-2", children:
|
|
370
|
-
|
|
368
|
+
/* @__PURE__ */ d("div", { className: "flex items-center justify-between gap-2 min-w-0", children: [
|
|
369
|
+
/* @__PURE__ */ e("p", { className: "text-xs text-stone mr-2 flex-1 line-clamp-2", children: m }),
|
|
370
|
+
N > 0 && /* @__PURE__ */ e("span", { className: "bg-primary text-white text-xs px-2 py-0.5 rounded-full min-w-[20px] text-center flex-shrink-0", children: N > 99 ? "99+" : N })
|
|
371
371
|
] })
|
|
372
372
|
] })
|
|
373
373
|
] })
|
|
@@ -378,43 +378,43 @@ const Y = ({
|
|
|
378
378
|
selectedChannel: s,
|
|
379
379
|
showStartConversation: n = !1,
|
|
380
380
|
onStartConversation: l,
|
|
381
|
-
participantLabel:
|
|
382
|
-
className:
|
|
381
|
+
participantLabel: i = "participants",
|
|
382
|
+
className: c
|
|
383
383
|
}) => {
|
|
384
384
|
var u;
|
|
385
|
-
const
|
|
386
|
-
|
|
387
|
-
const { debug:
|
|
388
|
-
|
|
389
|
-
renderCount:
|
|
385
|
+
const a = X.useRef(0);
|
|
386
|
+
a.current++;
|
|
387
|
+
const { debug: o = !1 } = se();
|
|
388
|
+
o && console.log("๐บ [ChannelList] ๐ RENDER START", {
|
|
389
|
+
renderCount: a.current,
|
|
390
390
|
selectedChannelId: s == null ? void 0 : s.id,
|
|
391
391
|
showStartConversation: n,
|
|
392
|
-
participantLabel:
|
|
392
|
+
participantLabel: i
|
|
393
393
|
});
|
|
394
|
-
const { client:
|
|
395
|
-
|
|
396
|
-
renderCount:
|
|
397
|
-
hasClient: !!
|
|
398
|
-
clientUserId:
|
|
399
|
-
clientConnected: (u =
|
|
394
|
+
const { client: r } = ye();
|
|
395
|
+
o && console.log("๐บ [ChannelList] ๐ก CHAT CONTEXT", {
|
|
396
|
+
renderCount: a.current,
|
|
397
|
+
hasClient: !!r,
|
|
398
|
+
clientUserId: r == null ? void 0 : r.userID,
|
|
399
|
+
clientConnected: (u = r == null ? void 0 : r.wsConnection) == null ? void 0 : u.isHealthy
|
|
400
400
|
});
|
|
401
|
-
const
|
|
402
|
-
const
|
|
403
|
-
return
|
|
404
|
-
renderCount:
|
|
405
|
-
userId:
|
|
401
|
+
const b = X.useMemo(() => {
|
|
402
|
+
const g = r.userID, m = g ? { type: "messaging", members: { $in: [g] }, hidden: !1 } : { type: "messaging" };
|
|
403
|
+
return o && console.log("๐บ [ChannelList] ๐ FILTERS MEMOIZED", {
|
|
404
|
+
renderCount: a.current,
|
|
405
|
+
userId: g,
|
|
406
406
|
filters: m
|
|
407
407
|
}), m;
|
|
408
|
-
}, [
|
|
409
|
-
return /* @__PURE__ */
|
|
408
|
+
}, [r.userID, o]);
|
|
409
|
+
return /* @__PURE__ */ d(
|
|
410
410
|
"div",
|
|
411
411
|
{
|
|
412
412
|
className: D(
|
|
413
413
|
"messaging-channel-list h-full flex flex-col min-w-0 overflow-hidden",
|
|
414
|
-
|
|
414
|
+
c
|
|
415
415
|
),
|
|
416
416
|
children: [
|
|
417
|
-
/* @__PURE__ */ e("div", { className: "px-4 py-4 border-b border-sand bg-chalk", children: /* @__PURE__ */
|
|
417
|
+
/* @__PURE__ */ e("div", { className: "px-4 py-4 border-b border-sand bg-chalk", children: /* @__PURE__ */ d("div", { className: "flex items-center justify-between gap-3 min-h-10 min-w-0", children: [
|
|
418
418
|
/* @__PURE__ */ e("h2", { className: "text-lg font-semibold text-charcoal", children: "Conversations" }),
|
|
419
419
|
/* @__PURE__ */ e("div", { className: "flex items-center gap-2", children: n && l && /* @__PURE__ */ e(
|
|
420
420
|
ne,
|
|
@@ -426,30 +426,30 @@ const Y = ({
|
|
|
426
426
|
}
|
|
427
427
|
) })
|
|
428
428
|
] }) }),
|
|
429
|
-
/* @__PURE__ */ e("div", { className: "flex-1 overflow-hidden min-w-0", children: (
|
|
430
|
-
renderCount:
|
|
431
|
-
filters:
|
|
432
|
-
hasClient: !!
|
|
433
|
-
clientUserId:
|
|
429
|
+
/* @__PURE__ */ e("div", { className: "flex-1 overflow-hidden min-w-0", children: (o && console.log("๐บ [ChannelList] ๐ฌ RENDERING STREAM CHANNEL LIST", {
|
|
430
|
+
renderCount: a.current,
|
|
431
|
+
filters: b,
|
|
432
|
+
hasClient: !!r,
|
|
433
|
+
clientUserId: r == null ? void 0 : r.userID
|
|
434
434
|
}), /* @__PURE__ */ e(
|
|
435
435
|
Se,
|
|
436
436
|
{
|
|
437
|
-
filters:
|
|
437
|
+
filters: b,
|
|
438
438
|
sort: { last_message_at: -1 },
|
|
439
439
|
options: { limit: 30 },
|
|
440
|
-
Preview: (
|
|
441
|
-
var m,
|
|
442
|
-
return
|
|
443
|
-
channelId: (m =
|
|
440
|
+
Preview: (g) => {
|
|
441
|
+
var m, I;
|
|
442
|
+
return o && console.log("๐บ [ChannelList] ๐ CHANNEL PREVIEW RENDER", {
|
|
443
|
+
channelId: (m = g.channel) == null ? void 0 : m.id,
|
|
444
444
|
selectedChannelId: s == null ? void 0 : s.id,
|
|
445
|
-
isSelected: (s == null ? void 0 : s.id) === ((
|
|
445
|
+
isSelected: (s == null ? void 0 : s.id) === ((I = g.channel) == null ? void 0 : I.id)
|
|
446
446
|
}), /* @__PURE__ */ e(
|
|
447
447
|
Ae,
|
|
448
448
|
{
|
|
449
|
-
...
|
|
449
|
+
...g,
|
|
450
450
|
selectedChannel: s,
|
|
451
451
|
onChannelSelect: t,
|
|
452
|
-
debug:
|
|
452
|
+
debug: o
|
|
453
453
|
}
|
|
454
454
|
);
|
|
455
455
|
}
|
|
@@ -479,19 +479,19 @@ const Y = ({
|
|
|
479
479
|
function fe({ onClick: t }) {
|
|
480
480
|
return /* @__PURE__ */ e(ne, { label: "Close", onClick: t, className: "p-1", children: /* @__PURE__ */ e(me, { className: "h-5 w-5 text-stone", weight: "bold" }) });
|
|
481
481
|
}
|
|
482
|
-
const He = ({ renderActions: t }) => /* @__PURE__ */
|
|
482
|
+
const He = ({ renderActions: t }) => /* @__PURE__ */ d("div", { className: "message-input flex items-center gap-2 p-4", children: [
|
|
483
483
|
t && t(),
|
|
484
484
|
/* @__PURE__ */ e("div", { className: "flex-1", children: /* @__PURE__ */ e(Pe, { focus: !0, maxRows: 4 }) })
|
|
485
485
|
] }), Ge = ({ onBack: t, showBackButton: s, onShowInfo: n, canShowInfo: l }) => {
|
|
486
|
-
var
|
|
487
|
-
const { channel:
|
|
488
|
-
(
|
|
489
|
-
var
|
|
490
|
-
return ((
|
|
486
|
+
var r, b, u, g;
|
|
487
|
+
const { channel: i } = ue(), c = X.useMemo(() => Object.values(i.state.members || {}).find(
|
|
488
|
+
(I) => {
|
|
489
|
+
var N;
|
|
490
|
+
return ((N = I.user) == null ? void 0 : N.id) && I.user.id !== i._client.userID;
|
|
491
491
|
}
|
|
492
|
-
), [
|
|
493
|
-
return /* @__PURE__ */
|
|
494
|
-
/* @__PURE__ */
|
|
492
|
+
), [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", o = (u = c == null ? void 0 : c.user) == null ? void 0 : u.image;
|
|
493
|
+
return /* @__PURE__ */ d("div", { className: "flex items-center justify-between gap-3 min-h-12", children: [
|
|
494
|
+
/* @__PURE__ */ d("div", { className: "flex items-center gap-3 min-w-0", children: [
|
|
495
495
|
s && t && /* @__PURE__ */ e(
|
|
496
496
|
"button",
|
|
497
497
|
{
|
|
@@ -505,13 +505,13 @@ const He = ({ renderActions: t }) => /* @__PURE__ */ c("div", { className: "mess
|
|
|
505
505
|
/* @__PURE__ */ e(
|
|
506
506
|
Y,
|
|
507
507
|
{
|
|
508
|
-
id: ((
|
|
509
|
-
name:
|
|
510
|
-
image:
|
|
508
|
+
id: ((g = c == null ? void 0 : c.user) == null ? void 0 : g.id) || i.id || "unknown",
|
|
509
|
+
name: a,
|
|
510
|
+
image: o,
|
|
511
511
|
size: 40
|
|
512
512
|
}
|
|
513
513
|
),
|
|
514
|
-
/* @__PURE__ */ e("div", { className: "min-w-0", children: /* @__PURE__ */ e("h1", { className: "text-lg font-semibold text-charcoal truncate", children:
|
|
514
|
+
/* @__PURE__ */ e("div", { className: "min-w-0", children: /* @__PURE__ */ e("h1", { className: "text-lg font-semibold text-charcoal truncate", children: a }) })
|
|
515
515
|
] }),
|
|
516
516
|
l && n && /* @__PURE__ */ e(ne, { label: "Chat info", onClick: n, children: /* @__PURE__ */ e(Oe, { className: "h-6 w-6 text-charcoal", weight: "bold" }) })
|
|
517
517
|
] });
|
|
@@ -520,56 +520,56 @@ const He = ({ renderActions: t }) => /* @__PURE__ */ c("div", { className: "mess
|
|
|
520
520
|
onClose: s,
|
|
521
521
|
participant: n,
|
|
522
522
|
channel: l,
|
|
523
|
-
followerStatusLabel:
|
|
524
|
-
onLeaveConversation:
|
|
525
|
-
onBlockParticipant:
|
|
523
|
+
followerStatusLabel: i,
|
|
524
|
+
onLeaveConversation: c,
|
|
525
|
+
onBlockParticipant: a
|
|
526
526
|
}) => {
|
|
527
527
|
var L, $, _, V, Q, W, z;
|
|
528
|
-
const { service:
|
|
528
|
+
const { service: o, debug: r } = se(), b = H(null), [u, g] = E(!1), [m, I] = E(!1), [N, h] = E(!1);
|
|
529
529
|
G(() => {
|
|
530
|
-
const R =
|
|
530
|
+
const R = b.current;
|
|
531
531
|
R && (t ? R.showModal() : R.close());
|
|
532
532
|
}, [t]);
|
|
533
|
-
const
|
|
533
|
+
const v = U(async () => {
|
|
534
534
|
var R;
|
|
535
|
-
if (!(!
|
|
535
|
+
if (!(!o || !((R = n == null ? void 0 : n.user) != null && R.id)))
|
|
536
536
|
try {
|
|
537
|
-
const A = (await
|
|
537
|
+
const A = (await o.getBlockedUsers()).some(
|
|
538
538
|
(q) => {
|
|
539
539
|
var Z;
|
|
540
540
|
return q.blocked_user_id === ((Z = n == null ? void 0 : n.user) == null ? void 0 : Z.id);
|
|
541
541
|
}
|
|
542
542
|
);
|
|
543
|
-
|
|
543
|
+
g(A);
|
|
544
544
|
} catch (P) {
|
|
545
545
|
console.error(
|
|
546
546
|
"[ChannelInfoDialog] Failed to check blocked status:",
|
|
547
547
|
P
|
|
548
548
|
);
|
|
549
549
|
}
|
|
550
|
-
}, [
|
|
550
|
+
}, [o, (L = n == null ? void 0 : n.user) == null ? void 0 : L.id]);
|
|
551
551
|
G(() => {
|
|
552
|
-
t &&
|
|
553
|
-
}, [t,
|
|
552
|
+
t && v();
|
|
553
|
+
}, [t, v]);
|
|
554
554
|
const S = async () => {
|
|
555
555
|
var R;
|
|
556
556
|
if (!m) {
|
|
557
|
-
|
|
557
|
+
r && console.log("[ChannelInfoDialog] Leave conversation", l.cid), I(!0);
|
|
558
558
|
try {
|
|
559
559
|
const P = ((R = l._client) == null ? void 0 : R.userID) ?? null;
|
|
560
|
-
await l.hide(P, !1),
|
|
560
|
+
await l.hide(P, !1), c && await c(l), s();
|
|
561
561
|
} catch (P) {
|
|
562
562
|
console.error("[ChannelInfoDialog] Failed to leave conversation", P);
|
|
563
563
|
} finally {
|
|
564
|
-
|
|
564
|
+
I(!1);
|
|
565
565
|
}
|
|
566
566
|
}
|
|
567
567
|
}, O = async () => {
|
|
568
568
|
var R, P, A;
|
|
569
|
-
if (!(
|
|
570
|
-
|
|
569
|
+
if (!(N || !o)) {
|
|
570
|
+
r && console.log("[ChannelInfoDialog] Block member", (R = n == null ? void 0 : n.user) == null ? void 0 : R.id), h(!0);
|
|
571
571
|
try {
|
|
572
|
-
await
|
|
572
|
+
await o.blockUser((P = n == null ? void 0 : n.user) == null ? void 0 : P.id), a && await a((A = n == null ? void 0 : n.user) == null ? void 0 : A.id), s();
|
|
573
573
|
} catch (q) {
|
|
574
574
|
console.error("[ChannelInfoDialog] Failed to block member", q);
|
|
575
575
|
} finally {
|
|
@@ -578,10 +578,10 @@ const He = ({ renderActions: t }) => /* @__PURE__ */ c("div", { className: "mess
|
|
|
578
578
|
}
|
|
579
579
|
}, y = async () => {
|
|
580
580
|
var R, P, A;
|
|
581
|
-
if (!(
|
|
582
|
-
|
|
581
|
+
if (!(N || !o)) {
|
|
582
|
+
r && console.log("[ChannelInfoDialog] Unblock member", (R = n == null ? void 0 : n.user) == null ? void 0 : R.id), h(!0);
|
|
583
583
|
try {
|
|
584
|
-
await
|
|
584
|
+
await o.unBlockUser((P = n == null ? void 0 : n.user) == null ? void 0 : P.id), a && await a((A = n == null ? void 0 : n.user) == null ? void 0 : A.id), s();
|
|
585
585
|
} catch (q) {
|
|
586
586
|
console.error("[ChannelInfoDialog] Failed to unblock member", q);
|
|
587
587
|
} finally {
|
|
@@ -596,25 +596,25 @@ const He = ({ renderActions: t }) => /* @__PURE__ */ c("div", { className: "mess
|
|
|
596
596
|
);
|
|
597
597
|
};
|
|
598
598
|
if (!n) return null;
|
|
599
|
-
const T = (($ = n.user) == null ? void 0 : $.name) || ((_ = n.user) == null ? void 0 : _.id) || "Unknown member", f = (V = n.user) == null ? void 0 : V.image,
|
|
599
|
+
const T = (($ = n.user) == null ? void 0 : $.name) || ((_ = n.user) == null ? void 0 : _.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, M = x || (w ? `linktr.ee/${w}` : void 0), p = ((z = n.user) == null ? void 0 : z.id) || "unknown";
|
|
600
600
|
return (
|
|
601
601
|
// eslint-disable-next-line jsx-a11y/click-events-have-key-events, jsx-a11y/no-noninteractive-element-interactions
|
|
602
602
|
/* @__PURE__ */ e(
|
|
603
603
|
"dialog",
|
|
604
604
|
{
|
|
605
|
-
ref:
|
|
605
|
+
ref: b,
|
|
606
606
|
className: "mes-dialog",
|
|
607
607
|
onClose: s,
|
|
608
608
|
onClick: (R) => {
|
|
609
|
-
R.target ===
|
|
609
|
+
R.target === b.current && s();
|
|
610
610
|
},
|
|
611
|
-
children: /* @__PURE__ */
|
|
612
|
-
/* @__PURE__ */
|
|
611
|
+
children: /* @__PURE__ */ d("div", { className: "ml-auto flex h-full w-full flex-col bg-white shadow-max-elevation-light", children: [
|
|
612
|
+
/* @__PURE__ */ d("div", { className: "flex items-center justify-between border-b border-sand px-4 py-3", children: [
|
|
613
613
|
/* @__PURE__ */ e("h2", { className: "text-base font-semibold text-charcoal", children: "Chat info" }),
|
|
614
614
|
/* @__PURE__ */ e(fe, { onClick: s })
|
|
615
615
|
] }),
|
|
616
|
-
/* @__PURE__ */
|
|
617
|
-
/* @__PURE__ */ e("div", { className: "rounded-2xl bg-chalk p-4", children: /* @__PURE__ */
|
|
616
|
+
/* @__PURE__ */ d("div", { className: "flex-1 overflow-y-auto px-6 py-6", children: [
|
|
617
|
+
/* @__PURE__ */ e("div", { className: "rounded-2xl bg-chalk p-4", children: /* @__PURE__ */ d("div", { className: "flex items-center gap-4", children: [
|
|
618
618
|
/* @__PURE__ */ e(
|
|
619
619
|
Y,
|
|
620
620
|
{
|
|
@@ -624,14 +624,14 @@ const He = ({ renderActions: t }) => /* @__PURE__ */ c("div", { className: "mess
|
|
|
624
624
|
size: 64
|
|
625
625
|
}
|
|
626
626
|
),
|
|
627
|
-
/* @__PURE__ */
|
|
627
|
+
/* @__PURE__ */ d("div", { className: "min-w-0 flex-1", children: [
|
|
628
628
|
/* @__PURE__ */ e("p", { className: "truncate text-base font-semibold text-charcoal", children: T }),
|
|
629
629
|
M && /* @__PURE__ */ e("p", { className: "truncate text-sm text-stone", children: M }),
|
|
630
|
-
|
|
630
|
+
i && /* @__PURE__ */ e("span", { className: "mt-2 inline-flex items-center rounded-full bg-green-100 px-2 py-0.5 text-xs font-medium text-green-700", children: i })
|
|
631
631
|
] })
|
|
632
632
|
] }) }),
|
|
633
|
-
/* @__PURE__ */
|
|
634
|
-
/* @__PURE__ */ e("li", { children: /* @__PURE__ */
|
|
633
|
+
/* @__PURE__ */ d("ul", { className: "flex flex-col gap-2 mt-2", children: [
|
|
634
|
+
/* @__PURE__ */ e("li", { children: /* @__PURE__ */ d(
|
|
635
635
|
K,
|
|
636
636
|
{
|
|
637
637
|
onClick: S,
|
|
@@ -643,30 +643,30 @@ const He = ({ renderActions: t }) => /* @__PURE__ */ c("div", { className: "mess
|
|
|
643
643
|
]
|
|
644
644
|
}
|
|
645
645
|
) }),
|
|
646
|
-
/* @__PURE__ */ e("li", { children: u ? /* @__PURE__ */
|
|
646
|
+
/* @__PURE__ */ e("li", { children: u ? /* @__PURE__ */ d(
|
|
647
647
|
K,
|
|
648
648
|
{
|
|
649
649
|
onClick: y,
|
|
650
|
-
disabled:
|
|
651
|
-
"aria-busy":
|
|
650
|
+
disabled: N,
|
|
651
|
+
"aria-busy": N,
|
|
652
652
|
children: [
|
|
653
|
-
|
|
653
|
+
N ? /* @__PURE__ */ e(ee, { className: "h-5 w-5 animate-spin" }) : /* @__PURE__ */ e(ie, { className: "h-5 w-5" }),
|
|
654
654
|
/* @__PURE__ */ e("span", { children: "Unblock" })
|
|
655
655
|
]
|
|
656
656
|
}
|
|
657
|
-
) : /* @__PURE__ */
|
|
657
|
+
) : /* @__PURE__ */ d(
|
|
658
658
|
K,
|
|
659
659
|
{
|
|
660
660
|
onClick: O,
|
|
661
|
-
disabled:
|
|
662
|
-
"aria-busy":
|
|
661
|
+
disabled: N,
|
|
662
|
+
"aria-busy": N,
|
|
663
663
|
children: [
|
|
664
|
-
|
|
664
|
+
N ? /* @__PURE__ */ e(ee, { className: "h-5 w-5 animate-spin" }) : /* @__PURE__ */ e(ie, { className: "h-5 w-5" }),
|
|
665
665
|
/* @__PURE__ */ e("span", { children: "Block" })
|
|
666
666
|
]
|
|
667
667
|
}
|
|
668
668
|
) }),
|
|
669
|
-
/* @__PURE__ */ e("li", { children: /* @__PURE__ */
|
|
669
|
+
/* @__PURE__ */ e("li", { children: /* @__PURE__ */ d(K, { variant: "danger", onClick: k, children: [
|
|
670
670
|
/* @__PURE__ */ e(Fe, { className: "h-5 w-5" }),
|
|
671
671
|
/* @__PURE__ */ e("span", { children: "Report" })
|
|
672
672
|
] }) })
|
|
@@ -681,51 +681,51 @@ const He = ({ renderActions: t }) => /* @__PURE__ */ c("div", { className: "mess
|
|
|
681
681
|
showBackButton: s,
|
|
682
682
|
renderMessageInputActions: n,
|
|
683
683
|
onLeaveConversation: l,
|
|
684
|
-
onBlockParticipant:
|
|
685
|
-
CustomChannelEmptyState:
|
|
684
|
+
onBlockParticipant: i,
|
|
685
|
+
CustomChannelEmptyState: c
|
|
686
686
|
}) => {
|
|
687
|
-
var m,
|
|
688
|
-
const { channel:
|
|
687
|
+
var m, I;
|
|
688
|
+
const { channel: a } = ue(), [o, r] = E(!1), b = (((I = (m = a == null ? void 0 : a.state) == null ? void 0 : m.messages) == null ? void 0 : I.length) ?? 0) > 0, u = X.useMemo(() => Object.values(a.state.members || {}).find(
|
|
689
689
|
(h) => {
|
|
690
|
-
var
|
|
691
|
-
return ((
|
|
690
|
+
var v;
|
|
691
|
+
return ((v = h.user) == null ? void 0 : v.id) && h.user.id !== a._client.userID;
|
|
692
692
|
}
|
|
693
|
-
), [
|
|
694
|
-
const
|
|
695
|
-
return
|
|
696
|
-
}, [
|
|
697
|
-
return /* @__PURE__ */
|
|
698
|
-
/* @__PURE__ */
|
|
693
|
+
), [a._client.userID, a.state.members]), g = X.useMemo(() => {
|
|
694
|
+
const N = a.data ?? {};
|
|
695
|
+
return N.followerStatus ? String(N.followerStatus) : N.isFollower ? "Subscribed to you" : void 0;
|
|
696
|
+
}, [a.data]);
|
|
697
|
+
return /* @__PURE__ */ d(oe, { children: [
|
|
698
|
+
/* @__PURE__ */ d(ke, { children: [
|
|
699
699
|
/* @__PURE__ */ e("div", { className: "border-b border-sand bg-white px-4 py-3", children: /* @__PURE__ */ e(
|
|
700
700
|
Ge,
|
|
701
701
|
{
|
|
702
702
|
onBack: t,
|
|
703
703
|
showBackButton: s,
|
|
704
|
-
onShowInfo: () =>
|
|
704
|
+
onShowInfo: () => r(!0),
|
|
705
705
|
canShowInfo: !!u
|
|
706
706
|
}
|
|
707
707
|
) }),
|
|
708
|
-
/* @__PURE__ */
|
|
708
|
+
/* @__PURE__ */ d("div", { className: "flex-1 overflow-hidden relative", children: [
|
|
709
709
|
/* @__PURE__ */ e(Te, { hideDeletedMessages: !0, hideNewMessageSeparator: !1 }),
|
|
710
|
-
!
|
|
710
|
+
!b && c && /* @__PURE__ */ e("div", { className: "absolute inset-0 flex bg-white", children: /* @__PURE__ */ e(c, {}) })
|
|
711
711
|
] }),
|
|
712
712
|
/* @__PURE__ */ e(
|
|
713
713
|
He,
|
|
714
714
|
{
|
|
715
|
-
renderActions: () => n == null ? void 0 : n(
|
|
715
|
+
renderActions: () => n == null ? void 0 : n(a)
|
|
716
716
|
}
|
|
717
717
|
)
|
|
718
718
|
] }),
|
|
719
719
|
/* @__PURE__ */ e(
|
|
720
720
|
$e,
|
|
721
721
|
{
|
|
722
|
-
isOpen:
|
|
723
|
-
onClose: () =>
|
|
722
|
+
isOpen: o,
|
|
723
|
+
onClose: () => r(!1),
|
|
724
724
|
participant: u,
|
|
725
|
-
channel:
|
|
726
|
-
followerStatusLabel:
|
|
725
|
+
channel: a,
|
|
726
|
+
followerStatusLabel: g,
|
|
727
727
|
onLeaveConversation: l,
|
|
728
|
-
onBlockParticipant:
|
|
728
|
+
onBlockParticipant: i
|
|
729
729
|
}
|
|
730
730
|
)
|
|
731
731
|
] });
|
|
@@ -734,16 +734,16 @@ const He = ({ renderActions: t }) => /* @__PURE__ */ c("div", { className: "mess
|
|
|
734
734
|
onBack: s,
|
|
735
735
|
showBackButton: n = !1,
|
|
736
736
|
renderMessageInputActions: l,
|
|
737
|
-
onLeaveConversation:
|
|
738
|
-
onBlockParticipant:
|
|
739
|
-
className:
|
|
740
|
-
CustomChannelEmptyState:
|
|
737
|
+
onLeaveConversation: i,
|
|
738
|
+
onBlockParticipant: c,
|
|
739
|
+
className: a,
|
|
740
|
+
CustomChannelEmptyState: o
|
|
741
741
|
}) => /* @__PURE__ */ e(
|
|
742
742
|
"div",
|
|
743
743
|
{
|
|
744
744
|
className: D(
|
|
745
745
|
"messaging-channel-view h-full flex flex-col",
|
|
746
|
-
|
|
746
|
+
a
|
|
747
747
|
),
|
|
748
748
|
children: /* @__PURE__ */ e(Re, { channel: t, children: /* @__PURE__ */ e(
|
|
749
749
|
_e,
|
|
@@ -751,9 +751,9 @@ const He = ({ renderActions: t }) => /* @__PURE__ */ c("div", { className: "mess
|
|
|
751
751
|
onBack: s,
|
|
752
752
|
showBackButton: n,
|
|
753
753
|
renderMessageInputActions: l,
|
|
754
|
-
onLeaveConversation:
|
|
755
|
-
onBlockParticipant:
|
|
756
|
-
CustomChannelEmptyState:
|
|
754
|
+
onLeaveConversation: i,
|
|
755
|
+
onBlockParticipant: c,
|
|
756
|
+
CustomChannelEmptyState: o
|
|
757
757
|
}
|
|
758
758
|
) })
|
|
759
759
|
}
|
|
@@ -764,7 +764,7 @@ function We({
|
|
|
764
764
|
placeholder: n
|
|
765
765
|
}) {
|
|
766
766
|
const l = H(null);
|
|
767
|
-
return /* @__PURE__ */
|
|
767
|
+
return /* @__PURE__ */ d("div", { className: "relative", children: [
|
|
768
768
|
/* @__PURE__ */ e(
|
|
769
769
|
pe,
|
|
770
770
|
{
|
|
@@ -779,7 +779,7 @@ function We({
|
|
|
779
779
|
type: "text",
|
|
780
780
|
placeholder: n,
|
|
781
781
|
value: t,
|
|
782
|
-
onChange: (
|
|
782
|
+
onChange: (i) => s(i.target.value),
|
|
783
783
|
className: "w-full pl-10 pr-10 py-3 text-sm border border-sand rounded-xl focus:outline-none focus:ring-2 focus:ring-black focus:border-transparent"
|
|
784
784
|
}
|
|
785
785
|
),
|
|
@@ -788,8 +788,8 @@ function We({
|
|
|
788
788
|
{
|
|
789
789
|
label: "Clear search",
|
|
790
790
|
onClick: () => {
|
|
791
|
-
var
|
|
792
|
-
s(""), (
|
|
791
|
+
var i;
|
|
792
|
+
s(""), (i = l.current) == null || i.focus();
|
|
793
793
|
},
|
|
794
794
|
className: "absolute right-3 top-1/2 -translate-y-1/2 p-1 text-stone hover:text-charcoal",
|
|
795
795
|
children: /* @__PURE__ */ e(me, { className: "h-4 w-4", weight: "bold" })
|
|
@@ -802,104 +802,104 @@ const ze = ({
|
|
|
802
802
|
onSelectParticipant: s,
|
|
803
803
|
onClose: n,
|
|
804
804
|
existingParticipantIds: l = /* @__PURE__ */ new Set(),
|
|
805
|
-
participantLabel:
|
|
806
|
-
searchPlaceholder:
|
|
807
|
-
className:
|
|
805
|
+
participantLabel: i = "participants",
|
|
806
|
+
searchPlaceholder: c = "Search participants...",
|
|
807
|
+
className: a
|
|
808
808
|
}) => {
|
|
809
|
-
const { debug:
|
|
809
|
+
const { debug: o } = se(), [r, b] = E(""), [u, g] = E([]), [m, I] = E(!1), [N, h] = E(null), [v, S] = E(
|
|
810
810
|
null
|
|
811
811
|
), O = H(!1);
|
|
812
812
|
G(() => {
|
|
813
813
|
if (t.loading) {
|
|
814
|
-
|
|
814
|
+
o && console.log(
|
|
815
815
|
"[ParticipantPicker] Waiting for participant source to finish loading..."
|
|
816
816
|
);
|
|
817
817
|
return;
|
|
818
818
|
}
|
|
819
819
|
if (O.current) return;
|
|
820
820
|
(async () => {
|
|
821
|
-
|
|
821
|
+
o && console.log("[ParticipantPicker] Loading initial participants..."), I(!0), h(null);
|
|
822
822
|
try {
|
|
823
|
-
const
|
|
823
|
+
const x = await t.loadParticipants({
|
|
824
824
|
search: "",
|
|
825
825
|
// Load all participants initially
|
|
826
826
|
limit: 100
|
|
827
827
|
});
|
|
828
|
-
|
|
828
|
+
g(x.participants), O.current = !0, o && console.log(
|
|
829
829
|
"[ParticipantPicker] Participants loaded successfully:",
|
|
830
|
-
|
|
830
|
+
x.participants.length
|
|
831
831
|
);
|
|
832
|
-
} catch (
|
|
833
|
-
const
|
|
834
|
-
h(
|
|
832
|
+
} catch (x) {
|
|
833
|
+
const w = x instanceof Error ? x.message : "Failed to load participants";
|
|
834
|
+
h(w), console.error("[ParticipantPicker] Failed to load participants:", x);
|
|
835
835
|
} finally {
|
|
836
|
-
|
|
836
|
+
I(!1);
|
|
837
837
|
}
|
|
838
838
|
})();
|
|
839
|
-
}, [t.loading,
|
|
839
|
+
}, [t.loading, o]);
|
|
840
840
|
const y = u.filter((f) => !l.has(f.id)).filter((f) => {
|
|
841
|
-
var
|
|
842
|
-
if (!
|
|
843
|
-
const
|
|
844
|
-
return f.name.toLowerCase().includes(
|
|
841
|
+
var w;
|
|
842
|
+
if (!r) return !0;
|
|
843
|
+
const x = r.toLowerCase();
|
|
844
|
+
return f.name.toLowerCase().includes(x) || ((w = f.email) == null ? void 0 : w.toLowerCase().includes(x)) || !1;
|
|
845
845
|
}), k = U(
|
|
846
846
|
async (f) => {
|
|
847
|
-
if (!
|
|
847
|
+
if (!v) {
|
|
848
848
|
S(f.id);
|
|
849
849
|
try {
|
|
850
850
|
await s(f);
|
|
851
|
-
} catch (
|
|
852
|
-
console.error("[ParticipantPicker] Failed to start chat:",
|
|
851
|
+
} catch (x) {
|
|
852
|
+
console.error("[ParticipantPicker] Failed to start chat:", x), S(null);
|
|
853
853
|
}
|
|
854
854
|
}
|
|
855
855
|
},
|
|
856
|
-
[s,
|
|
857
|
-
), T = (f,
|
|
858
|
-
(f.key === "Enter" || f.key === " ") && (f.preventDefault(), k(
|
|
856
|
+
[s, v]
|
|
857
|
+
), T = (f, x) => {
|
|
858
|
+
(f.key === "Enter" || f.key === " ") && (f.preventDefault(), k(x));
|
|
859
859
|
};
|
|
860
|
-
return /* @__PURE__ */
|
|
861
|
-
/* @__PURE__ */
|
|
862
|
-
/* @__PURE__ */
|
|
860
|
+
return /* @__PURE__ */ d("div", { className: D("flex flex-col h-full", a), children: [
|
|
861
|
+
/* @__PURE__ */ d("div", { className: "px-4 py-4 border-b border-sand bg-chalk", children: [
|
|
862
|
+
/* @__PURE__ */ d("div", { className: "flex items-center justify-between mb-3", children: [
|
|
863
863
|
/* @__PURE__ */ e("h2", { className: "text-lg font-semibold text-charcoal", children: "Start a new Conversation" }),
|
|
864
864
|
/* @__PURE__ */ e(fe, { onClick: n })
|
|
865
865
|
] }),
|
|
866
|
-
/* @__PURE__ */
|
|
866
|
+
/* @__PURE__ */ d("p", { className: "text-xs text-stone mb-3", children: [
|
|
867
867
|
"Select a ",
|
|
868
|
-
|
|
868
|
+
i.slice(0, -1),
|
|
869
869
|
" to start messaging (",
|
|
870
870
|
y.length,
|
|
871
871
|
" available)",
|
|
872
|
-
t.totalCount !== void 0 && ` โข ${t.totalCount} ${
|
|
872
|
+
t.totalCount !== void 0 && ` โข ${t.totalCount} ${i} total`
|
|
873
873
|
] }),
|
|
874
874
|
/* @__PURE__ */ e(
|
|
875
875
|
We,
|
|
876
876
|
{
|
|
877
|
-
searchQuery:
|
|
878
|
-
setSearchQuery:
|
|
879
|
-
placeholder:
|
|
877
|
+
searchQuery: r,
|
|
878
|
+
setSearchQuery: b,
|
|
879
|
+
placeholder: c
|
|
880
880
|
}
|
|
881
881
|
)
|
|
882
882
|
] }),
|
|
883
|
-
|
|
883
|
+
N && /* @__PURE__ */ d("div", { className: "p-4 text-sm text-danger bg-danger-alt", children: [
|
|
884
884
|
"Error loading ",
|
|
885
|
-
|
|
885
|
+
i,
|
|
886
886
|
": ",
|
|
887
|
-
|
|
887
|
+
N
|
|
888
888
|
] }),
|
|
889
|
-
/* @__PURE__ */ e("div", { className: "flex-1 overflow-auto", children: m && y.length === 0 ? /* @__PURE__ */ e("div", { className: "h-32 flex items-center justify-center", children: /* @__PURE__ */
|
|
889
|
+
/* @__PURE__ */ e("div", { className: "flex-1 overflow-auto", children: m && y.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: [
|
|
890
890
|
/* @__PURE__ */ e("div", { className: "w-4 h-4 animate-spin rounded-full border-2 border-primary border-t-transparent" }),
|
|
891
|
-
/* @__PURE__ */
|
|
891
|
+
/* @__PURE__ */ d("span", { className: "text-sm text-stone", children: [
|
|
892
892
|
"Loading ",
|
|
893
|
-
|
|
893
|
+
i,
|
|
894
894
|
"..."
|
|
895
895
|
] })
|
|
896
|
-
] }) }) : y.length === 0 ? /* @__PURE__ */
|
|
896
|
+
] }) }) : y.length === 0 ? /* @__PURE__ */ d("div", { className: "p-6 text-center", children: [
|
|
897
897
|
/* @__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" }) }),
|
|
898
|
-
/* @__PURE__ */ e("h3", { className: "text-sm font-semibold text-charcoal mb-2", children:
|
|
899
|
-
/* @__PURE__ */ e("p", { className: "text-xs text-stone", children:
|
|
900
|
-
] }) : /* @__PURE__ */
|
|
898
|
+
/* @__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` }),
|
|
899
|
+
/* @__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` })
|
|
900
|
+
] }) : /* @__PURE__ */ d("ul", { className: "space-y-0", children: [
|
|
901
901
|
y.map((f) => {
|
|
902
|
-
const
|
|
902
|
+
const x = f.name || f.email || f.id, w = f.email && f.name ? f.email : f.phone;
|
|
903
903
|
return /* @__PURE__ */ e("li", { children: /* @__PURE__ */ e(
|
|
904
904
|
"button",
|
|
905
905
|
{
|
|
@@ -907,46 +907,46 @@ const ze = ({
|
|
|
907
907
|
onClick: () => k(f),
|
|
908
908
|
onKeyDown: (M) => T(M, f),
|
|
909
909
|
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",
|
|
910
|
-
children: /* @__PURE__ */
|
|
911
|
-
/* @__PURE__ */
|
|
910
|
+
children: /* @__PURE__ */ d("div", { className: "flex items-center justify-between", children: [
|
|
911
|
+
/* @__PURE__ */ d("div", { className: "flex items-center space-x-3 flex-1 min-w-0", children: [
|
|
912
912
|
/* @__PURE__ */ e(
|
|
913
913
|
Y,
|
|
914
914
|
{
|
|
915
915
|
id: f.id,
|
|
916
|
-
name:
|
|
916
|
+
name: x,
|
|
917
917
|
image: f.image,
|
|
918
918
|
size: 40
|
|
919
919
|
}
|
|
920
920
|
),
|
|
921
|
-
/* @__PURE__ */
|
|
922
|
-
/* @__PURE__ */ e("h4", { className: "text-sm font-medium text-charcoal truncate", children:
|
|
923
|
-
|
|
921
|
+
/* @__PURE__ */ d("div", { className: "flex-1 min-w-0", children: [
|
|
922
|
+
/* @__PURE__ */ e("h4", { className: "text-sm font-medium text-charcoal truncate", children: x }),
|
|
923
|
+
w && /* @__PURE__ */ e("p", { className: "text-xs text-stone truncate", children: w })
|
|
924
924
|
] })
|
|
925
925
|
] }),
|
|
926
|
-
/* @__PURE__ */ e("div", { className: "flex-shrink-0", children:
|
|
926
|
+
/* @__PURE__ */ e("div", { className: "flex-shrink-0", children: v === f.id ? /* @__PURE__ */ e(ee, { className: "h-5 w-5 text-primary animate-spin" }) : /* @__PURE__ */ e(ce, { className: "h-5 w-5 text-stone" }) })
|
|
927
927
|
] })
|
|
928
928
|
}
|
|
929
929
|
) }, f.id);
|
|
930
930
|
}),
|
|
931
|
-
m && /* @__PURE__ */ e("li", { className: "p-4 flex justify-center", children: /* @__PURE__ */
|
|
931
|
+
m && /* @__PURE__ */ e("li", { className: "p-4 flex justify-center", children: /* @__PURE__ */ d("div", { className: "flex items-center space-x-2", children: [
|
|
932
932
|
/* @__PURE__ */ e("div", { className: "w-4 h-4 animate-spin rounded-full border-2 border-primary border-t-transparent" }),
|
|
933
933
|
/* @__PURE__ */ e("span", { className: "text-sm text-stone", children: "Loading more..." })
|
|
934
934
|
] }) })
|
|
935
935
|
] }) })
|
|
936
936
|
] });
|
|
937
|
-
}, qe = ({ 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__ */
|
|
937
|
+
}, qe = ({ 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: [
|
|
938
938
|
/* @__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: "๐ฌ" }) }),
|
|
939
939
|
/* @__PURE__ */ e("h2", { className: "font-semibold text-charcoal", children: "Welcome to Messages" }),
|
|
940
|
-
/* @__PURE__ */ e("p", { className: "text-stone text-sm mb-6", children: t ? /* @__PURE__ */
|
|
940
|
+
/* @__PURE__ */ e("p", { className: "text-stone text-sm mb-6", children: t ? /* @__PURE__ */ d(oe, { children: [
|
|
941
941
|
"Choose a conversation from the list or",
|
|
942
942
|
" ",
|
|
943
|
-
s && /* @__PURE__ */
|
|
943
|
+
s && /* @__PURE__ */ d(de, { onClick: s, children: [
|
|
944
944
|
"start a new conversation with a ",
|
|
945
945
|
n.slice(0, -1),
|
|
946
946
|
"."
|
|
947
947
|
] })
|
|
948
|
-
] }) : s && /* @__PURE__ */
|
|
949
|
-
/* @__PURE__ */
|
|
948
|
+
] }) : s && /* @__PURE__ */ d(oe, { children: [
|
|
949
|
+
/* @__PURE__ */ d(de, { onClick: s, children: [
|
|
950
950
|
"Start a new conversation with one of your ",
|
|
951
951
|
n
|
|
952
952
|
] }),
|
|
@@ -964,7 +964,7 @@ const ze = ({
|
|
|
964
964
|
className: "inline-flex items-center gap-1 text-sm font-medium text-primary hover:text-primary-alt focus:outline-none focus:ring-2 focus:ring-primary",
|
|
965
965
|
children: s
|
|
966
966
|
}
|
|
967
|
-
), le = ({ message: t, onBack: s }) => /* @__PURE__ */ e("div", { className: "messaging-error-state flex items-center justify-center h-full p-8", children: /* @__PURE__ */
|
|
967
|
+
), le = ({ message: t, onBack: s }) => /* @__PURE__ */ e("div", { className: "messaging-error-state flex items-center justify-center h-full p-8", children: /* @__PURE__ */ d("div", { className: "text-center max-w-sm", children: [
|
|
968
968
|
/* @__PURE__ */ e("div", { className: "w-24 h-24 bg-danger-alt/20 rounded-full flex items-center justify-center mx-auto mb-6", children: /* @__PURE__ */ e("span", { className: "text-4xl", children: "โ ๏ธ" }) }),
|
|
969
969
|
/* @__PURE__ */ e("h2", { className: "font-semibold text-charcoal mb-2", children: "Oops!" }),
|
|
970
970
|
/* @__PURE__ */ e("p", { className: "text-stone text-sm mb-6", children: t }),
|
|
@@ -977,12 +977,12 @@ const ze = ({
|
|
|
977
977
|
children: "Go Back"
|
|
978
978
|
}
|
|
979
979
|
)
|
|
980
|
-
] }) }), Xe = ({ className: t, message: s }) => /* @__PURE__ */
|
|
980
|
+
] }) }), Xe = ({ className: t, message: s }) => /* @__PURE__ */ d(
|
|
981
981
|
"div",
|
|
982
982
|
{
|
|
983
983
|
className: D("flex items-center justify-center h-full", t),
|
|
984
984
|
children: [
|
|
985
|
-
/* @__PURE__ */
|
|
985
|
+
/* @__PURE__ */ d("svg", { viewBox: "0 0 100 100", className: "size-8 fill-pebble", stroke: "none", children: [
|
|
986
986
|
/* @__PURE__ */ e("circle", { cx: "6", cy: "50", r: "6", children: /* @__PURE__ */ e(
|
|
987
987
|
"animateTransform",
|
|
988
988
|
{
|
|
@@ -1020,7 +1020,7 @@ const ze = ({
|
|
|
1020
1020
|
s && /* @__PURE__ */ e("span", { className: "text-stone", children: s })
|
|
1021
1021
|
]
|
|
1022
1022
|
}
|
|
1023
|
-
), Qe = () => /* @__PURE__ */ e("div", { className: "messaging-loading-state flex items-center justify-center h-full", children: /* @__PURE__ */
|
|
1023
|
+
), Qe = () => /* @__PURE__ */ e("div", { className: "messaging-loading-state flex items-center justify-center h-full", children: /* @__PURE__ */ d("div", { className: "flex items-center", children: [
|
|
1024
1024
|
/* @__PURE__ */ e(Xe, { className: "w-6 h-6" }),
|
|
1025
1025
|
/* @__PURE__ */ e("span", { className: "text-sm text-stone", children: "Loading messages" })
|
|
1026
1026
|
] }) }), rs = ({
|
|
@@ -1028,34 +1028,34 @@ const ze = ({
|
|
|
1028
1028
|
className: s,
|
|
1029
1029
|
renderMessageInputActions: n,
|
|
1030
1030
|
onChannelSelect: l,
|
|
1031
|
-
onParticipantSelect:
|
|
1032
|
-
initialParticipantFilter:
|
|
1033
|
-
initialParticipantData:
|
|
1034
|
-
CustomChannelEmptyState:
|
|
1035
|
-
showChannelList:
|
|
1031
|
+
onParticipantSelect: i,
|
|
1032
|
+
initialParticipantFilter: c,
|
|
1033
|
+
initialParticipantData: a,
|
|
1034
|
+
CustomChannelEmptyState: o,
|
|
1035
|
+
showChannelList: r = !0
|
|
1036
1036
|
}) => {
|
|
1037
1037
|
const {
|
|
1038
|
-
service:
|
|
1038
|
+
service: b,
|
|
1039
1039
|
client: u,
|
|
1040
|
-
isConnected:
|
|
1040
|
+
isConnected: g,
|
|
1041
1041
|
isLoading: m,
|
|
1042
|
-
error:
|
|
1043
|
-
refreshConnection:
|
|
1042
|
+
error: I,
|
|
1043
|
+
refreshConnection: N,
|
|
1044
1044
|
debug: h
|
|
1045
|
-
} = Le(), [
|
|
1045
|
+
} = Le(), [v, S] = E(null), [O, y] = E(!1), [k, T] = E(!1), [f, x] = E(/* @__PURE__ */ new Set()), [w, M] = E(0), [p, L] = E(!1), [$, _] = E(null), V = H(null), {
|
|
1046
1046
|
showStartConversation: Q = !1,
|
|
1047
1047
|
participantSource: W,
|
|
1048
1048
|
participantLabel: z = "participants"
|
|
1049
1049
|
} = t, R = H(null), P = U(async () => {
|
|
1050
|
-
if (!u || !
|
|
1051
|
-
const
|
|
1052
|
-
if (
|
|
1050
|
+
if (!u || !g) return;
|
|
1051
|
+
const C = u.userID;
|
|
1052
|
+
if (C)
|
|
1053
1053
|
try {
|
|
1054
|
-
h && console.log("[MessagingShell] Syncing channels for user:",
|
|
1054
|
+
h && console.log("[MessagingShell] Syncing channels for user:", C);
|
|
1055
1055
|
const j = await u.queryChannels(
|
|
1056
1056
|
{
|
|
1057
1057
|
type: "messaging",
|
|
1058
|
-
members: { $in: [
|
|
1058
|
+
members: { $in: [C] }
|
|
1059
1059
|
},
|
|
1060
1060
|
{},
|
|
1061
1061
|
{ limit: 100 }
|
|
@@ -1065,34 +1065,34 @@ const ze = ({
|
|
|
1065
1065
|
Object.values(be).forEach((Ce) => {
|
|
1066
1066
|
var ae;
|
|
1067
1067
|
const re = (ae = Ce.user) == null ? void 0 : ae.id;
|
|
1068
|
-
re && re !==
|
|
1068
|
+
re && re !== C && F.add(re);
|
|
1069
1069
|
});
|
|
1070
|
-
}),
|
|
1070
|
+
}), x(F), y(j.length > 0), R.current = C, h && console.log("[MessagingShell] Channels synced successfully:", {
|
|
1071
1071
|
channelCount: j.length,
|
|
1072
1072
|
memberCount: F.size
|
|
1073
1073
|
});
|
|
1074
1074
|
} catch (j) {
|
|
1075
1075
|
console.error("[MessagingShell] Failed to sync channels:", j);
|
|
1076
1076
|
}
|
|
1077
|
-
}, [u,
|
|
1077
|
+
}, [u, g, h]);
|
|
1078
1078
|
G(() => {
|
|
1079
|
-
if (!u || !
|
|
1080
|
-
const
|
|
1081
|
-
|
|
1082
|
-
}, [u,
|
|
1083
|
-
if (!
|
|
1079
|
+
if (!u || !g) return;
|
|
1080
|
+
const C = u.userID;
|
|
1081
|
+
C && R.current !== C && P();
|
|
1082
|
+
}, [u, g, P]), G(() => {
|
|
1083
|
+
if (!c || !u || !g) return;
|
|
1084
1084
|
(async () => {
|
|
1085
1085
|
const j = u.userID;
|
|
1086
1086
|
if (j)
|
|
1087
1087
|
try {
|
|
1088
1088
|
h && console.log(
|
|
1089
1089
|
"[MessagingShell] Loading initial conversation with:",
|
|
1090
|
-
|
|
1090
|
+
c
|
|
1091
1091
|
);
|
|
1092
1092
|
const F = await u.queryChannels(
|
|
1093
1093
|
{
|
|
1094
1094
|
type: "messaging",
|
|
1095
|
-
members: { $eq: [j,
|
|
1095
|
+
members: { $eq: [j, c] }
|
|
1096
1096
|
},
|
|
1097
1097
|
{},
|
|
1098
1098
|
{ limit: 1 }
|
|
@@ -1102,17 +1102,17 @@ const ze = ({
|
|
|
1102
1102
|
"[MessagingShell] Initial conversation loaded:",
|
|
1103
1103
|
F[0].id
|
|
1104
1104
|
);
|
|
1105
|
-
else if (
|
|
1105
|
+
else if (a && b) {
|
|
1106
1106
|
h && console.log(
|
|
1107
1107
|
"[MessagingShell] No conversation found, creating one for:",
|
|
1108
|
-
|
|
1108
|
+
a
|
|
1109
1109
|
);
|
|
1110
1110
|
try {
|
|
1111
|
-
const B = await
|
|
1112
|
-
id:
|
|
1113
|
-
name:
|
|
1114
|
-
email:
|
|
1115
|
-
phone:
|
|
1111
|
+
const B = await b.startChannelWithParticipant({
|
|
1112
|
+
id: a.id,
|
|
1113
|
+
name: a.name,
|
|
1114
|
+
email: a.email,
|
|
1115
|
+
phone: a.phone
|
|
1116
1116
|
});
|
|
1117
1117
|
S(B), L(!0), _(null), l && l(B), h && console.log(
|
|
1118
1118
|
"[MessagingShell] Channel created and loaded:",
|
|
@@ -1129,7 +1129,7 @@ const ze = ({
|
|
|
1129
1129
|
"No conversation found with this account"
|
|
1130
1130
|
), h && console.log(
|
|
1131
1131
|
"[MessagingShell] No conversation found for:",
|
|
1132
|
-
|
|
1132
|
+
c
|
|
1133
1133
|
);
|
|
1134
1134
|
} catch (F) {
|
|
1135
1135
|
console.error(
|
|
@@ -1139,71 +1139,71 @@ const ze = ({
|
|
|
1139
1139
|
}
|
|
1140
1140
|
})();
|
|
1141
1141
|
}, [
|
|
1142
|
-
|
|
1143
|
-
|
|
1142
|
+
c,
|
|
1143
|
+
a,
|
|
1144
1144
|
u,
|
|
1145
|
-
|
|
1146
|
-
|
|
1145
|
+
g,
|
|
1146
|
+
b,
|
|
1147
1147
|
h,
|
|
1148
1148
|
l
|
|
1149
1149
|
]);
|
|
1150
1150
|
const A = U(
|
|
1151
|
-
(
|
|
1152
|
-
S(
|
|
1151
|
+
(C) => {
|
|
1152
|
+
S(C), l == null || l(C);
|
|
1153
1153
|
},
|
|
1154
1154
|
[l]
|
|
1155
1155
|
), q = U(() => {
|
|
1156
1156
|
p || S(null);
|
|
1157
1157
|
}, [p]), Z = U(() => {
|
|
1158
|
-
var
|
|
1159
|
-
W && (M((j) => j + 1), T(!0), (
|
|
1158
|
+
var C;
|
|
1159
|
+
W && (M((j) => j + 1), T(!0), (C = V.current) == null || C.showModal());
|
|
1160
1160
|
}, [W]), ge = U(
|
|
1161
|
-
async (
|
|
1161
|
+
async (C) => {
|
|
1162
1162
|
var j;
|
|
1163
|
-
if (
|
|
1163
|
+
if (b)
|
|
1164
1164
|
try {
|
|
1165
1165
|
h && console.log(
|
|
1166
1166
|
"[MessagingShell] Starting conversation with:",
|
|
1167
|
-
|
|
1167
|
+
C.id
|
|
1168
1168
|
);
|
|
1169
|
-
const F = await
|
|
1170
|
-
id:
|
|
1171
|
-
name:
|
|
1172
|
-
email:
|
|
1173
|
-
phone:
|
|
1169
|
+
const F = await b.startChannelWithParticipant({
|
|
1170
|
+
id: C.id,
|
|
1171
|
+
name: C.name,
|
|
1172
|
+
email: C.email,
|
|
1173
|
+
phone: C.phone
|
|
1174
1174
|
});
|
|
1175
1175
|
try {
|
|
1176
1176
|
await F.show();
|
|
1177
1177
|
} catch (B) {
|
|
1178
1178
|
console.warn("[MessagingShell] Failed to unhide channel:", B);
|
|
1179
1179
|
}
|
|
1180
|
-
S(F), T(!1), (j = V.current) == null || j.close(),
|
|
1180
|
+
S(F), T(!1), (j = V.current) == null || j.close(), i == null || i(C);
|
|
1181
1181
|
} catch (F) {
|
|
1182
1182
|
console.error("[MessagingShell] Failed to start conversation:", F);
|
|
1183
1183
|
}
|
|
1184
1184
|
},
|
|
1185
|
-
[
|
|
1185
|
+
[b, i, h]
|
|
1186
1186
|
), te = U(() => {
|
|
1187
|
-
var
|
|
1188
|
-
T(!1), (
|
|
1187
|
+
var C;
|
|
1188
|
+
T(!1), (C = V.current) == null || C.close();
|
|
1189
1189
|
}, []), xe = U(
|
|
1190
|
-
async (
|
|
1191
|
-
h && console.log("[MessagingShell] Leaving conversation:",
|
|
1190
|
+
async (C) => {
|
|
1191
|
+
h && console.log("[MessagingShell] Leaving conversation:", C.id), S(null), L(!1), R.current = null, await P();
|
|
1192
1192
|
},
|
|
1193
1193
|
[P, h]
|
|
1194
1194
|
), Ne = U(
|
|
1195
|
-
async (
|
|
1196
|
-
h && console.log("[MessagingShell] Blocking participant:",
|
|
1195
|
+
async (C) => {
|
|
1196
|
+
h && console.log("[MessagingShell] Blocking participant:", C), S(null), L(!1), R.current = null, await P();
|
|
1197
1197
|
},
|
|
1198
1198
|
[P, h]
|
|
1199
|
-
), J = !!
|
|
1200
|
-
return m ? /* @__PURE__ */ e("div", { className: D("h-full", s), children: /* @__PURE__ */ e(Qe, {}) }) :
|
|
1199
|
+
), J = !!v;
|
|
1200
|
+
return m ? /* @__PURE__ */ e("div", { className: D("h-full", s), children: /* @__PURE__ */ e(Qe, {}) }) : I ? /* @__PURE__ */ e("div", { className: D("h-full", s), children: /* @__PURE__ */ e(le, { message: I, onBack: N }) }) : !g || !u ? /* @__PURE__ */ e("div", { className: D("h-full", s), children: /* @__PURE__ */ e(
|
|
1201
1201
|
le,
|
|
1202
1202
|
{
|
|
1203
1203
|
message: "Not connected to messaging service",
|
|
1204
|
-
onBack:
|
|
1204
|
+
onBack: N
|
|
1205
1205
|
}
|
|
1206
|
-
) }) : $ ? /* @__PURE__ */ e("div", { className: D("h-full", s), children: /* @__PURE__ */ e(le, { message: $ }) }) : /* @__PURE__ */
|
|
1206
|
+
) }) : $ ? /* @__PURE__ */ e("div", { className: D("h-full", s), children: /* @__PURE__ */ e(le, { message: $ }) }) : /* @__PURE__ */ d(
|
|
1207
1207
|
"div",
|
|
1208
1208
|
{
|
|
1209
1209
|
className: D(
|
|
@@ -1211,7 +1211,7 @@ const ze = ({
|
|
|
1211
1211
|
s
|
|
1212
1212
|
),
|
|
1213
1213
|
children: [
|
|
1214
|
-
/* @__PURE__ */
|
|
1214
|
+
/* @__PURE__ */ d("div", { className: "flex h-full min-h-0", children: [
|
|
1215
1215
|
/* @__PURE__ */ e(
|
|
1216
1216
|
"div",
|
|
1217
1217
|
{
|
|
@@ -1219,18 +1219,18 @@ const ze = ({
|
|
|
1219
1219
|
"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",
|
|
1220
1220
|
{
|
|
1221
1221
|
// Explicitly hidden via prop or in direct conversation mode
|
|
1222
|
-
"!hidden":
|
|
1222
|
+
"!hidden": r === !1 || p,
|
|
1223
1223
|
// Normal mode: hide on mobile when channel selected, show on desktop
|
|
1224
|
-
"hidden lg:flex lg:w-80 lg:min-w-[280px] lg:max-w-[360px]":
|
|
1224
|
+
"hidden lg:flex lg:w-80 lg:min-w-[280px] lg:max-w-[360px]": r !== !1 && !p && J,
|
|
1225
1225
|
// Normal mode: show when no channel selected
|
|
1226
|
-
"flex flex-col w-full lg:flex-1 lg:max-w-2xl":
|
|
1226
|
+
"flex flex-col w-full lg:flex-1 lg:max-w-2xl": r !== !1 && !p && !J
|
|
1227
1227
|
}
|
|
1228
1228
|
),
|
|
1229
1229
|
children: /* @__PURE__ */ e(
|
|
1230
1230
|
Be,
|
|
1231
1231
|
{
|
|
1232
1232
|
onChannelSelect: A,
|
|
1233
|
-
selectedChannel:
|
|
1233
|
+
selectedChannel: v || void 0,
|
|
1234
1234
|
showStartConversation: Q && !!W,
|
|
1235
1235
|
onStartConversation: Z,
|
|
1236
1236
|
participantLabel: z
|
|
@@ -1250,18 +1250,18 @@ const ze = ({
|
|
|
1250
1250
|
"hidden lg:flex": !p && !J
|
|
1251
1251
|
}
|
|
1252
1252
|
),
|
|
1253
|
-
children:
|
|
1253
|
+
children: v ? /* @__PURE__ */ e("div", { className: "flex-1 min-h-0 flex flex-col", children: /* @__PURE__ */ e(
|
|
1254
1254
|
Ve,
|
|
1255
1255
|
{
|
|
1256
|
-
channel:
|
|
1256
|
+
channel: v,
|
|
1257
1257
|
onBack: q,
|
|
1258
1258
|
showBackButton: !p,
|
|
1259
1259
|
renderMessageInputActions: n,
|
|
1260
1260
|
onLeaveConversation: xe,
|
|
1261
1261
|
onBlockParticipant: Ne,
|
|
1262
|
-
CustomChannelEmptyState:
|
|
1262
|
+
CustomChannelEmptyState: o
|
|
1263
1263
|
},
|
|
1264
|
-
|
|
1264
|
+
v.id
|
|
1265
1265
|
) }) : /* @__PURE__ */ e(
|
|
1266
1266
|
qe,
|
|
1267
1267
|
{
|
|
@@ -1279,8 +1279,8 @@ const ze = ({
|
|
|
1279
1279
|
{
|
|
1280
1280
|
ref: V,
|
|
1281
1281
|
className: "mes-dialog",
|
|
1282
|
-
onClick: (
|
|
1283
|
-
|
|
1282
|
+
onClick: (C) => {
|
|
1283
|
+
C.target === V.current && te();
|
|
1284
1284
|
},
|
|
1285
1285
|
onClose: te,
|
|
1286
1286
|
children: /* @__PURE__ */ e("div", { className: "h-full w-full bg-white shadow-max-elevation-light", children: /* @__PURE__ */ e(
|
|
@@ -1293,7 +1293,7 @@ const ze = ({
|
|
|
1293
1293
|
participantLabel: z,
|
|
1294
1294
|
searchPlaceholder: `Search ${z}...`
|
|
1295
1295
|
},
|
|
1296
|
-
|
|
1296
|
+
w
|
|
1297
1297
|
) })
|
|
1298
1298
|
}
|
|
1299
1299
|
)
|
|
@@ -1327,74 +1327,74 @@ const ze = ({
|
|
|
1327
1327
|
onFaqClick: s,
|
|
1328
1328
|
loadingFaqId: n,
|
|
1329
1329
|
headerText: l,
|
|
1330
|
-
className:
|
|
1331
|
-
avatarImage:
|
|
1332
|
-
avatarName:
|
|
1330
|
+
className: i,
|
|
1331
|
+
avatarImage: c,
|
|
1332
|
+
avatarName: a
|
|
1333
1333
|
}) => {
|
|
1334
|
-
const
|
|
1335
|
-
return
|
|
1336
|
-
(
|
|
1334
|
+
const o = t.filter((r) => r.enabled).sort((r, b) => (r.order ?? 0) - (b.order ?? 0));
|
|
1335
|
+
return o.length === 0 ? null : /* @__PURE__ */ e("div", { className: D("px-4 py-6", i), children: /* @__PURE__ */ d("div", { className: "flex gap-3 items-end", children: [
|
|
1336
|
+
(c || a) && /* @__PURE__ */ e("div", { className: "flex-none", children: /* @__PURE__ */ e(
|
|
1337
1337
|
Y,
|
|
1338
1338
|
{
|
|
1339
|
-
id:
|
|
1340
|
-
name:
|
|
1341
|
-
image:
|
|
1339
|
+
id: a || "account",
|
|
1340
|
+
name: a || "Account",
|
|
1341
|
+
image: c,
|
|
1342
1342
|
size: 24
|
|
1343
1343
|
}
|
|
1344
1344
|
) }),
|
|
1345
|
-
/* @__PURE__ */
|
|
1345
|
+
/* @__PURE__ */ d(
|
|
1346
1346
|
"div",
|
|
1347
1347
|
{
|
|
1348
1348
|
className: "flex-1 rounded-lg p-4 space-y-3",
|
|
1349
1349
|
style: { backgroundColor: "#F1F0EE" },
|
|
1350
1350
|
children: [
|
|
1351
1351
|
l && /* @__PURE__ */ e("p", { className: "text-md text-charcoal mb-4", children: l }),
|
|
1352
|
-
|
|
1352
|
+
o.map((r) => /* @__PURE__ */ e(
|
|
1353
1353
|
Ze,
|
|
1354
1354
|
{
|
|
1355
|
-
question:
|
|
1356
|
-
onClick: () => s(
|
|
1357
|
-
loading: n ===
|
|
1355
|
+
question: r.question,
|
|
1356
|
+
onClick: () => s(r.id),
|
|
1357
|
+
loading: n === r.id
|
|
1358
1358
|
},
|
|
1359
|
-
|
|
1359
|
+
r.id
|
|
1360
1360
|
))
|
|
1361
1361
|
]
|
|
1362
1362
|
}
|
|
1363
1363
|
)
|
|
1364
1364
|
] }) });
|
|
1365
1365
|
}, os = (t, s = {}) => {
|
|
1366
|
-
const { initialSearch: n = "", pageSize: l = 20 } = s, [
|
|
1367
|
-
if (
|
|
1366
|
+
const { initialSearch: n = "", pageSize: l = 20 } = s, [i, c] = E([]), [a, o] = E(!1), [r, b] = E(null), [u, g] = E(n), [m, I] = E(!0), [N, h] = E(), v = U(async (k = !1, T) => {
|
|
1367
|
+
if (a) return;
|
|
1368
1368
|
const f = T !== void 0 ? T : u;
|
|
1369
|
-
|
|
1369
|
+
o(!0), b(null);
|
|
1370
1370
|
try {
|
|
1371
|
-
const
|
|
1371
|
+
const x = await t.loadParticipants({
|
|
1372
1372
|
search: f || void 0,
|
|
1373
1373
|
limit: l,
|
|
1374
|
-
cursor: k ? void 0 :
|
|
1374
|
+
cursor: k ? void 0 : N
|
|
1375
1375
|
});
|
|
1376
|
-
|
|
1377
|
-
(
|
|
1378
|
-
),
|
|
1379
|
-
} catch (
|
|
1380
|
-
const
|
|
1381
|
-
w
|
|
1376
|
+
c(
|
|
1377
|
+
(w) => k ? x.participants : [...w, ...x.participants]
|
|
1378
|
+
), I(x.hasMore), h(x.nextCursor);
|
|
1379
|
+
} catch (x) {
|
|
1380
|
+
const w = x instanceof Error ? x.message : "Failed to load participants";
|
|
1381
|
+
b(w), console.error("[useParticipants] Load error:", x);
|
|
1382
1382
|
} finally {
|
|
1383
|
-
|
|
1383
|
+
o(!1);
|
|
1384
1384
|
}
|
|
1385
|
-
}, [t, u,
|
|
1386
|
-
m && !
|
|
1387
|
-
}, [m,
|
|
1388
|
-
|
|
1389
|
-
}, [
|
|
1390
|
-
h(void 0),
|
|
1391
|
-
}, [
|
|
1385
|
+
}, [t, u, N, l, a]), S = U(() => {
|
|
1386
|
+
m && !a && v(!1);
|
|
1387
|
+
}, [m, a, v]), O = U((k) => {
|
|
1388
|
+
g(k), h(void 0), v(!0, k);
|
|
1389
|
+
}, [v]), y = U(() => {
|
|
1390
|
+
h(void 0), v(!0);
|
|
1391
|
+
}, [v]);
|
|
1392
1392
|
return G(() => {
|
|
1393
|
-
|
|
1393
|
+
v(!0);
|
|
1394
1394
|
}, [t.loadParticipants]), {
|
|
1395
|
-
participants:
|
|
1396
|
-
loading:
|
|
1397
|
-
error:
|
|
1395
|
+
participants: i,
|
|
1396
|
+
loading: a,
|
|
1397
|
+
error: r,
|
|
1398
1398
|
searchQuery: u,
|
|
1399
1399
|
hasMore: m,
|
|
1400
1400
|
totalCount: t.totalCount,
|