@linktr.ee/messaging-react 1.8.4 โ 1.8.5
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,40 +125,40 @@ 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
|
});
|
|
136
136
|
} catch (M) {
|
|
137
|
-
const
|
|
138
|
-
k(
|
|
137
|
+
const B = M instanceof Error ? M.message : "Connection failed";
|
|
138
|
+
k(B), l("โ USER CONNECTION ERROR", {
|
|
139
139
|
userId: s.id,
|
|
140
|
-
error:
|
|
140
|
+
error: B
|
|
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,67 +166,67 @@ 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(), Be = (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
|
+
}, Ae = (t) => {
|
|
226
226
|
const s = /* @__PURE__ */ new Date();
|
|
227
227
|
if (Math.floor((s.getTime() - t.getTime()) / 1e3) < 60)
|
|
228
228
|
return "Just now";
|
|
229
|
-
const r =
|
|
229
|
+
const r = Be(t, s);
|
|
230
230
|
return r === 0 ? t.toLocaleTimeString([], {
|
|
231
231
|
hour: "numeric",
|
|
232
232
|
minute: "2-digit"
|
|
@@ -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 ? Ae(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,
|
|
518
|
-
const { service: l, debug: o } = se(), E =
|
|
519
|
-
|
|
520
|
-
const
|
|
521
|
-
|
|
522
|
+
var M, B, 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 = ((
|
|
594
|
+
const U = ((B = n.user) == null ? void 0 : B.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,40 @@ 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__ */
|
|
727
|
+
/* @__PURE__ */ u("div", { className: "flex-1 overflow-hidden relative", children: [
|
|
723
728
|
/* @__PURE__ */ e(Me, { hideDeletedMessages: !0, hideNewMessageSeparator: !1 }),
|
|
724
|
-
!E &&
|
|
729
|
+
!E && d && /* @__PURE__ */ e("div", { className: "absolute inset-0 w-full h-full bg-white", children: /* @__PURE__ */ e(d, {}) })
|
|
725
730
|
] }),
|
|
726
731
|
/* @__PURE__ */ e(
|
|
727
732
|
We,
|
|
728
733
|
{
|
|
729
|
-
renderActions: () => n == null ? void 0 : n(
|
|
734
|
+
renderActions: () => n == null ? void 0 : n(c)
|
|
730
735
|
}
|
|
731
736
|
)
|
|
732
737
|
] }),
|
|
@@ -735,9 +740,9 @@ const xe = () => /* @__PURE__ */ e("div", { className: "messaging-channel-empty-
|
|
|
735
740
|
{
|
|
736
741
|
isOpen: l,
|
|
737
742
|
onClose: () => o(!1),
|
|
738
|
-
participant:
|
|
739
|
-
channel:
|
|
740
|
-
followerStatusLabel:
|
|
743
|
+
participant: v,
|
|
744
|
+
channel: c,
|
|
745
|
+
followerStatusLabel: m,
|
|
741
746
|
onLeaveConversation: r,
|
|
742
747
|
onBlockParticipant: a
|
|
743
748
|
}
|
|
@@ -749,15 +754,15 @@ const xe = () => /* @__PURE__ */ e("div", { className: "messaging-channel-empty-
|
|
|
749
754
|
showBackButton: n = !1,
|
|
750
755
|
renderMessageInputActions: r,
|
|
751
756
|
onLeaveConversation: a,
|
|
752
|
-
onBlockParticipant:
|
|
753
|
-
className:
|
|
757
|
+
onBlockParticipant: d,
|
|
758
|
+
className: c,
|
|
754
759
|
CustomChannelEmptyState: l = xe
|
|
755
760
|
}) => /* @__PURE__ */ e(
|
|
756
761
|
"div",
|
|
757
762
|
{
|
|
758
763
|
className: D(
|
|
759
764
|
"messaging-channel-view h-full flex flex-col",
|
|
760
|
-
|
|
765
|
+
c
|
|
761
766
|
),
|
|
762
767
|
children: /* @__PURE__ */ e(De, { channel: t, children: /* @__PURE__ */ e(
|
|
763
768
|
Ye,
|
|
@@ -766,7 +771,7 @@ const xe = () => /* @__PURE__ */ e("div", { className: "messaging-channel-empty-
|
|
|
766
771
|
showBackButton: n,
|
|
767
772
|
renderMessageInputActions: r,
|
|
768
773
|
onLeaveConversation: a,
|
|
769
|
-
onBlockParticipant:
|
|
774
|
+
onBlockParticipant: d,
|
|
770
775
|
CustomChannelEmptyState: l
|
|
771
776
|
}
|
|
772
777
|
) })
|
|
@@ -777,8 +782,8 @@ function Qe({
|
|
|
777
782
|
setSearchQuery: s,
|
|
778
783
|
placeholder: n
|
|
779
784
|
}) {
|
|
780
|
-
const r =
|
|
781
|
-
return /* @__PURE__ */
|
|
785
|
+
const r = $(null);
|
|
786
|
+
return /* @__PURE__ */ u("div", { className: "relative", children: [
|
|
782
787
|
/* @__PURE__ */ e(
|
|
783
788
|
je,
|
|
784
789
|
{
|
|
@@ -817,67 +822,67 @@ const Xe = ({
|
|
|
817
822
|
onClose: n,
|
|
818
823
|
existingParticipantIds: r = /* @__PURE__ */ new Set(),
|
|
819
824
|
participantLabel: a = "participants",
|
|
820
|
-
searchPlaceholder:
|
|
821
|
-
className:
|
|
825
|
+
searchPlaceholder: d = "Search participants...",
|
|
826
|
+
className: c
|
|
822
827
|
}) => {
|
|
823
|
-
const { debug: l } = se(), [o, E] =
|
|
828
|
+
const { debug: l } = se(), [o, E] = w(""), [v, m] = w([]), [g, R] = w(!1), [x, C] = w(null), [h, k] = w(
|
|
824
829
|
null
|
|
825
|
-
),
|
|
826
|
-
|
|
830
|
+
), I = $(!1);
|
|
831
|
+
G(() => {
|
|
827
832
|
if (t.loading) {
|
|
828
833
|
l && console.log(
|
|
829
834
|
"[ParticipantPicker] Waiting for participant source to finish loading..."
|
|
830
835
|
);
|
|
831
836
|
return;
|
|
832
837
|
}
|
|
833
|
-
if (
|
|
838
|
+
if (I.current) return;
|
|
834
839
|
(async () => {
|
|
835
|
-
l && console.log("[ParticipantPicker] Loading initial participants..."),
|
|
840
|
+
l && console.log("[ParticipantPicker] Loading initial participants..."), R(!0), C(null);
|
|
836
841
|
try {
|
|
837
|
-
const
|
|
842
|
+
const f = await t.loadParticipants({
|
|
838
843
|
search: "",
|
|
839
844
|
// Load all participants initially
|
|
840
845
|
limit: 100
|
|
841
846
|
});
|
|
842
|
-
|
|
847
|
+
m(f.participants), I.current = !0, l && console.log(
|
|
843
848
|
"[ParticipantPicker] Participants loaded successfully:",
|
|
844
|
-
|
|
849
|
+
f.participants.length
|
|
845
850
|
);
|
|
846
|
-
} catch (
|
|
847
|
-
const
|
|
848
|
-
|
|
851
|
+
} catch (f) {
|
|
852
|
+
const b = f instanceof Error ? f.message : "Failed to load participants";
|
|
853
|
+
C(b), console.error("[ParticipantPicker] Failed to load participants:", f);
|
|
849
854
|
} finally {
|
|
850
|
-
|
|
855
|
+
R(!1);
|
|
851
856
|
}
|
|
852
857
|
})();
|
|
853
858
|
}, [t.loading, l]);
|
|
854
|
-
const y =
|
|
855
|
-
var
|
|
859
|
+
const y = v.filter((i) => !r.has(i.id)).filter((i) => {
|
|
860
|
+
var b;
|
|
856
861
|
if (!o) return !0;
|
|
857
|
-
const
|
|
858
|
-
return
|
|
862
|
+
const f = o.toLowerCase();
|
|
863
|
+
return i.name.toLowerCase().includes(f) || ((b = i.email) == null ? void 0 : b.toLowerCase().includes(f)) || !1;
|
|
859
864
|
}), T = P(
|
|
860
|
-
async (
|
|
861
|
-
if (!
|
|
862
|
-
k(
|
|
865
|
+
async (i) => {
|
|
866
|
+
if (!h) {
|
|
867
|
+
k(i.id);
|
|
863
868
|
try {
|
|
864
|
-
await s(
|
|
865
|
-
} catch (
|
|
866
|
-
console.error("[ParticipantPicker] Failed to start chat:",
|
|
869
|
+
await s(i);
|
|
870
|
+
} catch (f) {
|
|
871
|
+
console.error("[ParticipantPicker] Failed to start chat:", f), k(null);
|
|
867
872
|
}
|
|
868
873
|
}
|
|
869
874
|
},
|
|
870
|
-
[s,
|
|
871
|
-
), U = (
|
|
872
|
-
(
|
|
875
|
+
[s, h]
|
|
876
|
+
), U = (i, f) => {
|
|
877
|
+
(i.key === "Enter" || i.key === " ") && (i.preventDefault(), T(f));
|
|
873
878
|
};
|
|
874
|
-
return /* @__PURE__ */
|
|
875
|
-
/* @__PURE__ */
|
|
876
|
-
/* @__PURE__ */
|
|
879
|
+
return /* @__PURE__ */ u("div", { className: D("flex flex-col h-full", c), children: [
|
|
880
|
+
/* @__PURE__ */ u("div", { className: "px-4 py-4 border-b border-sand bg-chalk", children: [
|
|
881
|
+
/* @__PURE__ */ u("div", { className: "flex items-center justify-between mb-3", children: [
|
|
877
882
|
/* @__PURE__ */ e("h2", { className: "text-lg font-semibold text-charcoal", children: "Start a new Conversation" }),
|
|
878
883
|
/* @__PURE__ */ e(ge, { onClick: n })
|
|
879
884
|
] }),
|
|
880
|
-
/* @__PURE__ */
|
|
885
|
+
/* @__PURE__ */ u("p", { className: "text-xs text-stone mb-3", children: [
|
|
881
886
|
"Select a ",
|
|
882
887
|
a.slice(0, -1),
|
|
883
888
|
" to start messaging (",
|
|
@@ -890,77 +895,77 @@ const Xe = ({
|
|
|
890
895
|
{
|
|
891
896
|
searchQuery: o,
|
|
892
897
|
setSearchQuery: E,
|
|
893
|
-
placeholder:
|
|
898
|
+
placeholder: d
|
|
894
899
|
}
|
|
895
900
|
)
|
|
896
901
|
] }),
|
|
897
|
-
x && /* @__PURE__ */
|
|
902
|
+
x && /* @__PURE__ */ u("div", { className: "p-4 text-sm text-danger bg-danger-alt", children: [
|
|
898
903
|
"Error loading ",
|
|
899
904
|
a,
|
|
900
905
|
": ",
|
|
901
906
|
x
|
|
902
907
|
] }),
|
|
903
|
-
/* @__PURE__ */ e("div", { className: "flex-1 overflow-auto", children:
|
|
908
|
+
/* @__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
909
|
/* @__PURE__ */ e("div", { className: "w-4 h-4 animate-spin rounded-full border-2 border-primary border-t-transparent" }),
|
|
905
|
-
/* @__PURE__ */
|
|
910
|
+
/* @__PURE__ */ u("span", { className: "text-sm text-stone", children: [
|
|
906
911
|
"Loading ",
|
|
907
912
|
a,
|
|
908
913
|
"..."
|
|
909
914
|
] })
|
|
910
|
-
] }) }) : y.length === 0 ? /* @__PURE__ */
|
|
915
|
+
] }) }) : y.length === 0 ? /* @__PURE__ */ u("div", { className: "p-6 text-center", children: [
|
|
911
916
|
/* @__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
|
|
917
|
+
/* @__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` }),
|
|
918
|
+
/* @__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` })
|
|
919
|
+
] }) : /* @__PURE__ */ u("ul", { className: "space-y-0", children: [
|
|
920
|
+
y.map((i) => {
|
|
921
|
+
const f = i.name || i.email || i.id, b = i.email && i.name ? i.email : i.phone;
|
|
917
922
|
return /* @__PURE__ */ e("li", { children: /* @__PURE__ */ e(
|
|
918
923
|
"button",
|
|
919
924
|
{
|
|
920
925
|
type: "button",
|
|
921
|
-
onClick: () => T(
|
|
922
|
-
onKeyDown: (F) => U(F,
|
|
926
|
+
onClick: () => T(i),
|
|
927
|
+
onKeyDown: (F) => U(F, i),
|
|
923
928
|
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__ */
|
|
929
|
+
children: /* @__PURE__ */ u("div", { className: "flex items-center justify-between", children: [
|
|
930
|
+
/* @__PURE__ */ u("div", { className: "flex items-center space-x-3 flex-1 min-w-0", children: [
|
|
926
931
|
/* @__PURE__ */ e(
|
|
927
932
|
J,
|
|
928
933
|
{
|
|
929
|
-
id:
|
|
930
|
-
name:
|
|
931
|
-
image:
|
|
934
|
+
id: i.id,
|
|
935
|
+
name: f,
|
|
936
|
+
image: i.image,
|
|
932
937
|
size: 40
|
|
933
938
|
}
|
|
934
939
|
),
|
|
935
|
-
/* @__PURE__ */
|
|
936
|
-
/* @__PURE__ */ e("h4", { className: "text-sm font-medium text-charcoal truncate", children:
|
|
937
|
-
|
|
940
|
+
/* @__PURE__ */ u("div", { className: "flex-1 min-w-0", children: [
|
|
941
|
+
/* @__PURE__ */ e("h4", { className: "text-sm font-medium text-charcoal truncate", children: f }),
|
|
942
|
+
b && /* @__PURE__ */ e("p", { className: "text-xs text-stone truncate", children: b })
|
|
938
943
|
] })
|
|
939
944
|
] }),
|
|
940
|
-
/* @__PURE__ */ e("div", { className: "flex-shrink-0", children:
|
|
945
|
+
/* @__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
946
|
] })
|
|
942
947
|
}
|
|
943
|
-
) },
|
|
948
|
+
) }, i.id);
|
|
944
949
|
}),
|
|
945
|
-
|
|
950
|
+
g && /* @__PURE__ */ e("li", { className: "p-4 flex justify-center", children: /* @__PURE__ */ u("div", { className: "flex items-center space-x-2", children: [
|
|
946
951
|
/* @__PURE__ */ e("div", { className: "w-4 h-4 animate-spin rounded-full border-2 border-primary border-t-transparent" }),
|
|
947
952
|
/* @__PURE__ */ e("span", { className: "text-sm text-stone", children: "Loading more..." })
|
|
948
953
|
] }) })
|
|
949
954
|
] }) })
|
|
950
955
|
] });
|
|
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__ */
|
|
956
|
+
}, 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
957
|
/* @__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
958
|
/* @__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__ */
|
|
959
|
+
/* @__PURE__ */ e("p", { className: "text-stone text-sm mb-6", children: t ? /* @__PURE__ */ u(le, { children: [
|
|
955
960
|
"Choose a conversation from the list or",
|
|
956
961
|
" ",
|
|
957
|
-
s && /* @__PURE__ */
|
|
962
|
+
s && /* @__PURE__ */ u(ue, { onClick: s, children: [
|
|
958
963
|
"start a new conversation with a ",
|
|
959
964
|
n.slice(0, -1),
|
|
960
965
|
"."
|
|
961
966
|
] })
|
|
962
|
-
] }) : s && /* @__PURE__ */
|
|
963
|
-
/* @__PURE__ */
|
|
967
|
+
] }) : s && /* @__PURE__ */ u(le, { children: [
|
|
968
|
+
/* @__PURE__ */ u(ue, { onClick: s, children: [
|
|
964
969
|
"Start a new conversation with one of your ",
|
|
965
970
|
n
|
|
966
971
|
] }),
|
|
@@ -978,7 +983,7 @@ const Xe = ({
|
|
|
978
983
|
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
984
|
children: s
|
|
980
985
|
}
|
|
981
|
-
), re = ({ message: t, onBack: s }) => /* @__PURE__ */ e("div", { className: "messaging-error-state flex items-center justify-center h-full p-8", children: /* @__PURE__ */
|
|
986
|
+
), 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
987
|
/* @__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
988
|
/* @__PURE__ */ e("h2", { className: "font-semibold text-charcoal mb-2", children: "Oops!" }),
|
|
984
989
|
/* @__PURE__ */ e("p", { className: "text-stone text-sm mb-6", children: t }),
|
|
@@ -991,12 +996,12 @@ const Xe = ({
|
|
|
991
996
|
children: "Go Back"
|
|
992
997
|
}
|
|
993
998
|
)
|
|
994
|
-
] }) }), Ke = ({ className: t, message: s }) => /* @__PURE__ */
|
|
999
|
+
] }) }), Ke = ({ className: t, message: s }) => /* @__PURE__ */ u(
|
|
995
1000
|
"div",
|
|
996
1001
|
{
|
|
997
1002
|
className: D("flex items-center justify-center h-full", t),
|
|
998
1003
|
children: [
|
|
999
|
-
/* @__PURE__ */
|
|
1004
|
+
/* @__PURE__ */ u("svg", { viewBox: "0 0 100 100", className: "size-8 fill-pebble", stroke: "none", children: [
|
|
1000
1005
|
/* @__PURE__ */ e("circle", { cx: "6", cy: "50", r: "6", children: /* @__PURE__ */ e(
|
|
1001
1006
|
"animateTransform",
|
|
1002
1007
|
{
|
|
@@ -1034,7 +1039,7 @@ const Xe = ({
|
|
|
1034
1039
|
s && /* @__PURE__ */ e("span", { className: "text-stone", children: s })
|
|
1035
1040
|
]
|
|
1036
1041
|
}
|
|
1037
|
-
), es = () => /* @__PURE__ */ e("div", { className: "messaging-loading-state flex items-center justify-center h-full", children: /* @__PURE__ */
|
|
1042
|
+
), 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
1043
|
/* @__PURE__ */ e(Ke, { className: "w-6 h-6" }),
|
|
1039
1044
|
/* @__PURE__ */ e("span", { className: "text-sm text-stone", children: "Loading messages" })
|
|
1040
1045
|
] }) }), cs = ({
|
|
@@ -1043,26 +1048,26 @@ const Xe = ({
|
|
|
1043
1048
|
renderMessageInputActions: n,
|
|
1044
1049
|
onChannelSelect: r,
|
|
1045
1050
|
onParticipantSelect: a,
|
|
1046
|
-
initialParticipantFilter:
|
|
1047
|
-
initialParticipantData:
|
|
1051
|
+
initialParticipantFilter: d,
|
|
1052
|
+
initialParticipantData: c,
|
|
1048
1053
|
CustomChannelEmptyState: l,
|
|
1049
1054
|
showChannelList: o = !0,
|
|
1050
1055
|
filters: E
|
|
1051
1056
|
}) => {
|
|
1052
1057
|
const {
|
|
1053
|
-
service:
|
|
1054
|
-
client:
|
|
1055
|
-
isConnected:
|
|
1056
|
-
isLoading:
|
|
1058
|
+
service: v,
|
|
1059
|
+
client: m,
|
|
1060
|
+
isConnected: g,
|
|
1061
|
+
isLoading: R,
|
|
1057
1062
|
error: x,
|
|
1058
|
-
refreshConnection:
|
|
1059
|
-
debug:
|
|
1060
|
-
} =
|
|
1063
|
+
refreshConnection: C,
|
|
1064
|
+
debug: h
|
|
1065
|
+
} = _e(), [k, I] = w(null), [y, T] = w(!1), [U, i] = w(!1), [f, b] = w(/* @__PURE__ */ new Set()), [F, z] = w(0), [M, B] = w(!1), [Y, H] = w(null), V = $(null), {
|
|
1061
1066
|
showStartConversation: Q = !1,
|
|
1062
1067
|
participantSource: W,
|
|
1063
|
-
participantLabel:
|
|
1064
|
-
} = t,
|
|
1065
|
-
const N =
|
|
1068
|
+
participantLabel: S = "participants"
|
|
1069
|
+
} = t, O = q.useMemo(() => {
|
|
1070
|
+
const N = m == null ? void 0 : m.userID;
|
|
1066
1071
|
return {
|
|
1067
1072
|
...{
|
|
1068
1073
|
type: "messaging",
|
|
@@ -1074,164 +1079,164 @@ const Xe = ({
|
|
|
1074
1079
|
},
|
|
1075
1080
|
...E
|
|
1076
1081
|
};
|
|
1077
|
-
}, [E,
|
|
1078
|
-
if (!
|
|
1079
|
-
const N =
|
|
1082
|
+
}, [E, m == null ? void 0 : m.userID]), j = $(null), _ = P(async () => {
|
|
1083
|
+
if (!m || !g) return;
|
|
1084
|
+
const N = m.userID;
|
|
1080
1085
|
if (N)
|
|
1081
1086
|
try {
|
|
1082
|
-
|
|
1083
|
-
const L = await
|
|
1087
|
+
h && console.log("[MessagingShell] Syncing channels for user:", N);
|
|
1088
|
+
const L = await m.queryChannels(
|
|
1084
1089
|
{
|
|
1085
1090
|
type: "messaging",
|
|
1086
1091
|
members: { $in: [N] }
|
|
1087
1092
|
},
|
|
1088
1093
|
{},
|
|
1089
1094
|
{ limit: 100 }
|
|
1090
|
-
),
|
|
1091
|
-
L.forEach((
|
|
1092
|
-
const Ee =
|
|
1095
|
+
), p = /* @__PURE__ */ new Set();
|
|
1096
|
+
L.forEach((A) => {
|
|
1097
|
+
const Ee = A.state.members;
|
|
1093
1098
|
Object.values(Ee).forEach((ye) => {
|
|
1094
1099
|
var ae;
|
|
1095
1100
|
const te = (ae = ye.user) == null ? void 0 : ae.id;
|
|
1096
|
-
te && te !== N &&
|
|
1101
|
+
te && te !== N && p.add(te);
|
|
1097
1102
|
});
|
|
1098
|
-
}),
|
|
1103
|
+
}), b(p), T(L.length > 0), j.current = N, h && console.log("[MessagingShell] Channels synced successfully:", {
|
|
1099
1104
|
channelCount: L.length,
|
|
1100
|
-
memberCount:
|
|
1105
|
+
memberCount: p.size
|
|
1101
1106
|
});
|
|
1102
1107
|
} catch (L) {
|
|
1103
1108
|
console.error("[MessagingShell] Failed to sync channels:", L);
|
|
1104
1109
|
}
|
|
1105
|
-
}, [
|
|
1106
|
-
|
|
1107
|
-
if (!
|
|
1108
|
-
const N =
|
|
1109
|
-
N && j.current !== N &&
|
|
1110
|
-
}, [
|
|
1111
|
-
if (!
|
|
1110
|
+
}, [m, g, h]);
|
|
1111
|
+
G(() => {
|
|
1112
|
+
if (!m || !g) return;
|
|
1113
|
+
const N = m.userID;
|
|
1114
|
+
N && j.current !== N && _();
|
|
1115
|
+
}, [m, g, _]), G(() => {
|
|
1116
|
+
if (!d || !m || !g) return;
|
|
1112
1117
|
(async () => {
|
|
1113
|
-
const L =
|
|
1118
|
+
const L = m.userID;
|
|
1114
1119
|
if (L)
|
|
1115
1120
|
try {
|
|
1116
|
-
|
|
1121
|
+
h && console.log(
|
|
1117
1122
|
"[MessagingShell] Loading initial conversation with:",
|
|
1118
|
-
|
|
1123
|
+
d
|
|
1119
1124
|
);
|
|
1120
|
-
const
|
|
1125
|
+
const p = await m.queryChannels(
|
|
1121
1126
|
{
|
|
1122
1127
|
type: "messaging",
|
|
1123
|
-
members: { $eq: [L,
|
|
1128
|
+
members: { $eq: [L, d] }
|
|
1124
1129
|
},
|
|
1125
1130
|
{},
|
|
1126
1131
|
{ limit: 1 }
|
|
1127
1132
|
);
|
|
1128
|
-
if (
|
|
1129
|
-
|
|
1133
|
+
if (p.length > 0)
|
|
1134
|
+
I(p[0]), B(!0), H(null), r && r(p[0]), h && console.log(
|
|
1130
1135
|
"[MessagingShell] Initial conversation loaded:",
|
|
1131
|
-
|
|
1136
|
+
p[0].id
|
|
1132
1137
|
);
|
|
1133
|
-
else if (
|
|
1134
|
-
|
|
1138
|
+
else if (c && v) {
|
|
1139
|
+
h && console.log(
|
|
1135
1140
|
"[MessagingShell] No conversation found, creating one for:",
|
|
1136
|
-
|
|
1141
|
+
c
|
|
1137
1142
|
);
|
|
1138
1143
|
try {
|
|
1139
|
-
const
|
|
1140
|
-
id:
|
|
1141
|
-
name:
|
|
1142
|
-
email:
|
|
1143
|
-
phone:
|
|
1144
|
+
const A = await v.startChannelWithParticipant({
|
|
1145
|
+
id: c.id,
|
|
1146
|
+
name: c.name,
|
|
1147
|
+
email: c.email,
|
|
1148
|
+
phone: c.phone
|
|
1144
1149
|
});
|
|
1145
|
-
|
|
1150
|
+
I(A), B(!0), H(null), r && r(A), h && console.log(
|
|
1146
1151
|
"[MessagingShell] Channel created and loaded:",
|
|
1147
|
-
|
|
1152
|
+
A.id
|
|
1148
1153
|
);
|
|
1149
|
-
} catch (
|
|
1154
|
+
} catch (A) {
|
|
1150
1155
|
console.error(
|
|
1151
1156
|
"[MessagingShell] Failed to create conversation:",
|
|
1152
|
-
|
|
1153
|
-
),
|
|
1157
|
+
A
|
|
1158
|
+
), H("Failed to create conversation");
|
|
1154
1159
|
}
|
|
1155
1160
|
} else
|
|
1156
|
-
|
|
1161
|
+
H(
|
|
1157
1162
|
"No conversation found with this account"
|
|
1158
|
-
),
|
|
1163
|
+
), h && console.log(
|
|
1159
1164
|
"[MessagingShell] No conversation found for:",
|
|
1160
|
-
|
|
1165
|
+
d
|
|
1161
1166
|
);
|
|
1162
|
-
} catch (
|
|
1167
|
+
} catch (p) {
|
|
1163
1168
|
console.error(
|
|
1164
1169
|
"[MessagingShell] Failed to load initial conversation:",
|
|
1165
|
-
|
|
1166
|
-
),
|
|
1170
|
+
p
|
|
1171
|
+
), H("Failed to load conversation");
|
|
1167
1172
|
}
|
|
1168
1173
|
})();
|
|
1169
1174
|
}, [
|
|
1175
|
+
d,
|
|
1170
1176
|
c,
|
|
1171
|
-
i,
|
|
1172
|
-
u,
|
|
1173
|
-
f,
|
|
1174
|
-
b,
|
|
1175
1177
|
m,
|
|
1178
|
+
g,
|
|
1179
|
+
v,
|
|
1180
|
+
h,
|
|
1176
1181
|
r
|
|
1177
1182
|
]);
|
|
1178
1183
|
const X = P(
|
|
1179
1184
|
(N) => {
|
|
1180
|
-
|
|
1185
|
+
I(N), r == null || r(N);
|
|
1181
1186
|
},
|
|
1182
1187
|
[r]
|
|
1183
1188
|
), Ne = P(() => {
|
|
1184
|
-
M ||
|
|
1189
|
+
M || I(null);
|
|
1185
1190
|
}, [M]), be = P(() => {
|
|
1186
1191
|
var N;
|
|
1187
|
-
W && (z((L) => L + 1),
|
|
1192
|
+
W && (z((L) => L + 1), i(!0), (N = V.current) == null || N.showModal());
|
|
1188
1193
|
}, [W]), ve = P(
|
|
1189
1194
|
async (N) => {
|
|
1190
1195
|
var L;
|
|
1191
|
-
if (
|
|
1196
|
+
if (v)
|
|
1192
1197
|
try {
|
|
1193
|
-
|
|
1198
|
+
h && console.log(
|
|
1194
1199
|
"[MessagingShell] Starting conversation with:",
|
|
1195
1200
|
N.id
|
|
1196
1201
|
);
|
|
1197
|
-
const
|
|
1202
|
+
const p = await v.startChannelWithParticipant({
|
|
1198
1203
|
id: N.id,
|
|
1199
1204
|
name: N.name,
|
|
1200
1205
|
email: N.email,
|
|
1201
1206
|
phone: N.phone
|
|
1202
1207
|
});
|
|
1203
1208
|
try {
|
|
1204
|
-
await
|
|
1205
|
-
} catch (
|
|
1206
|
-
console.warn("[MessagingShell] Failed to unhide channel:",
|
|
1209
|
+
await p.show();
|
|
1210
|
+
} catch (A) {
|
|
1211
|
+
console.warn("[MessagingShell] Failed to unhide channel:", A);
|
|
1207
1212
|
}
|
|
1208
|
-
|
|
1209
|
-
} catch (
|
|
1210
|
-
console.error("[MessagingShell] Failed to start conversation:",
|
|
1213
|
+
I(p), i(!1), (L = V.current) == null || L.close(), a == null || a(N);
|
|
1214
|
+
} catch (p) {
|
|
1215
|
+
console.error("[MessagingShell] Failed to start conversation:", p);
|
|
1211
1216
|
}
|
|
1212
1217
|
},
|
|
1213
|
-
[
|
|
1218
|
+
[v, a, h]
|
|
1214
1219
|
), ne = P(() => {
|
|
1215
1220
|
var N;
|
|
1216
|
-
|
|
1221
|
+
i(!1), (N = V.current) == null || N.close();
|
|
1217
1222
|
}, []), Ce = P(
|
|
1218
1223
|
async (N) => {
|
|
1219
|
-
|
|
1224
|
+
h && console.log("[MessagingShell] Leaving conversation:", N.id), I(null), B(!1), j.current = null, await _();
|
|
1220
1225
|
},
|
|
1221
|
-
[
|
|
1226
|
+
[_, h]
|
|
1222
1227
|
), we = P(
|
|
1223
1228
|
async (N) => {
|
|
1224
|
-
|
|
1229
|
+
h && console.log("[MessagingShell] Blocking participant:", N), I(null), B(!1), j.current = null, await _();
|
|
1225
1230
|
},
|
|
1226
|
-
[
|
|
1231
|
+
[_, h]
|
|
1227
1232
|
), Z = !!k;
|
|
1228
|
-
return
|
|
1233
|
+
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
1234
|
re,
|
|
1230
1235
|
{
|
|
1231
1236
|
message: "Not connected to messaging service",
|
|
1232
|
-
onBack:
|
|
1237
|
+
onBack: C
|
|
1233
1238
|
}
|
|
1234
|
-
) }) : Y ? /* @__PURE__ */ e("div", { className: D("h-full", s), children: /* @__PURE__ */ e(re, { message: Y }) }) : /* @__PURE__ */
|
|
1239
|
+
) }) : Y ? /* @__PURE__ */ e("div", { className: D("h-full", s), children: /* @__PURE__ */ e(re, { message: Y }) }) : /* @__PURE__ */ u(
|
|
1235
1240
|
"div",
|
|
1236
1241
|
{
|
|
1237
1242
|
className: D(
|
|
@@ -1239,7 +1244,7 @@ const Xe = ({
|
|
|
1239
1244
|
s
|
|
1240
1245
|
),
|
|
1241
1246
|
children: [
|
|
1242
|
-
/* @__PURE__ */
|
|
1247
|
+
/* @__PURE__ */ u("div", { className: "flex h-full min-h-0", children: [
|
|
1243
1248
|
/* @__PURE__ */ e(
|
|
1244
1249
|
"div",
|
|
1245
1250
|
{
|
|
@@ -1259,7 +1264,7 @@ const Xe = ({
|
|
|
1259
1264
|
{
|
|
1260
1265
|
onChannelSelect: X,
|
|
1261
1266
|
selectedChannel: k || void 0,
|
|
1262
|
-
filters:
|
|
1267
|
+
filters: O
|
|
1263
1268
|
}
|
|
1264
1269
|
)
|
|
1265
1270
|
}
|
|
@@ -1293,7 +1298,7 @@ const Xe = ({
|
|
|
1293
1298
|
{
|
|
1294
1299
|
hasChannels: y,
|
|
1295
1300
|
onStartConversation: Q ? be : void 0,
|
|
1296
|
-
participantLabel:
|
|
1301
|
+
participantLabel: S
|
|
1297
1302
|
}
|
|
1298
1303
|
)
|
|
1299
1304
|
}
|
|
@@ -1315,9 +1320,9 @@ const Xe = ({
|
|
|
1315
1320
|
participantSource: W,
|
|
1316
1321
|
onSelectParticipant: ve,
|
|
1317
1322
|
onClose: ne,
|
|
1318
|
-
existingParticipantIds:
|
|
1319
|
-
participantLabel:
|
|
1320
|
-
searchPlaceholder: `Search ${
|
|
1323
|
+
existingParticipantIds: f,
|
|
1324
|
+
participantLabel: S,
|
|
1325
|
+
searchPlaceholder: `Search ${S}...`
|
|
1321
1326
|
},
|
|
1322
1327
|
F
|
|
1323
1328
|
) })
|
|
@@ -1354,21 +1359,21 @@ const Xe = ({
|
|
|
1354
1359
|
loadingFaqId: n,
|
|
1355
1360
|
headerText: r,
|
|
1356
1361
|
className: a,
|
|
1357
|
-
avatarImage:
|
|
1358
|
-
avatarName:
|
|
1362
|
+
avatarImage: d,
|
|
1363
|
+
avatarName: c
|
|
1359
1364
|
}) => {
|
|
1360
1365
|
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
|
-
(
|
|
1366
|
+
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: [
|
|
1367
|
+
(d || c) && /* @__PURE__ */ e("div", { className: "flex-none", children: /* @__PURE__ */ e(
|
|
1363
1368
|
J,
|
|
1364
1369
|
{
|
|
1365
|
-
id:
|
|
1366
|
-
name:
|
|
1367
|
-
image:
|
|
1370
|
+
id: c || "account",
|
|
1371
|
+
name: c || "Account",
|
|
1372
|
+
image: d,
|
|
1368
1373
|
size: 24
|
|
1369
1374
|
}
|
|
1370
1375
|
) }),
|
|
1371
|
-
/* @__PURE__ */
|
|
1376
|
+
/* @__PURE__ */ u(
|
|
1372
1377
|
"div",
|
|
1373
1378
|
{
|
|
1374
1379
|
className: "flex-1 rounded-lg p-4 space-y-3",
|
|
@@ -1389,43 +1394,43 @@ const Xe = ({
|
|
|
1389
1394
|
)
|
|
1390
1395
|
] }) });
|
|
1391
1396
|
}, us = (t, s = {}) => {
|
|
1392
|
-
const { initialSearch: n = "", pageSize: r = 20 } = s, [a,
|
|
1393
|
-
if (
|
|
1394
|
-
const
|
|
1397
|
+
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) => {
|
|
1398
|
+
if (c) return;
|
|
1399
|
+
const i = U !== void 0 ? U : v;
|
|
1395
1400
|
l(!0), E(null);
|
|
1396
1401
|
try {
|
|
1397
|
-
const
|
|
1398
|
-
search:
|
|
1402
|
+
const f = await t.loadParticipants({
|
|
1403
|
+
search: i || void 0,
|
|
1399
1404
|
limit: r,
|
|
1400
1405
|
cursor: T ? void 0 : x
|
|
1401
1406
|
});
|
|
1402
|
-
|
|
1403
|
-
(
|
|
1404
|
-
),
|
|
1405
|
-
} catch (
|
|
1406
|
-
const
|
|
1407
|
-
E(
|
|
1407
|
+
d(
|
|
1408
|
+
(b) => T ? f.participants : [...b, ...f.participants]
|
|
1409
|
+
), R(f.hasMore), C(f.nextCursor);
|
|
1410
|
+
} catch (f) {
|
|
1411
|
+
const b = f instanceof Error ? f.message : "Failed to load participants";
|
|
1412
|
+
E(b), console.error("[useParticipants] Load error:", f);
|
|
1408
1413
|
} finally {
|
|
1409
1414
|
l(!1);
|
|
1410
1415
|
}
|
|
1411
|
-
}, [t,
|
|
1412
|
-
|
|
1413
|
-
}, [
|
|
1414
|
-
|
|
1415
|
-
}, [
|
|
1416
|
-
|
|
1417
|
-
}, [
|
|
1418
|
-
return
|
|
1419
|
-
|
|
1416
|
+
}, [t, v, x, r, c]), k = P(() => {
|
|
1417
|
+
g && !c && h(!1);
|
|
1418
|
+
}, [g, c, h]), I = P((T) => {
|
|
1419
|
+
m(T), C(void 0), h(!0, T);
|
|
1420
|
+
}, [h]), y = P(() => {
|
|
1421
|
+
C(void 0), h(!0);
|
|
1422
|
+
}, [h]);
|
|
1423
|
+
return G(() => {
|
|
1424
|
+
h(!0);
|
|
1420
1425
|
}, [t.loadParticipants]), {
|
|
1421
1426
|
participants: a,
|
|
1422
|
-
loading:
|
|
1427
|
+
loading: c,
|
|
1423
1428
|
error: o,
|
|
1424
|
-
searchQuery:
|
|
1425
|
-
hasMore:
|
|
1429
|
+
searchQuery: v,
|
|
1430
|
+
hasMore: g,
|
|
1426
1431
|
totalCount: t.totalCount,
|
|
1427
1432
|
loadMore: k,
|
|
1428
|
-
search:
|
|
1433
|
+
search: I,
|
|
1429
1434
|
refresh: y
|
|
1430
1435
|
};
|
|
1431
1436
|
};
|
|
@@ -1439,8 +1444,8 @@ export {
|
|
|
1439
1444
|
is as MessagingProvider,
|
|
1440
1445
|
cs as MessagingShell,
|
|
1441
1446
|
Xe as ParticipantPicker,
|
|
1442
|
-
|
|
1443
|
-
|
|
1447
|
+
Ae as formatRelativeTime,
|
|
1448
|
+
_e as useMessaging,
|
|
1444
1449
|
us as useParticipants
|
|
1445
1450
|
};
|
|
1446
1451
|
//# sourceMappingURL=index.js.map
|