@linktr.ee/messaging-react 1.8.4 โ 1.8.6-rc-1764053798
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,9 +1,9 @@
|
|
|
1
|
-
import { jsx as e, jsxs as
|
|
1
|
+
import { jsx as e, jsxs as u, Fragment as le } from "react/jsx-runtime";
|
|
2
2
|
import D from "classnames";
|
|
3
|
-
import q, { createContext as Ie, useContext as Se, useCallback as P, useState as
|
|
3
|
+
import q, { createContext as Ie, useContext as Se, useCallback as P, useState as w, useRef as $, useEffect as G } from "react";
|
|
4
4
|
import { StreamChatService as Re } from "@linktr.ee/messaging-core";
|
|
5
5
|
import { Chat as ke, ChannelList as Te, Channel as De, useChannelStateContext as me, Window as Fe, MessageList as Me, MessageInput as Ue } from "stream-chat-react";
|
|
6
|
-
import { XIcon as he, ArrowLeftIcon as Pe, DotsThreeIcon as
|
|
6
|
+
import { XIcon as he, ArrowLeftIcon as Pe, DotsThreeIcon as pe, SpinnerGapIcon as ee, SignOutIcon as Oe, ProhibitInsetIcon as ie, FlagIcon as Le, MagnifyingGlassIcon as je, ChatCircleDotsIcon as ce } from "@phosphor-icons/react";
|
|
7
7
|
const fe = Ie({
|
|
8
8
|
service: null,
|
|
9
9
|
client: null,
|
|
@@ -21,29 +21,29 @@ const fe = Ie({
|
|
|
21
21
|
serviceConfig: n,
|
|
22
22
|
apiKey: r,
|
|
23
23
|
capabilities: a = {},
|
|
24
|
-
customization:
|
|
25
|
-
debug:
|
|
24
|
+
customization: d = {},
|
|
25
|
+
debug: c = !1
|
|
26
26
|
}) => {
|
|
27
27
|
const l = P(
|
|
28
|
-
(
|
|
29
|
-
|
|
28
|
+
(b, ...F) => {
|
|
29
|
+
c && console.log(`๐ฅ [MessagingProvider] ${b}`, ...F);
|
|
30
30
|
},
|
|
31
|
-
[
|
|
31
|
+
[c]
|
|
32
32
|
);
|
|
33
33
|
l("๐ RENDER START", {
|
|
34
34
|
userId: s == null ? void 0 : s.id,
|
|
35
35
|
apiKey: (r == null ? void 0 : r.substring(0, 8)) + "...",
|
|
36
36
|
serviceConfig: !!n,
|
|
37
37
|
capabilities: Object.keys(a),
|
|
38
|
-
customization: Object.keys(
|
|
38
|
+
customization: Object.keys(d)
|
|
39
39
|
});
|
|
40
|
-
const [o, E] =
|
|
40
|
+
const [o, E] = w(null), [v, m] = w(null), [g, R] = w(!1), [x, C] = w(!1), [h, k] = w(null), I = $(!1), y = $({
|
|
41
41
|
userId: s == null ? void 0 : s.id,
|
|
42
42
|
apiKey: r,
|
|
43
43
|
serviceConfig: n,
|
|
44
44
|
capabilities: a,
|
|
45
|
-
customization:
|
|
46
|
-
}), T =
|
|
45
|
+
customization: d
|
|
46
|
+
}), T = $(0);
|
|
47
47
|
T.current++, l("๐ RENDER INFO", {
|
|
48
48
|
renderCount: T.current,
|
|
49
49
|
currentProps: { userId: s == null ? void 0 : s.id, apiKey: (r == null ? void 0 : r.substring(0, 8)) + "..." },
|
|
@@ -52,18 +52,18 @@ const fe = Ie({
|
|
|
52
52
|
apiKeyChanged: y.current.apiKey !== r,
|
|
53
53
|
serviceConfigChanged: y.current.serviceConfig !== n,
|
|
54
54
|
capabilitiesChanged: y.current.capabilities !== a,
|
|
55
|
-
customizationChanged: y.current.customization !==
|
|
55
|
+
customizationChanged: y.current.customization !== d
|
|
56
56
|
}
|
|
57
57
|
}), y.current = {
|
|
58
58
|
userId: s == null ? void 0 : s.id,
|
|
59
59
|
apiKey: r,
|
|
60
60
|
serviceConfig: n,
|
|
61
61
|
capabilities: a,
|
|
62
|
-
customization:
|
|
63
|
-
},
|
|
64
|
-
const
|
|
62
|
+
customization: d
|
|
63
|
+
}, G(() => {
|
|
64
|
+
const b = T.current;
|
|
65
65
|
if (l("๐ง SERVICE INIT EFFECT TRIGGERED", {
|
|
66
|
-
renderCount:
|
|
66
|
+
renderCount: b,
|
|
67
67
|
apiKey: !!r,
|
|
68
68
|
serviceConfig: !!n,
|
|
69
69
|
dependencies: {
|
|
@@ -74,46 +74,46 @@ const fe = Ie({
|
|
|
74
74
|
}
|
|
75
75
|
}), !r || !n) {
|
|
76
76
|
l("โ ๏ธ SERVICE INIT SKIPPED", {
|
|
77
|
-
renderCount:
|
|
77
|
+
renderCount: b,
|
|
78
78
|
reason: "Missing apiKey or serviceConfig"
|
|
79
79
|
});
|
|
80
80
|
return;
|
|
81
81
|
}
|
|
82
82
|
l("๐ CREATING NEW SERVICE", {
|
|
83
|
-
renderCount:
|
|
83
|
+
renderCount: b,
|
|
84
84
|
apiKey: (r == null ? void 0 : r.substring(0, 8)) + "...",
|
|
85
85
|
serviceConfigChanged: y.current.serviceConfig !== n
|
|
86
86
|
});
|
|
87
87
|
const F = new Re({
|
|
88
88
|
...n,
|
|
89
89
|
apiKey: r,
|
|
90
|
-
debug:
|
|
90
|
+
debug: c
|
|
91
91
|
});
|
|
92
92
|
return E(F), l("โ
SERVICE SET", {
|
|
93
|
-
renderCount:
|
|
93
|
+
renderCount: b,
|
|
94
94
|
serviceInstance: !!F
|
|
95
95
|
}), () => {
|
|
96
96
|
l("๐งน SERVICE CLEANUP", {
|
|
97
|
-
renderCount:
|
|
97
|
+
renderCount: b,
|
|
98
98
|
reason: "Effect cleanup"
|
|
99
99
|
}), F.disconnectUser().catch(console.error);
|
|
100
100
|
};
|
|
101
|
-
}, [r, n,
|
|
102
|
-
const U =
|
|
103
|
-
|
|
101
|
+
}, [r, n, c, l]);
|
|
102
|
+
const U = $(null);
|
|
103
|
+
G(() => {
|
|
104
104
|
var F, z;
|
|
105
105
|
if (l("๐ USER CONNECTION EFFECT TRIGGERED", {
|
|
106
106
|
hasService: !!o,
|
|
107
107
|
hasUser: !!s,
|
|
108
108
|
userId: s == null ? void 0 : s.id,
|
|
109
|
-
isConnecting:
|
|
110
|
-
isConnected:
|
|
109
|
+
isConnecting: I.current,
|
|
110
|
+
isConnected: g,
|
|
111
111
|
dependencies: { service: !!o, userId: s == null ? void 0 : s.id }
|
|
112
112
|
}), !o || !s) {
|
|
113
113
|
l("โ ๏ธ USER CONNECTION SKIPPED", "Missing service or user");
|
|
114
114
|
return;
|
|
115
115
|
}
|
|
116
|
-
if (
|
|
116
|
+
if (I.current) {
|
|
117
117
|
l("โ ๏ธ USER CONNECTION SKIPPED", "Already connecting");
|
|
118
118
|
return;
|
|
119
119
|
}
|
|
@@ -125,11 +125,11 @@ const fe = Ie({
|
|
|
125
125
|
return;
|
|
126
126
|
}
|
|
127
127
|
(async () => {
|
|
128
|
-
l("๐ STARTING USER CONNECTION", { userId: s.id }),
|
|
128
|
+
l("๐ STARTING USER CONNECTION", { userId: s.id }), I.current = !0, C(!0), k(null);
|
|
129
129
|
try {
|
|
130
130
|
l("๐ CALLING SERVICE.CONNECTUSER", { userId: s.id });
|
|
131
131
|
const M = await o.connectUser(s);
|
|
132
|
-
|
|
132
|
+
m(M), R(!0), U.current = { serviceId: o, userId: s.id }, l("โ
USER CONNECTION SUCCESS", {
|
|
133
133
|
userId: s.id,
|
|
134
134
|
clientId: M.userID
|
|
135
135
|
});
|
|
@@ -140,25 +140,25 @@ const fe = Ie({
|
|
|
140
140
|
error: A
|
|
141
141
|
});
|
|
142
142
|
} finally {
|
|
143
|
-
|
|
143
|
+
C(!1), I.current = !1, l("๐ USER CONNECTION FINISHED", {
|
|
144
144
|
userId: s.id,
|
|
145
|
-
isConnected:
|
|
145
|
+
isConnected: g
|
|
146
146
|
});
|
|
147
147
|
}
|
|
148
148
|
})();
|
|
149
|
-
}, [o, s, l,
|
|
149
|
+
}, [o, s, l, g]), G(() => (l("๐ CLEANUP EFFECT REGISTERED", {
|
|
150
150
|
hasService: !!o,
|
|
151
|
-
isConnected:
|
|
151
|
+
isConnected: g
|
|
152
152
|
}), () => {
|
|
153
|
-
o &&
|
|
153
|
+
o && g ? (l(
|
|
154
154
|
"๐งน CLEANUP EFFECT TRIGGERED",
|
|
155
155
|
"Cleaning up connection on unmount"
|
|
156
156
|
), U.current = null, o.disconnectUser().catch(console.error)) : l("๐ CLEANUP EFFECT SKIPPED", {
|
|
157
157
|
hasService: !!o,
|
|
158
|
-
isConnected:
|
|
158
|
+
isConnected: g
|
|
159
159
|
});
|
|
160
|
-
}), [o,
|
|
161
|
-
const
|
|
160
|
+
}), [o, g, l]);
|
|
161
|
+
const i = P(async () => {
|
|
162
162
|
if (l("๐ REFRESH CONNECTION CALLED", {
|
|
163
163
|
hasService: !!o,
|
|
164
164
|
hasUser: !!s
|
|
@@ -166,63 +166,63 @@ const fe = Ie({
|
|
|
166
166
|
l("โ ๏ธ REFRESH CONNECTION SKIPPED", "Missing service or user");
|
|
167
167
|
return;
|
|
168
168
|
}
|
|
169
|
-
l("๐ STARTING CONNECTION REFRESH", { userId: s.id }),
|
|
169
|
+
l("๐ STARTING CONNECTION REFRESH", { userId: s.id }), C(!0);
|
|
170
170
|
try {
|
|
171
171
|
l("๐ DISCONNECTING FOR REFRESH"), await o.disconnectUser(), l("๐ RECONNECTING FOR REFRESH");
|
|
172
|
-
const
|
|
173
|
-
|
|
174
|
-
} catch (
|
|
175
|
-
const F =
|
|
172
|
+
const b = await o.connectUser(s);
|
|
173
|
+
m(b), R(!0), k(null), l("โ
CONNECTION REFRESH SUCCESS", { userId: s.id });
|
|
174
|
+
} catch (b) {
|
|
175
|
+
const F = b instanceof Error ? b.message : "Refresh failed";
|
|
176
176
|
k(F), l("โ CONNECTION REFRESH ERROR", {
|
|
177
177
|
userId: s.id,
|
|
178
178
|
error: F
|
|
179
179
|
});
|
|
180
180
|
} finally {
|
|
181
|
-
|
|
181
|
+
C(!1), l("๐ CONNECTION REFRESH FINISHED", { userId: s.id });
|
|
182
182
|
}
|
|
183
|
-
}, [o, s, l]),
|
|
183
|
+
}, [o, s, l]), f = q.useMemo(() => (l("๐ซ CONTEXT VALUE MEMOIZATION", {
|
|
184
184
|
hasService: !!o,
|
|
185
|
-
hasClient: !!
|
|
186
|
-
isConnected:
|
|
185
|
+
hasClient: !!v,
|
|
186
|
+
isConnected: g,
|
|
187
187
|
isLoading: x,
|
|
188
|
-
hasError: !!
|
|
188
|
+
hasError: !!h,
|
|
189
189
|
capabilitiesKeys: Object.keys(a),
|
|
190
|
-
customizationKeys: Object.keys(
|
|
190
|
+
customizationKeys: Object.keys(d)
|
|
191
191
|
}), {
|
|
192
192
|
service: o,
|
|
193
|
-
client:
|
|
194
|
-
isConnected:
|
|
193
|
+
client: v,
|
|
194
|
+
isConnected: g,
|
|
195
195
|
isLoading: x,
|
|
196
|
-
error:
|
|
196
|
+
error: h,
|
|
197
197
|
capabilities: a,
|
|
198
|
-
customization:
|
|
199
|
-
refreshConnection:
|
|
200
|
-
debug:
|
|
198
|
+
customization: d,
|
|
199
|
+
refreshConnection: i,
|
|
200
|
+
debug: c
|
|
201
201
|
}), [
|
|
202
202
|
o,
|
|
203
|
-
|
|
204
|
-
|
|
203
|
+
v,
|
|
204
|
+
g,
|
|
205
205
|
x,
|
|
206
|
-
m,
|
|
207
|
-
a,
|
|
208
|
-
c,
|
|
209
206
|
h,
|
|
207
|
+
a,
|
|
208
|
+
d,
|
|
210
209
|
i,
|
|
210
|
+
c,
|
|
211
211
|
l
|
|
212
212
|
]);
|
|
213
213
|
return l("๐ RENDER END", {
|
|
214
214
|
renderCount: T.current,
|
|
215
|
-
willRenderChat: !!(
|
|
216
|
-
contextValueReady: !!
|
|
217
|
-
}), /* @__PURE__ */ e(fe.Provider, { value:
|
|
218
|
-
},
|
|
215
|
+
willRenderChat: !!(v && g),
|
|
216
|
+
contextValueReady: !!f
|
|
217
|
+
}), /* @__PURE__ */ e(fe.Provider, { value: f, children: v && g ? /* @__PURE__ */ e(ke, { client: v, children: t }) : t });
|
|
218
|
+
}, _e = () => se(), Ae = (t, s) => {
|
|
219
219
|
const n = new Date(
|
|
220
220
|
Date.UTC(t.getUTCFullYear(), t.getUTCMonth(), t.getUTCDate())
|
|
221
221
|
), a = new Date(
|
|
222
222
|
Date.UTC(s.getUTCFullYear(), s.getUTCMonth(), s.getUTCDate())
|
|
223
223
|
).getTime() - n.getTime();
|
|
224
224
|
return Math.floor(a / (1e3 * 60 * 60 * 24));
|
|
225
|
-
},
|
|
225
|
+
}, Be = (t) => {
|
|
226
226
|
const s = /* @__PURE__ */ new Date();
|
|
227
227
|
if (Math.floor((s.getTime() - t.getTime()) / 1e3) < 60)
|
|
228
228
|
return "Just now";
|
|
@@ -263,7 +263,7 @@ const fe = Ie({
|
|
|
263
263
|
"๐"
|
|
264
264
|
// Melon
|
|
265
265
|
];
|
|
266
|
-
function
|
|
266
|
+
function $e(t) {
|
|
267
267
|
let s = 0;
|
|
268
268
|
for (let n = 0; n < t.length; n++) {
|
|
269
269
|
const r = t.charCodeAt(n);
|
|
@@ -271,8 +271,8 @@ function Ge(t) {
|
|
|
271
271
|
}
|
|
272
272
|
return Math.abs(s);
|
|
273
273
|
}
|
|
274
|
-
function
|
|
275
|
-
const n =
|
|
274
|
+
function Ge(t) {
|
|
275
|
+
const n = $e(t) % de.length;
|
|
276
276
|
return de[n];
|
|
277
277
|
}
|
|
278
278
|
const J = ({
|
|
@@ -281,7 +281,7 @@ const J = ({
|
|
|
281
281
|
size: n = 40,
|
|
282
282
|
className: r
|
|
283
283
|
}) => {
|
|
284
|
-
const a =
|
|
284
|
+
const a = Ge(t), c = n < 32 ? "text-xs" : n < 56 ? "text-sm" : "text-lg";
|
|
285
285
|
return /* @__PURE__ */ e(
|
|
286
286
|
"div",
|
|
287
287
|
{
|
|
@@ -306,69 +306,74 @@ const J = ({
|
|
|
306
306
|
"aria-hidden": "true",
|
|
307
307
|
className: D(
|
|
308
308
|
"avatar-fallback flex h-full w-full items-center justify-center font-semibold bg-[#E6E5E3] select-none transition-colors",
|
|
309
|
-
|
|
309
|
+
c
|
|
310
310
|
),
|
|
311
311
|
children: a
|
|
312
312
|
}
|
|
313
313
|
)
|
|
314
314
|
}
|
|
315
315
|
);
|
|
316
|
-
},
|
|
317
|
-
var
|
|
318
|
-
const
|
|
316
|
+
}, He = ({ channel: t, selectedChannel: s, onChannelSelect: n, debug: r = !1, unread: a }) => {
|
|
317
|
+
var h, k, I, y, T, U;
|
|
318
|
+
const d = (s == null ? void 0 : s.id) === (t == null ? void 0 : t.id), c = () => {
|
|
319
319
|
t && n(t);
|
|
320
|
-
}, o = Object.values(((
|
|
321
|
-
(
|
|
322
|
-
var
|
|
323
|
-
return ((
|
|
320
|
+
}, o = Object.values(((h = t == null ? void 0 : t.state) == null ? void 0 : h.members) || {}).find(
|
|
321
|
+
(i) => {
|
|
322
|
+
var f, b;
|
|
323
|
+
return ((f = i.user) == null ? void 0 : f.id) && i.user.id !== ((b = t == null ? void 0 : t._client) == null ? void 0 : b.userID);
|
|
324
324
|
}
|
|
325
|
-
), E = ((
|
|
325
|
+
), E = ((k = o == null ? void 0 : o.user) == null ? void 0 : k.name) || "Conversation", v = (I = o == null ? void 0 : o.user) == null ? void 0 : I.image, m = (T = (y = t == null ? void 0 : t.state) == null ? void 0 : y.messages) == null ? void 0 : T[t.state.messages.length - 1], R = (() => {
|
|
326
|
+
var f;
|
|
327
|
+
if (m != null && m.text) return m.text;
|
|
328
|
+
const i = (f = m == null ? void 0 : m.attachments) == null ? void 0 : f[0];
|
|
329
|
+
return i != null && i.asset_url ? i.asset_url : i != null && i.image_url ? i.image_url : i != null && i.og_scrape_url ? i.og_scrape_url : i != null && i.thumb_url ? i.thumb_url : "No messages yet";
|
|
330
|
+
})(), x = m != null && m.created_at ? Be(new Date(m.created_at)) : "", C = a ?? 0;
|
|
326
331
|
return r && console.log("๐บ [ChannelList] ๐ CHANNEL PREVIEW RENDER", {
|
|
327
332
|
channelId: t == null ? void 0 : t.id,
|
|
328
|
-
isSelected:
|
|
333
|
+
isSelected: d,
|
|
329
334
|
participantName: E,
|
|
330
|
-
unreadCount:
|
|
331
|
-
hasTimestamp: !!
|
|
335
|
+
unreadCount: C,
|
|
336
|
+
hasTimestamp: !!x
|
|
332
337
|
}), /* @__PURE__ */ e(
|
|
333
338
|
"button",
|
|
334
339
|
{
|
|
335
340
|
type: "button",
|
|
336
|
-
onClick:
|
|
341
|
+
onClick: c,
|
|
337
342
|
className: D(
|
|
338
343
|
"group w-full px-4 py-3 transition-colors border-b border-sand text-left max-w-full overflow-hidden focus-ring",
|
|
339
344
|
{
|
|
340
|
-
"bg-primary-alt/10 border-l-4 border-l-primary":
|
|
341
|
-
"hover:bg-sand": !
|
|
345
|
+
"bg-primary-alt/10 border-l-4 border-l-primary": d,
|
|
346
|
+
"hover:bg-sand": !d
|
|
342
347
|
}
|
|
343
348
|
),
|
|
344
|
-
children: /* @__PURE__ */
|
|
349
|
+
children: /* @__PURE__ */ u("div", { className: "flex items-start gap-3", children: [
|
|
345
350
|
/* @__PURE__ */ e(
|
|
346
351
|
J,
|
|
347
352
|
{
|
|
348
|
-
id: ((
|
|
353
|
+
id: ((U = o == null ? void 0 : o.user) == null ? void 0 : U.id) || t.id || "unknown",
|
|
349
354
|
name: E,
|
|
350
|
-
image:
|
|
355
|
+
image: v,
|
|
351
356
|
size: 44,
|
|
352
357
|
className: "[&_.avatar-fallback]:group-hover:bg-[#eeeeee]"
|
|
353
358
|
}
|
|
354
359
|
),
|
|
355
|
-
/* @__PURE__ */
|
|
356
|
-
/* @__PURE__ */
|
|
360
|
+
/* @__PURE__ */ u("div", { className: "flex-1 min-w-0 flex flex-col gap-1", children: [
|
|
361
|
+
/* @__PURE__ */ u("div", { className: "flex items-center justify-between gap-2", children: [
|
|
357
362
|
/* @__PURE__ */ e(
|
|
358
363
|
"h3",
|
|
359
364
|
{
|
|
360
365
|
className: D(
|
|
361
366
|
"text-sm font-medium truncate",
|
|
362
|
-
|
|
367
|
+
d ? "text-primary" : "text-charcoal"
|
|
363
368
|
),
|
|
364
369
|
children: E
|
|
365
370
|
}
|
|
366
371
|
),
|
|
367
|
-
|
|
372
|
+
x && /* @__PURE__ */ e("span", { className: "text-xs text-stone flex-shrink-0", children: x })
|
|
368
373
|
] }),
|
|
369
|
-
/* @__PURE__ */
|
|
370
|
-
/* @__PURE__ */ e("p", { className: "text-xs text-stone mr-2 flex-1 line-clamp-2", children:
|
|
371
|
-
|
|
374
|
+
/* @__PURE__ */ u("div", { className: "flex items-center justify-between gap-2 min-w-0", children: [
|
|
375
|
+
/* @__PURE__ */ e("p", { className: "text-xs text-stone mr-2 flex-1 line-clamp-2", children: R }),
|
|
376
|
+
C > 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: C > 99 ? "99+" : C })
|
|
372
377
|
] })
|
|
373
378
|
] })
|
|
374
379
|
] })
|
|
@@ -382,8 +387,8 @@ const J = ({
|
|
|
382
387
|
}) => {
|
|
383
388
|
const a = q.useRef(0);
|
|
384
389
|
a.current++;
|
|
385
|
-
const { debug:
|
|
386
|
-
return
|
|
390
|
+
const { debug: d = !1 } = se();
|
|
391
|
+
return d && console.log("๐บ [ChannelList] ๐ RENDER START", {
|
|
387
392
|
renderCount: a.current,
|
|
388
393
|
selectedChannelId: s == null ? void 0 : s.id,
|
|
389
394
|
filters: n
|
|
@@ -394,7 +399,7 @@ const J = ({
|
|
|
394
399
|
"messaging-channel-list h-full flex flex-col min-w-0 overflow-hidden",
|
|
395
400
|
r
|
|
396
401
|
),
|
|
397
|
-
children: /* @__PURE__ */ e("div", { className: "flex-1 overflow-hidden min-w-0", children: (
|
|
402
|
+
children: /* @__PURE__ */ e("div", { className: "flex-1 overflow-hidden min-w-0", children: (d && console.log("๐บ [ChannelList] ๐ฌ RENDERING STREAM CHANNEL LIST", {
|
|
398
403
|
renderCount: a.current,
|
|
399
404
|
filters: n
|
|
400
405
|
}), /* @__PURE__ */ e(
|
|
@@ -403,19 +408,19 @@ const J = ({
|
|
|
403
408
|
filters: n,
|
|
404
409
|
sort: { last_message_at: -1 },
|
|
405
410
|
options: { limit: 30 },
|
|
406
|
-
Preview: (
|
|
411
|
+
Preview: (c) => {
|
|
407
412
|
var l, o;
|
|
408
|
-
return
|
|
409
|
-
channelId: (l =
|
|
413
|
+
return d && console.log("๐บ [ChannelList] ๐ CHANNEL PREVIEW RENDER", {
|
|
414
|
+
channelId: (l = c.channel) == null ? void 0 : l.id,
|
|
410
415
|
selectedChannelId: s == null ? void 0 : s.id,
|
|
411
|
-
isSelected: (s == null ? void 0 : s.id) === ((o =
|
|
416
|
+
isSelected: (s == null ? void 0 : s.id) === ((o = c.channel) == null ? void 0 : o.id)
|
|
412
417
|
}), /* @__PURE__ */ e(
|
|
413
|
-
|
|
418
|
+
He,
|
|
414
419
|
{
|
|
415
|
-
...
|
|
420
|
+
...c,
|
|
416
421
|
selectedChannel: s,
|
|
417
422
|
onChannelSelect: t,
|
|
418
|
-
debug:
|
|
423
|
+
debug: d
|
|
419
424
|
}
|
|
420
425
|
);
|
|
421
426
|
}
|
|
@@ -443,7 +448,7 @@ const J = ({
|
|
|
443
448
|
}
|
|
444
449
|
);
|
|
445
450
|
function oe({ label: t, className: s, children: n, ...r }) {
|
|
446
|
-
return /* @__PURE__ */
|
|
451
|
+
return /* @__PURE__ */ u(
|
|
447
452
|
"button",
|
|
448
453
|
{
|
|
449
454
|
type: "button",
|
|
@@ -466,22 +471,22 @@ function oe({ label: t, className: s, children: n, ...r }) {
|
|
|
466
471
|
function ge({ onClick: t }) {
|
|
467
472
|
return /* @__PURE__ */ e(oe, { label: "Close", onClick: t, className: "p-1", children: /* @__PURE__ */ e(he, { className: "h-5 w-5 text-stone", weight: "bold" }) });
|
|
468
473
|
}
|
|
469
|
-
const xe = () => /* @__PURE__ */ e("div", { className: "messaging-channel-empty-state flex items-center justify-center h-full p-8 text-balance", children: /* @__PURE__ */
|
|
474
|
+
const xe = () => /* @__PURE__ */ e("div", { className: "messaging-channel-empty-state flex items-center justify-center h-full p-8 text-balance", children: /* @__PURE__ */ u("div", { className: "text-center max-w-sm", children: [
|
|
470
475
|
/* @__PURE__ */ e("h2", { className: "font-semibold text-charcoal mb-2", children: "No messages yet ๐" }),
|
|
471
476
|
/* @__PURE__ */ e("p", { className: "text-stone text-xs", children: "Share to social media to generate more conversations" })
|
|
472
|
-
] }) }), We = ({ renderActions: t }) => /* @__PURE__ */
|
|
477
|
+
] }) }), We = ({ renderActions: t }) => /* @__PURE__ */ u("div", { className: "message-input flex items-center gap-2 p-4", children: [
|
|
473
478
|
t && t(),
|
|
474
479
|
/* @__PURE__ */ e("div", { className: "flex-1", children: /* @__PURE__ */ e(Ue, { focus: !0, maxRows: 4 }) })
|
|
475
480
|
] }), ze = ({ onBack: t, showBackButton: s, onShowInfo: n, canShowInfo: r }) => {
|
|
476
|
-
var o, E,
|
|
477
|
-
const { channel: a } = me(),
|
|
478
|
-
(
|
|
481
|
+
var o, E, v, m;
|
|
482
|
+
const { channel: a } = me(), d = q.useMemo(() => Object.values(a.state.members || {}).find(
|
|
483
|
+
(R) => {
|
|
479
484
|
var x;
|
|
480
|
-
return ((x =
|
|
485
|
+
return ((x = R.user) == null ? void 0 : x.id) && R.user.id !== a._client.userID;
|
|
481
486
|
}
|
|
482
|
-
), [a._client.userID, a.state.members]),
|
|
483
|
-
return /* @__PURE__ */
|
|
484
|
-
/* @__PURE__ */
|
|
487
|
+
), [a._client.userID, a.state.members]), c = ((o = d == null ? void 0 : d.user) == null ? void 0 : o.name) || ((E = d == null ? void 0 : d.user) == null ? void 0 : E.id) || "Unknown member", l = (v = d == null ? void 0 : d.user) == null ? void 0 : v.image;
|
|
488
|
+
return /* @__PURE__ */ u("div", { className: "flex items-center justify-between gap-3 min-h-12", children: [
|
|
489
|
+
/* @__PURE__ */ u("div", { className: "flex items-center gap-3 min-w-0", children: [
|
|
485
490
|
s && t && /* @__PURE__ */ e(
|
|
486
491
|
"button",
|
|
487
492
|
{
|
|
@@ -495,15 +500,15 @@ const xe = () => /* @__PURE__ */ e("div", { className: "messaging-channel-empty-
|
|
|
495
500
|
/* @__PURE__ */ e(
|
|
496
501
|
J,
|
|
497
502
|
{
|
|
498
|
-
id: ((
|
|
499
|
-
name:
|
|
503
|
+
id: ((m = d == null ? void 0 : d.user) == null ? void 0 : m.id) || a.id || "unknown",
|
|
504
|
+
name: c,
|
|
500
505
|
image: l,
|
|
501
506
|
size: 40
|
|
502
507
|
}
|
|
503
508
|
),
|
|
504
|
-
/* @__PURE__ */ e("div", { className: "min-w-0", children: /* @__PURE__ */ e("h1", { className: "text-lg font-semibold text-charcoal truncate", children:
|
|
509
|
+
/* @__PURE__ */ e("div", { className: "min-w-0", children: /* @__PURE__ */ e("h1", { className: "text-lg font-semibold text-charcoal truncate", children: c }) })
|
|
505
510
|
] }),
|
|
506
|
-
r && n && /* @__PURE__ */ e(oe, { label: "Chat info", onClick: n, children: /* @__PURE__ */ e(
|
|
511
|
+
r && n && /* @__PURE__ */ e(oe, { label: "Chat info", onClick: n, children: /* @__PURE__ */ e(pe, { className: "h-6 w-6 text-charcoal", weight: "bold" }) })
|
|
507
512
|
] });
|
|
508
513
|
}, qe = ({
|
|
509
514
|
isOpen: t,
|
|
@@ -511,71 +516,71 @@ const xe = () => /* @__PURE__ */ e("div", { className: "messaging-channel-empty-
|
|
|
511
516
|
participant: n,
|
|
512
517
|
channel: r,
|
|
513
518
|
followerStatusLabel: a,
|
|
514
|
-
onLeaveConversation:
|
|
515
|
-
onBlockParticipant:
|
|
519
|
+
onLeaveConversation: d,
|
|
520
|
+
onBlockParticipant: c
|
|
516
521
|
}) => {
|
|
517
|
-
var M, A, Y,
|
|
518
|
-
const { service: l, debug: o } = se(), E =
|
|
519
|
-
|
|
520
|
-
const
|
|
521
|
-
|
|
522
|
+
var M, A, Y, H, V, Q, W;
|
|
523
|
+
const { service: l, debug: o } = se(), E = $(null), [v, m] = w(!1), [g, R] = w(!1), [x, C] = w(!1);
|
|
524
|
+
G(() => {
|
|
525
|
+
const S = E.current;
|
|
526
|
+
S && (t ? S.showModal() : S.close());
|
|
522
527
|
}, [t]);
|
|
523
|
-
const
|
|
524
|
-
var
|
|
525
|
-
if (!(!l || !((
|
|
528
|
+
const h = P(async () => {
|
|
529
|
+
var S;
|
|
530
|
+
if (!(!l || !((S = n == null ? void 0 : n.user) != null && S.id)))
|
|
526
531
|
try {
|
|
527
532
|
const j = (await l.getBlockedUsers()).some(
|
|
528
|
-
(
|
|
533
|
+
(_) => {
|
|
529
534
|
var X;
|
|
530
|
-
return
|
|
535
|
+
return _.blocked_user_id === ((X = n == null ? void 0 : n.user) == null ? void 0 : X.id);
|
|
531
536
|
}
|
|
532
537
|
);
|
|
533
|
-
|
|
534
|
-
} catch (
|
|
538
|
+
m(j);
|
|
539
|
+
} catch (O) {
|
|
535
540
|
console.error(
|
|
536
541
|
"[ChannelInfoDialog] Failed to check blocked status:",
|
|
537
|
-
|
|
542
|
+
O
|
|
538
543
|
);
|
|
539
544
|
}
|
|
540
545
|
}, [l, (M = n == null ? void 0 : n.user) == null ? void 0 : M.id]);
|
|
541
|
-
|
|
542
|
-
t &&
|
|
543
|
-
}, [t,
|
|
546
|
+
G(() => {
|
|
547
|
+
t && h();
|
|
548
|
+
}, [t, h]);
|
|
544
549
|
const k = async () => {
|
|
545
|
-
var
|
|
546
|
-
if (!
|
|
547
|
-
o && console.log("[ChannelInfoDialog] Leave conversation", r.cid),
|
|
550
|
+
var S;
|
|
551
|
+
if (!g) {
|
|
552
|
+
o && console.log("[ChannelInfoDialog] Leave conversation", r.cid), R(!0);
|
|
548
553
|
try {
|
|
549
|
-
const
|
|
550
|
-
await r.hide(
|
|
551
|
-
} catch (
|
|
552
|
-
console.error("[ChannelInfoDialog] Failed to leave conversation",
|
|
554
|
+
const O = ((S = r._client) == null ? void 0 : S.userID) ?? null;
|
|
555
|
+
await r.hide(O, !1), d && await d(r), s();
|
|
556
|
+
} catch (O) {
|
|
557
|
+
console.error("[ChannelInfoDialog] Failed to leave conversation", O);
|
|
553
558
|
} finally {
|
|
554
|
-
|
|
559
|
+
R(!1);
|
|
555
560
|
}
|
|
556
561
|
}
|
|
557
|
-
},
|
|
558
|
-
var
|
|
562
|
+
}, I = async () => {
|
|
563
|
+
var S, O, j;
|
|
559
564
|
if (!(x || !l)) {
|
|
560
|
-
o && console.log("[ChannelInfoDialog] Block member", (
|
|
565
|
+
o && console.log("[ChannelInfoDialog] Block member", (S = n == null ? void 0 : n.user) == null ? void 0 : S.id), C(!0);
|
|
561
566
|
try {
|
|
562
|
-
await l.blockUser((
|
|
563
|
-
} catch (
|
|
564
|
-
console.error("[ChannelInfoDialog] Failed to block member",
|
|
567
|
+
await l.blockUser((O = n == null ? void 0 : n.user) == null ? void 0 : O.id), c && await c((j = n == null ? void 0 : n.user) == null ? void 0 : j.id), s();
|
|
568
|
+
} catch (_) {
|
|
569
|
+
console.error("[ChannelInfoDialog] Failed to block member", _);
|
|
565
570
|
} finally {
|
|
566
|
-
|
|
571
|
+
C(!1);
|
|
567
572
|
}
|
|
568
573
|
}
|
|
569
574
|
}, y = async () => {
|
|
570
|
-
var
|
|
575
|
+
var S, O, j;
|
|
571
576
|
if (!(x || !l)) {
|
|
572
|
-
o && console.log("[ChannelInfoDialog] Unblock member", (
|
|
577
|
+
o && console.log("[ChannelInfoDialog] Unblock member", (S = n == null ? void 0 : n.user) == null ? void 0 : S.id), C(!0);
|
|
573
578
|
try {
|
|
574
|
-
await l.unBlockUser((
|
|
575
|
-
} catch (
|
|
576
|
-
console.error("[ChannelInfoDialog] Failed to unblock member",
|
|
579
|
+
await l.unBlockUser((O = n == null ? void 0 : n.user) == null ? void 0 : O.id), c && await c((j = n == null ? void 0 : n.user) == null ? void 0 : j.id), s();
|
|
580
|
+
} catch (_) {
|
|
581
|
+
console.error("[ChannelInfoDialog] Failed to unblock member", _);
|
|
577
582
|
} finally {
|
|
578
|
-
|
|
583
|
+
C(!1);
|
|
579
584
|
}
|
|
580
585
|
}
|
|
581
586
|
}, T = () => {
|
|
@@ -586,7 +591,7 @@ const xe = () => /* @__PURE__ */ e("div", { className: "messaging-channel-empty-
|
|
|
586
591
|
);
|
|
587
592
|
};
|
|
588
593
|
if (!n) return null;
|
|
589
|
-
const U = ((A = n.user) == null ? void 0 : A.name) || ((Y = n.user) == null ? void 0 : Y.id) || "Unknown member",
|
|
594
|
+
const U = ((A = n.user) == null ? void 0 : A.name) || ((Y = n.user) == null ? void 0 : Y.id) || "Unknown member", i = (H = n.user) == null ? void 0 : H.image, f = (V = n.user) == null ? void 0 : V.email, b = (Q = n.user) == null ? void 0 : Q.username, F = f || (b ? `linktr.ee/${b}` : void 0), z = ((W = n.user) == null ? void 0 : W.id) || "unknown";
|
|
590
595
|
return (
|
|
591
596
|
// eslint-disable-next-line jsx-a11y/click-events-have-key-events, jsx-a11y/no-noninteractive-element-interactions
|
|
592
597
|
/* @__PURE__ */ e(
|
|
@@ -595,32 +600,32 @@ const xe = () => /* @__PURE__ */ e("div", { className: "messaging-channel-empty-
|
|
|
595
600
|
ref: E,
|
|
596
601
|
className: "mes-dialog",
|
|
597
602
|
onClose: s,
|
|
598
|
-
onClick: (
|
|
599
|
-
|
|
603
|
+
onClick: (S) => {
|
|
604
|
+
S.target === E.current && s();
|
|
600
605
|
},
|
|
601
|
-
children: /* @__PURE__ */
|
|
602
|
-
/* @__PURE__ */
|
|
606
|
+
children: /* @__PURE__ */ u("div", { className: "ml-auto flex h-full w-full flex-col bg-white shadow-max-elevation-light", children: [
|
|
607
|
+
/* @__PURE__ */ u("div", { className: "flex items-center justify-between border-b border-sand px-4 py-3", children: [
|
|
603
608
|
/* @__PURE__ */ e("h2", { className: "text-base font-semibold text-charcoal", children: "Chat info" }),
|
|
604
609
|
/* @__PURE__ */ e(ge, { onClick: s })
|
|
605
610
|
] }),
|
|
606
|
-
/* @__PURE__ */
|
|
611
|
+
/* @__PURE__ */ u("div", { className: "flex-1 px-2 overflow-y-auto w-full", children: [
|
|
607
612
|
/* @__PURE__ */ e(
|
|
608
613
|
"div",
|
|
609
614
|
{
|
|
610
615
|
className: "flex flex-col items-center gap-3 self-stretch px-4 py-2 mt-6 rounded-lg border border-black/[0.04]",
|
|
611
616
|
style: { backgroundColor: "#FBFAF9" },
|
|
612
|
-
children: /* @__PURE__ */
|
|
617
|
+
children: /* @__PURE__ */ u("div", { className: "flex items-center gap-3 w-full", children: [
|
|
613
618
|
/* @__PURE__ */ e(
|
|
614
619
|
J,
|
|
615
620
|
{
|
|
616
621
|
id: z,
|
|
617
622
|
name: U,
|
|
618
|
-
image:
|
|
623
|
+
image: i,
|
|
619
624
|
size: 88,
|
|
620
625
|
className: "!rounded-full"
|
|
621
626
|
}
|
|
622
627
|
),
|
|
623
|
-
/* @__PURE__ */
|
|
628
|
+
/* @__PURE__ */ u("div", { className: "flex flex-col min-w-0 flex-1", children: [
|
|
624
629
|
/* @__PURE__ */ e("p", { className: "truncate text-base font-semibold text-charcoal", children: U }),
|
|
625
630
|
F && /* @__PURE__ */ e("p", { className: "truncate text-sm text-[#00000055]", children: F }),
|
|
626
631
|
a && /* @__PURE__ */ e(
|
|
@@ -641,20 +646,20 @@ const xe = () => /* @__PURE__ */ e("div", { className: "messaging-channel-empty-
|
|
|
641
646
|
] })
|
|
642
647
|
}
|
|
643
648
|
),
|
|
644
|
-
/* @__PURE__ */
|
|
645
|
-
/* @__PURE__ */ e("li", { children: /* @__PURE__ */
|
|
649
|
+
/* @__PURE__ */ u("ul", { className: "flex flex-col gap-2 mt-2", children: [
|
|
650
|
+
/* @__PURE__ */ e("li", { children: /* @__PURE__ */ u(
|
|
646
651
|
K,
|
|
647
652
|
{
|
|
648
653
|
onClick: k,
|
|
649
|
-
disabled:
|
|
650
|
-
"aria-busy":
|
|
654
|
+
disabled: g,
|
|
655
|
+
"aria-busy": g,
|
|
651
656
|
children: [
|
|
652
|
-
|
|
657
|
+
g ? /* @__PURE__ */ e(ee, { className: "h-5 w-5 animate-spin" }) : /* @__PURE__ */ e(Oe, { className: "h-5 w-5" }),
|
|
653
658
|
/* @__PURE__ */ e("span", { children: "Delete Conversation" })
|
|
654
659
|
]
|
|
655
660
|
}
|
|
656
661
|
) }),
|
|
657
|
-
/* @__PURE__ */ e("li", { children:
|
|
662
|
+
/* @__PURE__ */ e("li", { children: v ? /* @__PURE__ */ u(
|
|
658
663
|
K,
|
|
659
664
|
{
|
|
660
665
|
onClick: y,
|
|
@@ -665,10 +670,10 @@ const xe = () => /* @__PURE__ */ e("div", { className: "messaging-channel-empty-
|
|
|
665
670
|
/* @__PURE__ */ e("span", { children: "Unblock" })
|
|
666
671
|
]
|
|
667
672
|
}
|
|
668
|
-
) : /* @__PURE__ */
|
|
673
|
+
) : /* @__PURE__ */ u(
|
|
669
674
|
K,
|
|
670
675
|
{
|
|
671
|
-
onClick:
|
|
676
|
+
onClick: I,
|
|
672
677
|
disabled: x,
|
|
673
678
|
"aria-busy": x,
|
|
674
679
|
children: [
|
|
@@ -677,7 +682,7 @@ const xe = () => /* @__PURE__ */ e("div", { className: "messaging-channel-empty-
|
|
|
677
682
|
]
|
|
678
683
|
}
|
|
679
684
|
) }),
|
|
680
|
-
/* @__PURE__ */ e("li", { children: /* @__PURE__ */
|
|
685
|
+
/* @__PURE__ */ e("li", { children: /* @__PURE__ */ u(K, { variant: "danger", onClick: T, children: [
|
|
681
686
|
/* @__PURE__ */ e(Le, { className: "h-5 w-5" }),
|
|
682
687
|
/* @__PURE__ */ e("span", { children: "Report" })
|
|
683
688
|
] }) })
|
|
@@ -693,40 +698,47 @@ const xe = () => /* @__PURE__ */ e("div", { className: "messaging-channel-empty-
|
|
|
693
698
|
renderMessageInputActions: n,
|
|
694
699
|
onLeaveConversation: r,
|
|
695
700
|
onBlockParticipant: a,
|
|
696
|
-
CustomChannelEmptyState:
|
|
701
|
+
CustomChannelEmptyState: d = xe
|
|
697
702
|
}) => {
|
|
698
|
-
var
|
|
699
|
-
const { channel:
|
|
700
|
-
(
|
|
701
|
-
var
|
|
702
|
-
return ((
|
|
703
|
+
var g, R;
|
|
704
|
+
const { channel: c } = me(), [l, o] = w(!1), E = (((R = (g = c == null ? void 0 : c.state) == null ? void 0 : g.messages) == null ? void 0 : R.length) ?? 0) > 0, v = q.useMemo(() => Object.values(c.state.members || {}).find(
|
|
705
|
+
(C) => {
|
|
706
|
+
var h;
|
|
707
|
+
return ((h = C.user) == null ? void 0 : h.id) && C.user.id !== c._client.userID;
|
|
703
708
|
}
|
|
704
|
-
), [
|
|
705
|
-
const x =
|
|
709
|
+
), [c._client.userID, c.state.members]), m = q.useMemo(() => {
|
|
710
|
+
const x = c.data ?? {};
|
|
706
711
|
if (x.followerStatus)
|
|
707
712
|
return String(x.followerStatus);
|
|
708
713
|
if (x.isFollower !== void 0)
|
|
709
714
|
return x.isFollower ? "Subscribed to you" : "Not subscribed";
|
|
710
|
-
}, [
|
|
711
|
-
return /* @__PURE__ */
|
|
712
|
-
/* @__PURE__ */
|
|
715
|
+
}, [c.data]);
|
|
716
|
+
return /* @__PURE__ */ u(le, { children: [
|
|
717
|
+
/* @__PURE__ */ u(Fe, { children: [
|
|
713
718
|
/* @__PURE__ */ e("div", { className: "border-b border-sand bg-white px-4 py-3", children: /* @__PURE__ */ e(
|
|
714
719
|
ze,
|
|
715
720
|
{
|
|
716
721
|
onBack: t,
|
|
717
722
|
showBackButton: s,
|
|
718
723
|
onShowInfo: () => o(!0),
|
|
719
|
-
canShowInfo: !!
|
|
724
|
+
canShowInfo: !!v
|
|
720
725
|
}
|
|
721
726
|
) }),
|
|
722
|
-
/* @__PURE__ */
|
|
723
|
-
/* @__PURE__ */ e(
|
|
724
|
-
|
|
727
|
+
/* @__PURE__ */ u("div", { className: "flex-1 overflow-hidden relative", children: [
|
|
728
|
+
/* @__PURE__ */ e(
|
|
729
|
+
Me,
|
|
730
|
+
{
|
|
731
|
+
hideDeletedMessages: !0,
|
|
732
|
+
hideNewMessageSeparator: !1,
|
|
733
|
+
messageActions: []
|
|
734
|
+
}
|
|
735
|
+
),
|
|
736
|
+
!E && d && /* @__PURE__ */ e("div", { className: "absolute inset-0 w-full h-full bg-white", children: /* @__PURE__ */ e(d, {}) })
|
|
725
737
|
] }),
|
|
726
738
|
/* @__PURE__ */ e(
|
|
727
739
|
We,
|
|
728
740
|
{
|
|
729
|
-
renderActions: () => n == null ? void 0 : n(
|
|
741
|
+
renderActions: () => n == null ? void 0 : n(c)
|
|
730
742
|
}
|
|
731
743
|
)
|
|
732
744
|
] }),
|
|
@@ -735,9 +747,9 @@ const xe = () => /* @__PURE__ */ e("div", { className: "messaging-channel-empty-
|
|
|
735
747
|
{
|
|
736
748
|
isOpen: l,
|
|
737
749
|
onClose: () => o(!1),
|
|
738
|
-
participant:
|
|
739
|
-
channel:
|
|
740
|
-
followerStatusLabel:
|
|
750
|
+
participant: v,
|
|
751
|
+
channel: c,
|
|
752
|
+
followerStatusLabel: m,
|
|
741
753
|
onLeaveConversation: r,
|
|
742
754
|
onBlockParticipant: a
|
|
743
755
|
}
|
|
@@ -749,15 +761,15 @@ const xe = () => /* @__PURE__ */ e("div", { className: "messaging-channel-empty-
|
|
|
749
761
|
showBackButton: n = !1,
|
|
750
762
|
renderMessageInputActions: r,
|
|
751
763
|
onLeaveConversation: a,
|
|
752
|
-
onBlockParticipant:
|
|
753
|
-
className:
|
|
764
|
+
onBlockParticipant: d,
|
|
765
|
+
className: c,
|
|
754
766
|
CustomChannelEmptyState: l = xe
|
|
755
767
|
}) => /* @__PURE__ */ e(
|
|
756
768
|
"div",
|
|
757
769
|
{
|
|
758
770
|
className: D(
|
|
759
771
|
"messaging-channel-view h-full flex flex-col",
|
|
760
|
-
|
|
772
|
+
c
|
|
761
773
|
),
|
|
762
774
|
children: /* @__PURE__ */ e(De, { channel: t, children: /* @__PURE__ */ e(
|
|
763
775
|
Ye,
|
|
@@ -766,7 +778,7 @@ const xe = () => /* @__PURE__ */ e("div", { className: "messaging-channel-empty-
|
|
|
766
778
|
showBackButton: n,
|
|
767
779
|
renderMessageInputActions: r,
|
|
768
780
|
onLeaveConversation: a,
|
|
769
|
-
onBlockParticipant:
|
|
781
|
+
onBlockParticipant: d,
|
|
770
782
|
CustomChannelEmptyState: l
|
|
771
783
|
}
|
|
772
784
|
) })
|
|
@@ -777,8 +789,8 @@ function Qe({
|
|
|
777
789
|
setSearchQuery: s,
|
|
778
790
|
placeholder: n
|
|
779
791
|
}) {
|
|
780
|
-
const r =
|
|
781
|
-
return /* @__PURE__ */
|
|
792
|
+
const r = $(null);
|
|
793
|
+
return /* @__PURE__ */ u("div", { className: "relative", children: [
|
|
782
794
|
/* @__PURE__ */ e(
|
|
783
795
|
je,
|
|
784
796
|
{
|
|
@@ -817,67 +829,67 @@ const Xe = ({
|
|
|
817
829
|
onClose: n,
|
|
818
830
|
existingParticipantIds: r = /* @__PURE__ */ new Set(),
|
|
819
831
|
participantLabel: a = "participants",
|
|
820
|
-
searchPlaceholder:
|
|
821
|
-
className:
|
|
832
|
+
searchPlaceholder: d = "Search participants...",
|
|
833
|
+
className: c
|
|
822
834
|
}) => {
|
|
823
|
-
const { debug: l } = se(), [o, E] =
|
|
835
|
+
const { debug: l } = se(), [o, E] = w(""), [v, m] = w([]), [g, R] = w(!1), [x, C] = w(null), [h, k] = w(
|
|
824
836
|
null
|
|
825
|
-
),
|
|
826
|
-
|
|
837
|
+
), I = $(!1);
|
|
838
|
+
G(() => {
|
|
827
839
|
if (t.loading) {
|
|
828
840
|
l && console.log(
|
|
829
841
|
"[ParticipantPicker] Waiting for participant source to finish loading..."
|
|
830
842
|
);
|
|
831
843
|
return;
|
|
832
844
|
}
|
|
833
|
-
if (
|
|
845
|
+
if (I.current) return;
|
|
834
846
|
(async () => {
|
|
835
|
-
l && console.log("[ParticipantPicker] Loading initial participants..."),
|
|
847
|
+
l && console.log("[ParticipantPicker] Loading initial participants..."), R(!0), C(null);
|
|
836
848
|
try {
|
|
837
|
-
const
|
|
849
|
+
const f = await t.loadParticipants({
|
|
838
850
|
search: "",
|
|
839
851
|
// Load all participants initially
|
|
840
852
|
limit: 100
|
|
841
853
|
});
|
|
842
|
-
|
|
854
|
+
m(f.participants), I.current = !0, l && console.log(
|
|
843
855
|
"[ParticipantPicker] Participants loaded successfully:",
|
|
844
|
-
|
|
856
|
+
f.participants.length
|
|
845
857
|
);
|
|
846
|
-
} catch (
|
|
847
|
-
const
|
|
848
|
-
|
|
858
|
+
} catch (f) {
|
|
859
|
+
const b = f instanceof Error ? f.message : "Failed to load participants";
|
|
860
|
+
C(b), console.error("[ParticipantPicker] Failed to load participants:", f);
|
|
849
861
|
} finally {
|
|
850
|
-
|
|
862
|
+
R(!1);
|
|
851
863
|
}
|
|
852
864
|
})();
|
|
853
865
|
}, [t.loading, l]);
|
|
854
|
-
const y =
|
|
855
|
-
var
|
|
866
|
+
const y = v.filter((i) => !r.has(i.id)).filter((i) => {
|
|
867
|
+
var b;
|
|
856
868
|
if (!o) return !0;
|
|
857
|
-
const
|
|
858
|
-
return
|
|
869
|
+
const f = o.toLowerCase();
|
|
870
|
+
return i.name.toLowerCase().includes(f) || ((b = i.email) == null ? void 0 : b.toLowerCase().includes(f)) || !1;
|
|
859
871
|
}), T = P(
|
|
860
|
-
async (
|
|
861
|
-
if (!
|
|
862
|
-
k(
|
|
872
|
+
async (i) => {
|
|
873
|
+
if (!h) {
|
|
874
|
+
k(i.id);
|
|
863
875
|
try {
|
|
864
|
-
await s(
|
|
865
|
-
} catch (
|
|
866
|
-
console.error("[ParticipantPicker] Failed to start chat:",
|
|
876
|
+
await s(i);
|
|
877
|
+
} catch (f) {
|
|
878
|
+
console.error("[ParticipantPicker] Failed to start chat:", f), k(null);
|
|
867
879
|
}
|
|
868
880
|
}
|
|
869
881
|
},
|
|
870
|
-
[s,
|
|
871
|
-
), U = (
|
|
872
|
-
(
|
|
882
|
+
[s, h]
|
|
883
|
+
), U = (i, f) => {
|
|
884
|
+
(i.key === "Enter" || i.key === " ") && (i.preventDefault(), T(f));
|
|
873
885
|
};
|
|
874
|
-
return /* @__PURE__ */
|
|
875
|
-
/* @__PURE__ */
|
|
876
|
-
/* @__PURE__ */
|
|
886
|
+
return /* @__PURE__ */ u("div", { className: D("flex flex-col h-full", c), children: [
|
|
887
|
+
/* @__PURE__ */ u("div", { className: "px-4 py-4 border-b border-sand bg-chalk", children: [
|
|
888
|
+
/* @__PURE__ */ u("div", { className: "flex items-center justify-between mb-3", children: [
|
|
877
889
|
/* @__PURE__ */ e("h2", { className: "text-lg font-semibold text-charcoal", children: "Start a new Conversation" }),
|
|
878
890
|
/* @__PURE__ */ e(ge, { onClick: n })
|
|
879
891
|
] }),
|
|
880
|
-
/* @__PURE__ */
|
|
892
|
+
/* @__PURE__ */ u("p", { className: "text-xs text-stone mb-3", children: [
|
|
881
893
|
"Select a ",
|
|
882
894
|
a.slice(0, -1),
|
|
883
895
|
" to start messaging (",
|
|
@@ -890,77 +902,77 @@ const Xe = ({
|
|
|
890
902
|
{
|
|
891
903
|
searchQuery: o,
|
|
892
904
|
setSearchQuery: E,
|
|
893
|
-
placeholder:
|
|
905
|
+
placeholder: d
|
|
894
906
|
}
|
|
895
907
|
)
|
|
896
908
|
] }),
|
|
897
|
-
x && /* @__PURE__ */
|
|
909
|
+
x && /* @__PURE__ */ u("div", { className: "p-4 text-sm text-danger bg-danger-alt", children: [
|
|
898
910
|
"Error loading ",
|
|
899
911
|
a,
|
|
900
912
|
": ",
|
|
901
913
|
x
|
|
902
914
|
] }),
|
|
903
|
-
/* @__PURE__ */ e("div", { className: "flex-1 overflow-auto", children:
|
|
915
|
+
/* @__PURE__ */ e("div", { className: "flex-1 overflow-auto", children: g && y.length === 0 ? /* @__PURE__ */ e("div", { className: "h-32 flex items-center justify-center", children: /* @__PURE__ */ u("div", { className: "flex items-center space-x-2", children: [
|
|
904
916
|
/* @__PURE__ */ e("div", { className: "w-4 h-4 animate-spin rounded-full border-2 border-primary border-t-transparent" }),
|
|
905
|
-
/* @__PURE__ */
|
|
917
|
+
/* @__PURE__ */ u("span", { className: "text-sm text-stone", children: [
|
|
906
918
|
"Loading ",
|
|
907
919
|
a,
|
|
908
920
|
"..."
|
|
909
921
|
] })
|
|
910
|
-
] }) }) : y.length === 0 ? /* @__PURE__ */
|
|
922
|
+
] }) }) : y.length === 0 ? /* @__PURE__ */ u("div", { className: "p-6 text-center", children: [
|
|
911
923
|
/* @__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" }) }),
|
|
912
|
-
/* @__PURE__ */ e("h3", { className: "text-sm font-semibold text-charcoal mb-2", children: o ? `No ${a} found` :
|
|
913
|
-
/* @__PURE__ */ e("p", { className: "text-xs text-stone", children: o ? "Try a different search term" :
|
|
914
|
-
] }) : /* @__PURE__ */
|
|
915
|
-
y.map((
|
|
916
|
-
const
|
|
924
|
+
/* @__PURE__ */ e("h3", { className: "text-sm font-semibold text-charcoal mb-2", children: o ? `No ${a} found` : v.length > 0 ? `Already chatting with all ${a}` : `No ${a} yet` }),
|
|
925
|
+
/* @__PURE__ */ e("p", { className: "text-xs text-stone", children: o ? "Try a different search term" : v.length > 0 ? `You have existing conversations with all your ${a}` : `${a.charAt(0).toUpperCase() + a.slice(1)} will appear here` })
|
|
926
|
+
] }) : /* @__PURE__ */ u("ul", { className: "space-y-0", children: [
|
|
927
|
+
y.map((i) => {
|
|
928
|
+
const f = i.name || i.email || i.id, b = i.email && i.name ? i.email : i.phone;
|
|
917
929
|
return /* @__PURE__ */ e("li", { children: /* @__PURE__ */ e(
|
|
918
930
|
"button",
|
|
919
931
|
{
|
|
920
932
|
type: "button",
|
|
921
|
-
onClick: () => T(
|
|
922
|
-
onKeyDown: (F) => U(F,
|
|
933
|
+
onClick: () => T(i),
|
|
934
|
+
onKeyDown: (F) => U(F, i),
|
|
923
935
|
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",
|
|
924
|
-
children: /* @__PURE__ */
|
|
925
|
-
/* @__PURE__ */
|
|
936
|
+
children: /* @__PURE__ */ u("div", { className: "flex items-center justify-between", children: [
|
|
937
|
+
/* @__PURE__ */ u("div", { className: "flex items-center space-x-3 flex-1 min-w-0", children: [
|
|
926
938
|
/* @__PURE__ */ e(
|
|
927
939
|
J,
|
|
928
940
|
{
|
|
929
|
-
id:
|
|
930
|
-
name:
|
|
931
|
-
image:
|
|
941
|
+
id: i.id,
|
|
942
|
+
name: f,
|
|
943
|
+
image: i.image,
|
|
932
944
|
size: 40
|
|
933
945
|
}
|
|
934
946
|
),
|
|
935
|
-
/* @__PURE__ */
|
|
936
|
-
/* @__PURE__ */ e("h4", { className: "text-sm font-medium text-charcoal truncate", children:
|
|
937
|
-
|
|
947
|
+
/* @__PURE__ */ u("div", { className: "flex-1 min-w-0", children: [
|
|
948
|
+
/* @__PURE__ */ e("h4", { className: "text-sm font-medium text-charcoal truncate", children: f }),
|
|
949
|
+
b && /* @__PURE__ */ e("p", { className: "text-xs text-stone truncate", children: b })
|
|
938
950
|
] })
|
|
939
951
|
] }),
|
|
940
|
-
/* @__PURE__ */ e("div", { className: "flex-shrink-0", children:
|
|
952
|
+
/* @__PURE__ */ e("div", { className: "flex-shrink-0", children: h === i.id ? /* @__PURE__ */ e(ee, { className: "h-5 w-5 text-primary animate-spin" }) : /* @__PURE__ */ e(ce, { className: "h-5 w-5 text-stone" }) })
|
|
941
953
|
] })
|
|
942
954
|
}
|
|
943
|
-
) },
|
|
955
|
+
) }, i.id);
|
|
944
956
|
}),
|
|
945
|
-
|
|
957
|
+
g && /* @__PURE__ */ e("li", { className: "p-4 flex justify-center", children: /* @__PURE__ */ u("div", { className: "flex items-center space-x-2", children: [
|
|
946
958
|
/* @__PURE__ */ e("div", { className: "w-4 h-4 animate-spin rounded-full border-2 border-primary border-t-transparent" }),
|
|
947
959
|
/* @__PURE__ */ e("span", { className: "text-sm text-stone", children: "Loading more..." })
|
|
948
960
|
] }) })
|
|
949
961
|
] }) })
|
|
950
962
|
] });
|
|
951
|
-
}, 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__ */
|
|
963
|
+
}, 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__ */ u("div", { className: "text-center max-w-sm", children: [
|
|
952
964
|
/* @__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: "๐ฌ" }) }),
|
|
953
965
|
/* @__PURE__ */ e("h2", { className: "font-semibold text-charcoal", children: "Welcome to Messages" }),
|
|
954
|
-
/* @__PURE__ */ e("p", { className: "text-stone text-sm mb-6", children: t ? /* @__PURE__ */
|
|
966
|
+
/* @__PURE__ */ e("p", { className: "text-stone text-sm mb-6", children: t ? /* @__PURE__ */ u(le, { children: [
|
|
955
967
|
"Choose a conversation from the list or",
|
|
956
968
|
" ",
|
|
957
|
-
s && /* @__PURE__ */
|
|
969
|
+
s && /* @__PURE__ */ u(ue, { onClick: s, children: [
|
|
958
970
|
"start a new conversation with a ",
|
|
959
971
|
n.slice(0, -1),
|
|
960
972
|
"."
|
|
961
973
|
] })
|
|
962
|
-
] }) : s && /* @__PURE__ */
|
|
963
|
-
/* @__PURE__ */
|
|
974
|
+
] }) : s && /* @__PURE__ */ u(le, { children: [
|
|
975
|
+
/* @__PURE__ */ u(ue, { onClick: s, children: [
|
|
964
976
|
"Start a new conversation with one of your ",
|
|
965
977
|
n
|
|
966
978
|
] }),
|
|
@@ -978,7 +990,7 @@ const Xe = ({
|
|
|
978
990
|
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",
|
|
979
991
|
children: s
|
|
980
992
|
}
|
|
981
|
-
), re = ({ message: t, onBack: s }) => /* @__PURE__ */ e("div", { className: "messaging-error-state flex items-center justify-center h-full p-8", children: /* @__PURE__ */
|
|
993
|
+
), re = ({ message: t, onBack: s }) => /* @__PURE__ */ e("div", { className: "messaging-error-state flex items-center justify-center h-full p-8", children: /* @__PURE__ */ u("div", { className: "text-center max-w-sm", children: [
|
|
982
994
|
/* @__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: "โ ๏ธ" }) }),
|
|
983
995
|
/* @__PURE__ */ e("h2", { className: "font-semibold text-charcoal mb-2", children: "Oops!" }),
|
|
984
996
|
/* @__PURE__ */ e("p", { className: "text-stone text-sm mb-6", children: t }),
|
|
@@ -991,12 +1003,12 @@ const Xe = ({
|
|
|
991
1003
|
children: "Go Back"
|
|
992
1004
|
}
|
|
993
1005
|
)
|
|
994
|
-
] }) }), Ke = ({ className: t, message: s }) => /* @__PURE__ */
|
|
1006
|
+
] }) }), Ke = ({ className: t, message: s }) => /* @__PURE__ */ u(
|
|
995
1007
|
"div",
|
|
996
1008
|
{
|
|
997
1009
|
className: D("flex items-center justify-center h-full", t),
|
|
998
1010
|
children: [
|
|
999
|
-
/* @__PURE__ */
|
|
1011
|
+
/* @__PURE__ */ u("svg", { viewBox: "0 0 100 100", className: "size-8 fill-pebble", stroke: "none", children: [
|
|
1000
1012
|
/* @__PURE__ */ e("circle", { cx: "6", cy: "50", r: "6", children: /* @__PURE__ */ e(
|
|
1001
1013
|
"animateTransform",
|
|
1002
1014
|
{
|
|
@@ -1034,7 +1046,7 @@ const Xe = ({
|
|
|
1034
1046
|
s && /* @__PURE__ */ e("span", { className: "text-stone", children: s })
|
|
1035
1047
|
]
|
|
1036
1048
|
}
|
|
1037
|
-
), es = () => /* @__PURE__ */ e("div", { className: "messaging-loading-state flex items-center justify-center h-full", children: /* @__PURE__ */
|
|
1049
|
+
), es = () => /* @__PURE__ */ e("div", { className: "messaging-loading-state flex items-center justify-center h-full", children: /* @__PURE__ */ u("div", { className: "flex items-center", children: [
|
|
1038
1050
|
/* @__PURE__ */ e(Ke, { className: "w-6 h-6" }),
|
|
1039
1051
|
/* @__PURE__ */ e("span", { className: "text-sm text-stone", children: "Loading messages" })
|
|
1040
1052
|
] }) }), cs = ({
|
|
@@ -1043,26 +1055,26 @@ const Xe = ({
|
|
|
1043
1055
|
renderMessageInputActions: n,
|
|
1044
1056
|
onChannelSelect: r,
|
|
1045
1057
|
onParticipantSelect: a,
|
|
1046
|
-
initialParticipantFilter:
|
|
1047
|
-
initialParticipantData:
|
|
1058
|
+
initialParticipantFilter: d,
|
|
1059
|
+
initialParticipantData: c,
|
|
1048
1060
|
CustomChannelEmptyState: l,
|
|
1049
1061
|
showChannelList: o = !0,
|
|
1050
1062
|
filters: E
|
|
1051
1063
|
}) => {
|
|
1052
1064
|
const {
|
|
1053
|
-
service:
|
|
1054
|
-
client:
|
|
1055
|
-
isConnected:
|
|
1056
|
-
isLoading:
|
|
1065
|
+
service: v,
|
|
1066
|
+
client: m,
|
|
1067
|
+
isConnected: g,
|
|
1068
|
+
isLoading: R,
|
|
1057
1069
|
error: x,
|
|
1058
|
-
refreshConnection:
|
|
1059
|
-
debug:
|
|
1060
|
-
} =
|
|
1070
|
+
refreshConnection: C,
|
|
1071
|
+
debug: h
|
|
1072
|
+
} = _e(), [k, I] = w(null), [y, T] = w(!1), [U, i] = w(!1), [f, b] = w(/* @__PURE__ */ new Set()), [F, z] = w(0), [M, A] = w(!1), [Y, H] = w(null), V = $(null), {
|
|
1061
1073
|
showStartConversation: Q = !1,
|
|
1062
1074
|
participantSource: W,
|
|
1063
|
-
participantLabel:
|
|
1064
|
-
} = t,
|
|
1065
|
-
const N =
|
|
1075
|
+
participantLabel: S = "participants"
|
|
1076
|
+
} = t, O = q.useMemo(() => {
|
|
1077
|
+
const N = m == null ? void 0 : m.userID;
|
|
1066
1078
|
return {
|
|
1067
1079
|
...{
|
|
1068
1080
|
type: "messaging",
|
|
@@ -1074,164 +1086,164 @@ const Xe = ({
|
|
|
1074
1086
|
},
|
|
1075
1087
|
...E
|
|
1076
1088
|
};
|
|
1077
|
-
}, [E,
|
|
1078
|
-
if (!
|
|
1079
|
-
const N =
|
|
1089
|
+
}, [E, m == null ? void 0 : m.userID]), j = $(null), _ = P(async () => {
|
|
1090
|
+
if (!m || !g) return;
|
|
1091
|
+
const N = m.userID;
|
|
1080
1092
|
if (N)
|
|
1081
1093
|
try {
|
|
1082
|
-
|
|
1083
|
-
const L = await
|
|
1094
|
+
h && console.log("[MessagingShell] Syncing channels for user:", N);
|
|
1095
|
+
const L = await m.queryChannels(
|
|
1084
1096
|
{
|
|
1085
1097
|
type: "messaging",
|
|
1086
1098
|
members: { $in: [N] }
|
|
1087
1099
|
},
|
|
1088
1100
|
{},
|
|
1089
1101
|
{ limit: 100 }
|
|
1090
|
-
),
|
|
1091
|
-
L.forEach((
|
|
1092
|
-
const Ee =
|
|
1102
|
+
), p = /* @__PURE__ */ new Set();
|
|
1103
|
+
L.forEach((B) => {
|
|
1104
|
+
const Ee = B.state.members;
|
|
1093
1105
|
Object.values(Ee).forEach((ye) => {
|
|
1094
1106
|
var ae;
|
|
1095
1107
|
const te = (ae = ye.user) == null ? void 0 : ae.id;
|
|
1096
|
-
te && te !== N &&
|
|
1108
|
+
te && te !== N && p.add(te);
|
|
1097
1109
|
});
|
|
1098
|
-
}),
|
|
1110
|
+
}), b(p), T(L.length > 0), j.current = N, h && console.log("[MessagingShell] Channels synced successfully:", {
|
|
1099
1111
|
channelCount: L.length,
|
|
1100
|
-
memberCount:
|
|
1112
|
+
memberCount: p.size
|
|
1101
1113
|
});
|
|
1102
1114
|
} catch (L) {
|
|
1103
1115
|
console.error("[MessagingShell] Failed to sync channels:", L);
|
|
1104
1116
|
}
|
|
1105
|
-
}, [
|
|
1106
|
-
|
|
1107
|
-
if (!
|
|
1108
|
-
const N =
|
|
1109
|
-
N && j.current !== N &&
|
|
1110
|
-
}, [
|
|
1111
|
-
if (!
|
|
1117
|
+
}, [m, g, h]);
|
|
1118
|
+
G(() => {
|
|
1119
|
+
if (!m || !g) return;
|
|
1120
|
+
const N = m.userID;
|
|
1121
|
+
N && j.current !== N && _();
|
|
1122
|
+
}, [m, g, _]), G(() => {
|
|
1123
|
+
if (!d || !m || !g) return;
|
|
1112
1124
|
(async () => {
|
|
1113
|
-
const L =
|
|
1125
|
+
const L = m.userID;
|
|
1114
1126
|
if (L)
|
|
1115
1127
|
try {
|
|
1116
|
-
|
|
1128
|
+
h && console.log(
|
|
1117
1129
|
"[MessagingShell] Loading initial conversation with:",
|
|
1118
|
-
|
|
1130
|
+
d
|
|
1119
1131
|
);
|
|
1120
|
-
const
|
|
1132
|
+
const p = await m.queryChannels(
|
|
1121
1133
|
{
|
|
1122
1134
|
type: "messaging",
|
|
1123
|
-
members: { $eq: [L,
|
|
1135
|
+
members: { $eq: [L, d] }
|
|
1124
1136
|
},
|
|
1125
1137
|
{},
|
|
1126
1138
|
{ limit: 1 }
|
|
1127
1139
|
);
|
|
1128
|
-
if (
|
|
1129
|
-
|
|
1140
|
+
if (p.length > 0)
|
|
1141
|
+
I(p[0]), A(!0), H(null), r && r(p[0]), h && console.log(
|
|
1130
1142
|
"[MessagingShell] Initial conversation loaded:",
|
|
1131
|
-
|
|
1143
|
+
p[0].id
|
|
1132
1144
|
);
|
|
1133
|
-
else if (
|
|
1134
|
-
|
|
1145
|
+
else if (c && v) {
|
|
1146
|
+
h && console.log(
|
|
1135
1147
|
"[MessagingShell] No conversation found, creating one for:",
|
|
1136
|
-
|
|
1148
|
+
c
|
|
1137
1149
|
);
|
|
1138
1150
|
try {
|
|
1139
|
-
const
|
|
1140
|
-
id:
|
|
1141
|
-
name:
|
|
1142
|
-
email:
|
|
1143
|
-
phone:
|
|
1151
|
+
const B = await v.startChannelWithParticipant({
|
|
1152
|
+
id: c.id,
|
|
1153
|
+
name: c.name,
|
|
1154
|
+
email: c.email,
|
|
1155
|
+
phone: c.phone
|
|
1144
1156
|
});
|
|
1145
|
-
|
|
1157
|
+
I(B), A(!0), H(null), r && r(B), h && console.log(
|
|
1146
1158
|
"[MessagingShell] Channel created and loaded:",
|
|
1147
|
-
|
|
1159
|
+
B.id
|
|
1148
1160
|
);
|
|
1149
|
-
} catch (
|
|
1161
|
+
} catch (B) {
|
|
1150
1162
|
console.error(
|
|
1151
1163
|
"[MessagingShell] Failed to create conversation:",
|
|
1152
|
-
|
|
1153
|
-
),
|
|
1164
|
+
B
|
|
1165
|
+
), H("Failed to create conversation");
|
|
1154
1166
|
}
|
|
1155
1167
|
} else
|
|
1156
|
-
|
|
1168
|
+
H(
|
|
1157
1169
|
"No conversation found with this account"
|
|
1158
|
-
),
|
|
1170
|
+
), h && console.log(
|
|
1159
1171
|
"[MessagingShell] No conversation found for:",
|
|
1160
|
-
|
|
1172
|
+
d
|
|
1161
1173
|
);
|
|
1162
|
-
} catch (
|
|
1174
|
+
} catch (p) {
|
|
1163
1175
|
console.error(
|
|
1164
1176
|
"[MessagingShell] Failed to load initial conversation:",
|
|
1165
|
-
|
|
1166
|
-
),
|
|
1177
|
+
p
|
|
1178
|
+
), H("Failed to load conversation");
|
|
1167
1179
|
}
|
|
1168
1180
|
})();
|
|
1169
1181
|
}, [
|
|
1182
|
+
d,
|
|
1170
1183
|
c,
|
|
1171
|
-
i,
|
|
1172
|
-
u,
|
|
1173
|
-
f,
|
|
1174
|
-
b,
|
|
1175
1184
|
m,
|
|
1185
|
+
g,
|
|
1186
|
+
v,
|
|
1187
|
+
h,
|
|
1176
1188
|
r
|
|
1177
1189
|
]);
|
|
1178
1190
|
const X = P(
|
|
1179
1191
|
(N) => {
|
|
1180
|
-
|
|
1192
|
+
I(N), r == null || r(N);
|
|
1181
1193
|
},
|
|
1182
1194
|
[r]
|
|
1183
1195
|
), Ne = P(() => {
|
|
1184
|
-
M ||
|
|
1196
|
+
M || I(null);
|
|
1185
1197
|
}, [M]), be = P(() => {
|
|
1186
1198
|
var N;
|
|
1187
|
-
W && (z((L) => L + 1),
|
|
1199
|
+
W && (z((L) => L + 1), i(!0), (N = V.current) == null || N.showModal());
|
|
1188
1200
|
}, [W]), ve = P(
|
|
1189
1201
|
async (N) => {
|
|
1190
1202
|
var L;
|
|
1191
|
-
if (
|
|
1203
|
+
if (v)
|
|
1192
1204
|
try {
|
|
1193
|
-
|
|
1205
|
+
h && console.log(
|
|
1194
1206
|
"[MessagingShell] Starting conversation with:",
|
|
1195
1207
|
N.id
|
|
1196
1208
|
);
|
|
1197
|
-
const
|
|
1209
|
+
const p = await v.startChannelWithParticipant({
|
|
1198
1210
|
id: N.id,
|
|
1199
1211
|
name: N.name,
|
|
1200
1212
|
email: N.email,
|
|
1201
1213
|
phone: N.phone
|
|
1202
1214
|
});
|
|
1203
1215
|
try {
|
|
1204
|
-
await
|
|
1205
|
-
} catch (
|
|
1206
|
-
console.warn("[MessagingShell] Failed to unhide channel:",
|
|
1216
|
+
await p.show();
|
|
1217
|
+
} catch (B) {
|
|
1218
|
+
console.warn("[MessagingShell] Failed to unhide channel:", B);
|
|
1207
1219
|
}
|
|
1208
|
-
|
|
1209
|
-
} catch (
|
|
1210
|
-
console.error("[MessagingShell] Failed to start conversation:",
|
|
1220
|
+
I(p), i(!1), (L = V.current) == null || L.close(), a == null || a(N);
|
|
1221
|
+
} catch (p) {
|
|
1222
|
+
console.error("[MessagingShell] Failed to start conversation:", p);
|
|
1211
1223
|
}
|
|
1212
1224
|
},
|
|
1213
|
-
[
|
|
1225
|
+
[v, a, h]
|
|
1214
1226
|
), ne = P(() => {
|
|
1215
1227
|
var N;
|
|
1216
|
-
|
|
1228
|
+
i(!1), (N = V.current) == null || N.close();
|
|
1217
1229
|
}, []), Ce = P(
|
|
1218
1230
|
async (N) => {
|
|
1219
|
-
|
|
1231
|
+
h && console.log("[MessagingShell] Leaving conversation:", N.id), I(null), A(!1), j.current = null, await _();
|
|
1220
1232
|
},
|
|
1221
|
-
[
|
|
1233
|
+
[_, h]
|
|
1222
1234
|
), we = P(
|
|
1223
1235
|
async (N) => {
|
|
1224
|
-
|
|
1236
|
+
h && console.log("[MessagingShell] Blocking participant:", N), I(null), A(!1), j.current = null, await _();
|
|
1225
1237
|
},
|
|
1226
|
-
[
|
|
1238
|
+
[_, h]
|
|
1227
1239
|
), Z = !!k;
|
|
1228
|
-
return
|
|
1240
|
+
return R ? /* @__PURE__ */ e("div", { className: D("h-full", s), children: /* @__PURE__ */ e(es, {}) }) : x ? /* @__PURE__ */ e("div", { className: D("h-full", s), children: /* @__PURE__ */ e(re, { message: x, onBack: C }) }) : !g || !m ? /* @__PURE__ */ e("div", { className: D("h-full", s), children: /* @__PURE__ */ e(
|
|
1229
1241
|
re,
|
|
1230
1242
|
{
|
|
1231
1243
|
message: "Not connected to messaging service",
|
|
1232
|
-
onBack:
|
|
1244
|
+
onBack: C
|
|
1233
1245
|
}
|
|
1234
|
-
) }) : Y ? /* @__PURE__ */ e("div", { className: D("h-full", s), children: /* @__PURE__ */ e(re, { message: Y }) }) : /* @__PURE__ */
|
|
1246
|
+
) }) : Y ? /* @__PURE__ */ e("div", { className: D("h-full", s), children: /* @__PURE__ */ e(re, { message: Y }) }) : /* @__PURE__ */ u(
|
|
1235
1247
|
"div",
|
|
1236
1248
|
{
|
|
1237
1249
|
className: D(
|
|
@@ -1239,7 +1251,7 @@ const Xe = ({
|
|
|
1239
1251
|
s
|
|
1240
1252
|
),
|
|
1241
1253
|
children: [
|
|
1242
|
-
/* @__PURE__ */
|
|
1254
|
+
/* @__PURE__ */ u("div", { className: "flex h-full min-h-0", children: [
|
|
1243
1255
|
/* @__PURE__ */ e(
|
|
1244
1256
|
"div",
|
|
1245
1257
|
{
|
|
@@ -1259,7 +1271,7 @@ const Xe = ({
|
|
|
1259
1271
|
{
|
|
1260
1272
|
onChannelSelect: X,
|
|
1261
1273
|
selectedChannel: k || void 0,
|
|
1262
|
-
filters:
|
|
1274
|
+
filters: O
|
|
1263
1275
|
}
|
|
1264
1276
|
)
|
|
1265
1277
|
}
|
|
@@ -1293,7 +1305,7 @@ const Xe = ({
|
|
|
1293
1305
|
{
|
|
1294
1306
|
hasChannels: y,
|
|
1295
1307
|
onStartConversation: Q ? be : void 0,
|
|
1296
|
-
participantLabel:
|
|
1308
|
+
participantLabel: S
|
|
1297
1309
|
}
|
|
1298
1310
|
)
|
|
1299
1311
|
}
|
|
@@ -1315,9 +1327,9 @@ const Xe = ({
|
|
|
1315
1327
|
participantSource: W,
|
|
1316
1328
|
onSelectParticipant: ve,
|
|
1317
1329
|
onClose: ne,
|
|
1318
|
-
existingParticipantIds:
|
|
1319
|
-
participantLabel:
|
|
1320
|
-
searchPlaceholder: `Search ${
|
|
1330
|
+
existingParticipantIds: f,
|
|
1331
|
+
participantLabel: S,
|
|
1332
|
+
searchPlaceholder: `Search ${S}...`
|
|
1321
1333
|
},
|
|
1322
1334
|
F
|
|
1323
1335
|
) })
|
|
@@ -1354,21 +1366,21 @@ const Xe = ({
|
|
|
1354
1366
|
loadingFaqId: n,
|
|
1355
1367
|
headerText: r,
|
|
1356
1368
|
className: a,
|
|
1357
|
-
avatarImage:
|
|
1358
|
-
avatarName:
|
|
1369
|
+
avatarImage: d,
|
|
1370
|
+
avatarName: c
|
|
1359
1371
|
}) => {
|
|
1360
1372
|
const l = t.filter((o) => o.enabled).sort((o, E) => (o.order ?? 0) - (E.order ?? 0));
|
|
1361
|
-
return l.length === 0 ? null : /* @__PURE__ */ e("div", { className: D("px-4 py-6", a), children: /* @__PURE__ */
|
|
1362
|
-
(
|
|
1373
|
+
return l.length === 0 ? null : /* @__PURE__ */ e("div", { className: D("px-4 py-6", a), children: /* @__PURE__ */ u("div", { className: "flex gap-3 items-end", children: [
|
|
1374
|
+
(d || c) && /* @__PURE__ */ e("div", { className: "flex-none", children: /* @__PURE__ */ e(
|
|
1363
1375
|
J,
|
|
1364
1376
|
{
|
|
1365
|
-
id:
|
|
1366
|
-
name:
|
|
1367
|
-
image:
|
|
1377
|
+
id: c || "account",
|
|
1378
|
+
name: c || "Account",
|
|
1379
|
+
image: d,
|
|
1368
1380
|
size: 24
|
|
1369
1381
|
}
|
|
1370
1382
|
) }),
|
|
1371
|
-
/* @__PURE__ */
|
|
1383
|
+
/* @__PURE__ */ u(
|
|
1372
1384
|
"div",
|
|
1373
1385
|
{
|
|
1374
1386
|
className: "flex-1 rounded-lg p-4 space-y-3",
|
|
@@ -1389,43 +1401,43 @@ const Xe = ({
|
|
|
1389
1401
|
)
|
|
1390
1402
|
] }) });
|
|
1391
1403
|
}, us = (t, s = {}) => {
|
|
1392
|
-
const { initialSearch: n = "", pageSize: r = 20 } = s, [a,
|
|
1393
|
-
if (
|
|
1394
|
-
const
|
|
1404
|
+
const { initialSearch: n = "", pageSize: r = 20 } = s, [a, d] = w([]), [c, l] = w(!1), [o, E] = w(null), [v, m] = w(n), [g, R] = w(!0), [x, C] = w(), h = P(async (T = !1, U) => {
|
|
1405
|
+
if (c) return;
|
|
1406
|
+
const i = U !== void 0 ? U : v;
|
|
1395
1407
|
l(!0), E(null);
|
|
1396
1408
|
try {
|
|
1397
|
-
const
|
|
1398
|
-
search:
|
|
1409
|
+
const f = await t.loadParticipants({
|
|
1410
|
+
search: i || void 0,
|
|
1399
1411
|
limit: r,
|
|
1400
1412
|
cursor: T ? void 0 : x
|
|
1401
1413
|
});
|
|
1402
|
-
|
|
1403
|
-
(
|
|
1404
|
-
),
|
|
1405
|
-
} catch (
|
|
1406
|
-
const
|
|
1407
|
-
E(
|
|
1414
|
+
d(
|
|
1415
|
+
(b) => T ? f.participants : [...b, ...f.participants]
|
|
1416
|
+
), R(f.hasMore), C(f.nextCursor);
|
|
1417
|
+
} catch (f) {
|
|
1418
|
+
const b = f instanceof Error ? f.message : "Failed to load participants";
|
|
1419
|
+
E(b), console.error("[useParticipants] Load error:", f);
|
|
1408
1420
|
} finally {
|
|
1409
1421
|
l(!1);
|
|
1410
1422
|
}
|
|
1411
|
-
}, [t,
|
|
1412
|
-
|
|
1413
|
-
}, [
|
|
1414
|
-
|
|
1415
|
-
}, [
|
|
1416
|
-
|
|
1417
|
-
}, [
|
|
1418
|
-
return
|
|
1419
|
-
|
|
1423
|
+
}, [t, v, x, r, c]), k = P(() => {
|
|
1424
|
+
g && !c && h(!1);
|
|
1425
|
+
}, [g, c, h]), I = P((T) => {
|
|
1426
|
+
m(T), C(void 0), h(!0, T);
|
|
1427
|
+
}, [h]), y = P(() => {
|
|
1428
|
+
C(void 0), h(!0);
|
|
1429
|
+
}, [h]);
|
|
1430
|
+
return G(() => {
|
|
1431
|
+
h(!0);
|
|
1420
1432
|
}, [t.loadParticipants]), {
|
|
1421
1433
|
participants: a,
|
|
1422
|
-
loading:
|
|
1434
|
+
loading: c,
|
|
1423
1435
|
error: o,
|
|
1424
|
-
searchQuery:
|
|
1425
|
-
hasMore:
|
|
1436
|
+
searchQuery: v,
|
|
1437
|
+
hasMore: g,
|
|
1426
1438
|
totalCount: t.totalCount,
|
|
1427
1439
|
loadMore: k,
|
|
1428
|
-
search:
|
|
1440
|
+
search: I,
|
|
1429
1441
|
refresh: y
|
|
1430
1442
|
};
|
|
1431
1443
|
};
|
|
@@ -1439,8 +1451,8 @@ export {
|
|
|
1439
1451
|
is as MessagingProvider,
|
|
1440
1452
|
cs as MessagingShell,
|
|
1441
1453
|
Xe as ParticipantPicker,
|
|
1442
|
-
|
|
1443
|
-
|
|
1454
|
+
Be as formatRelativeTime,
|
|
1455
|
+
_e as useMessaging,
|
|
1444
1456
|
us as useParticipants
|
|
1445
1457
|
};
|
|
1446
1458
|
//# sourceMappingURL=index.js.map
|