@realtimexsco/live-chat 1.3.4 → 1.4.0
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.cjs +980 -292
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +69 -1
- package/dist/index.d.ts +69 -1
- package/dist/index.mjs +955 -294
- package/dist/index.mjs.map +1 -1
- package/dist/styles.css +93 -59
- package/package.json +5 -3
package/dist/index.cjs
CHANGED
|
@@ -15,12 +15,31 @@ var reactDom = require('react-dom');
|
|
|
15
15
|
var lucideReact = require('lucide-react');
|
|
16
16
|
var classVarianceAuthority = require('class-variance-authority');
|
|
17
17
|
var EmojiPicker = require('emoji-picker-react');
|
|
18
|
+
var reactDayPicker = require('react-day-picker');
|
|
18
19
|
var reactHotToast = require('react-hot-toast');
|
|
19
20
|
|
|
20
21
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
21
22
|
|
|
23
|
+
function _interopNamespace(e) {
|
|
24
|
+
if (e && e.__esModule) return e;
|
|
25
|
+
var n = Object.create(null);
|
|
26
|
+
if (e) {
|
|
27
|
+
Object.keys(e).forEach(function (k) {
|
|
28
|
+
if (k !== 'default') {
|
|
29
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
30
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
31
|
+
enumerable: true,
|
|
32
|
+
get: function () { return e[k]; }
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
n.default = e;
|
|
38
|
+
return Object.freeze(n);
|
|
39
|
+
}
|
|
40
|
+
|
|
22
41
|
var axios__default = /*#__PURE__*/_interopDefault(axios);
|
|
23
|
-
var
|
|
42
|
+
var React2__namespace = /*#__PURE__*/_interopNamespace(React2);
|
|
24
43
|
var EmojiPicker__default = /*#__PURE__*/_interopDefault(EmojiPicker);
|
|
25
44
|
|
|
26
45
|
var __defProp = Object.defineProperty;
|
|
@@ -570,7 +589,7 @@ var init_message_helpers = __esm({
|
|
|
570
589
|
"src/store/helpers/message.helpers.ts"() {
|
|
571
590
|
getMessageSenderId = (message) => String(message?.sender?._id || message?.sender?.id || message?.senderId || message?.fromUserId || message?.sender || "");
|
|
572
591
|
extractMessageData = (payload) => {
|
|
573
|
-
const
|
|
592
|
+
const messageId2 = payload.messageId || payload._id || payload.message?._id || payload.message?.id;
|
|
574
593
|
const content = payload.content || payload.message?.content;
|
|
575
594
|
const conversationId = payload.conversationId || payload.conversation_id || payload.message?.conversationId || payload.message?.conversation_id;
|
|
576
595
|
const status = payload.status || payload.message?.status;
|
|
@@ -578,7 +597,7 @@ var init_message_helpers = __esm({
|
|
|
578
597
|
const isStarred = payload.isStarred ?? payload.message?.isStarred;
|
|
579
598
|
const attachmentId = payload.attachmentId || payload.unpinAttachmentId || null;
|
|
580
599
|
const caption = payload.caption ?? payload.message?.caption ?? null;
|
|
581
|
-
return { messageId, content, conversationId, status, isPinned, isStarred, attachmentId, caption };
|
|
600
|
+
return { messageId: messageId2, content, conversationId, status, isPinned, isStarred, attachmentId, caption };
|
|
582
601
|
};
|
|
583
602
|
statusRank = { sent: 0, delivered: 1, read: 2 };
|
|
584
603
|
preferHigherStatus = (base, incoming) => {
|
|
@@ -809,15 +828,15 @@ var init_conversation_helpers = __esm({
|
|
|
809
828
|
init_message_helpers();
|
|
810
829
|
init_participant_helpers();
|
|
811
830
|
init_unread_helpers();
|
|
812
|
-
findConversationIdByMessageId = (messagesByConversation,
|
|
831
|
+
findConversationIdByMessageId = (messagesByConversation, messageId2) => {
|
|
813
832
|
return Object.keys(messagesByConversation).find(
|
|
814
833
|
(cid) => messagesByConversation[cid].some(
|
|
815
|
-
(m) => String(m._id || m.id) === String(
|
|
834
|
+
(m) => String(m._id || m.id) === String(messageId2)
|
|
816
835
|
)
|
|
817
836
|
);
|
|
818
837
|
};
|
|
819
|
-
applyMessageStatusToStore = (state,
|
|
820
|
-
const normalizedMessageId = String(
|
|
838
|
+
applyMessageStatusToStore = (state, messageId2, status, conversationId) => {
|
|
839
|
+
const normalizedMessageId = String(messageId2);
|
|
821
840
|
const resolvedConversationId = conversationId ? String(conversationId) : findConversationIdByMessageId(state.messagesByConversation, normalizedMessageId) || findConversationIdByLastMessageId(state.conversations, normalizedMessageId) || null;
|
|
822
841
|
const nextConversations = state.conversations.map((conversation) => {
|
|
823
842
|
const lastMessageId = String(
|
|
@@ -945,9 +964,9 @@ var init_conversation_helpers = __esm({
|
|
|
945
964
|
if (!conversationId) return void 0;
|
|
946
965
|
return conversations.find((c) => String(c._id) === String(conversationId));
|
|
947
966
|
};
|
|
948
|
-
findConversationIdByLastMessageId = (conversations,
|
|
949
|
-
if (!
|
|
950
|
-
const normalizedMessageId = String(
|
|
967
|
+
findConversationIdByLastMessageId = (conversations, messageId2) => {
|
|
968
|
+
if (!messageId2) return null;
|
|
969
|
+
const normalizedMessageId = String(messageId2);
|
|
951
970
|
const match = conversations.find(
|
|
952
971
|
(conversation) => String(conversation?.lastMessage?._id || conversation?.lastMessage?.id || "") === normalizedMessageId
|
|
953
972
|
);
|
|
@@ -1366,7 +1385,7 @@ var init_api_constants = __esm({
|
|
|
1366
1385
|
ADD_REMOVE_MEMBERS: "/conversation/group/participants/add-remove",
|
|
1367
1386
|
ADD_REMOVE_ADMINS: "/conversation/group/admins/add-remove",
|
|
1368
1387
|
SEARCH_MESSAGES: "/message/search-messages",
|
|
1369
|
-
SEARCH_MESSAGES_CONTEXT: (
|
|
1388
|
+
SEARCH_MESSAGES_CONTEXT: (messageId2) => `/message/searched-message/context?messageId=${messageId2}`,
|
|
1370
1389
|
BLOCK_UNBLOCK_USER: "/user/block-unblock"
|
|
1371
1390
|
}
|
|
1372
1391
|
};
|
|
@@ -1510,9 +1529,9 @@ var init_messages_api = __esm({
|
|
|
1510
1529
|
throw error;
|
|
1511
1530
|
}
|
|
1512
1531
|
};
|
|
1513
|
-
searchMessagesContext = async (
|
|
1532
|
+
searchMessagesContext = async (messageId2) => {
|
|
1514
1533
|
try {
|
|
1515
|
-
const response = await apiClient.get(API_ENDPOINTS.GROUP.SEARCH_MESSAGES_CONTEXT(
|
|
1534
|
+
const response = await apiClient.get(API_ENDPOINTS.GROUP.SEARCH_MESSAGES_CONTEXT(messageId2));
|
|
1516
1535
|
return response.data;
|
|
1517
1536
|
} catch (error) {
|
|
1518
1537
|
console.error("Search messages context failed:", error);
|
|
@@ -1638,24 +1657,24 @@ var init_forwardPending_store = __esm({
|
|
|
1638
1657
|
"src/store/forwardPending.store.ts"() {
|
|
1639
1658
|
pendingForwards = /* @__PURE__ */ new Map();
|
|
1640
1659
|
lastPendingMessageId = null;
|
|
1641
|
-
setPendingForward = (
|
|
1642
|
-
if (!
|
|
1643
|
-
const key = String(
|
|
1660
|
+
setPendingForward = (messageId2, meta) => {
|
|
1661
|
+
if (!messageId2) return;
|
|
1662
|
+
const key = String(messageId2);
|
|
1644
1663
|
pendingForwards.set(key, meta);
|
|
1645
1664
|
lastPendingMessageId = key;
|
|
1646
1665
|
};
|
|
1647
|
-
peekPendingForward = (
|
|
1648
|
-
if (!
|
|
1649
|
-
return pendingForwards.get(String(
|
|
1666
|
+
peekPendingForward = (messageId2) => {
|
|
1667
|
+
if (!messageId2) return void 0;
|
|
1668
|
+
return pendingForwards.get(String(messageId2));
|
|
1650
1669
|
};
|
|
1651
1670
|
peekMostRecentPendingForward = () => {
|
|
1652
1671
|
if (!lastPendingMessageId) return void 0;
|
|
1653
1672
|
return pendingForwards.get(lastPendingMessageId);
|
|
1654
1673
|
};
|
|
1655
1674
|
getLastPendingForwardMessageId = () => lastPendingMessageId;
|
|
1656
|
-
clearPendingForward = (
|
|
1657
|
-
if (
|
|
1658
|
-
const key = String(
|
|
1675
|
+
clearPendingForward = (messageId2) => {
|
|
1676
|
+
if (messageId2) {
|
|
1677
|
+
const key = String(messageId2);
|
|
1659
1678
|
pendingForwards.delete(key);
|
|
1660
1679
|
if (lastPendingMessageId === key) lastPendingMessageId = null;
|
|
1661
1680
|
return;
|
|
@@ -2125,14 +2144,14 @@ var init_group_reaction_handlers = __esm({
|
|
|
2125
2144
|
return Array.from(map.values());
|
|
2126
2145
|
};
|
|
2127
2146
|
handleGroupReactionAddReceive = (set, get, payload) => {
|
|
2128
|
-
const
|
|
2147
|
+
const messageId2 = payload.messageId || payload._id;
|
|
2129
2148
|
const conversationId = payload.conversationId;
|
|
2130
|
-
if (!
|
|
2149
|
+
if (!messageId2) return;
|
|
2131
2150
|
set((state) => {
|
|
2132
|
-
const cid = conversationId || findConversationIdByMessageId(state.messagesByConversation,
|
|
2151
|
+
const cid = conversationId || findConversationIdByMessageId(state.messagesByConversation, messageId2);
|
|
2133
2152
|
if (!cid) return state;
|
|
2134
2153
|
const messages = state.messagesByConversation[cid] || [];
|
|
2135
|
-
const idx = messages.findIndex((m) => String(m._id || m.id) === String(
|
|
2154
|
+
const idx = messages.findIndex((m) => String(m._id || m.id) === String(messageId2));
|
|
2136
2155
|
if (idx === -1) return state;
|
|
2137
2156
|
const nextMessages = [...messages];
|
|
2138
2157
|
const currentMsg = { ...nextMessages[idx] };
|
|
@@ -2150,20 +2169,20 @@ var init_group_reaction_handlers = __esm({
|
|
|
2150
2169
|
}
|
|
2151
2170
|
nextMessages[idx] = currentMsg;
|
|
2152
2171
|
return {
|
|
2153
|
-
lastReactionUpdate: { ...payload, messageId, action: "add", _v: Date.now() },
|
|
2172
|
+
lastReactionUpdate: { ...payload, messageId: messageId2, action: "add", _v: Date.now() },
|
|
2154
2173
|
messagesByConversation: { ...state.messagesByConversation, [cid]: nextMessages }
|
|
2155
2174
|
};
|
|
2156
2175
|
});
|
|
2157
2176
|
};
|
|
2158
2177
|
handleGroupReactionRemoveReceive = (set, get, payload) => {
|
|
2159
|
-
const
|
|
2178
|
+
const messageId2 = payload.messageId || payload._id;
|
|
2160
2179
|
const conversationId = payload.conversationId;
|
|
2161
|
-
if (!
|
|
2180
|
+
if (!messageId2) return;
|
|
2162
2181
|
set((state) => {
|
|
2163
|
-
const cid = conversationId || findConversationIdByMessageId(state.messagesByConversation,
|
|
2182
|
+
const cid = conversationId || findConversationIdByMessageId(state.messagesByConversation, messageId2);
|
|
2164
2183
|
if (!cid) return state;
|
|
2165
2184
|
const messages = state.messagesByConversation[cid] || [];
|
|
2166
|
-
const idx = messages.findIndex((m) => String(m._id || m.id) === String(
|
|
2185
|
+
const idx = messages.findIndex((m) => String(m._id || m.id) === String(messageId2));
|
|
2167
2186
|
if (idx === -1) return state;
|
|
2168
2187
|
const nextMessages = [...messages];
|
|
2169
2188
|
const currentMsg = { ...nextMessages[idx] };
|
|
@@ -2180,7 +2199,7 @@ var init_group_reaction_handlers = __esm({
|
|
|
2180
2199
|
}
|
|
2181
2200
|
nextMessages[idx] = currentMsg;
|
|
2182
2201
|
return {
|
|
2183
|
-
lastReactionUpdate: { ...payload, messageId, action: "remove", _v: Date.now() },
|
|
2202
|
+
lastReactionUpdate: { ...payload, messageId: messageId2, action: "remove", _v: Date.now() },
|
|
2184
2203
|
messagesByConversation: { ...state.messagesByConversation, [cid]: nextMessages }
|
|
2185
2204
|
};
|
|
2186
2205
|
});
|
|
@@ -2210,14 +2229,14 @@ function removeMessageAttachment(message, attachmentId) {
|
|
|
2210
2229
|
if (attachments.length === message.attachments.length) return message;
|
|
2211
2230
|
return { ...message, attachments };
|
|
2212
2231
|
}
|
|
2213
|
-
function pinKey(
|
|
2214
|
-
return attachmentId ? `${
|
|
2232
|
+
function pinKey(messageId2, attachmentId) {
|
|
2233
|
+
return attachmentId ? `${messageId2}:${attachmentId}` : String(messageId2);
|
|
2215
2234
|
}
|
|
2216
|
-
function matchesPinEntry(entry,
|
|
2235
|
+
function matchesPinEntry(entry, messageId2, attachmentId) {
|
|
2217
2236
|
const entryMessageId = String(
|
|
2218
2237
|
entry?.messageId?._id || entry?.messageId || entry?._id || entry?.id || ""
|
|
2219
2238
|
);
|
|
2220
|
-
if (entryMessageId !== String(
|
|
2239
|
+
if (entryMessageId !== String(messageId2)) return false;
|
|
2221
2240
|
const entryAttachmentId = entry?.attachmentId ? String(entry.attachmentId) : null;
|
|
2222
2241
|
const targetAttachmentId = attachmentId ? String(attachmentId) : null;
|
|
2223
2242
|
return entryAttachmentId === targetAttachmentId;
|
|
@@ -2232,13 +2251,13 @@ function applyPinnedListToMessages(messages, pinnedMessage) {
|
|
|
2232
2251
|
)
|
|
2233
2252
|
);
|
|
2234
2253
|
return messages.map((message) => {
|
|
2235
|
-
const
|
|
2236
|
-
const hasWholeMessagePin = pinnedKeys.has(pinKey(
|
|
2254
|
+
const messageId2 = String(message._id || message.id);
|
|
2255
|
+
const hasWholeMessagePin = pinnedKeys.has(pinKey(messageId2, null));
|
|
2237
2256
|
const attachments = (message.attachments || []).map((att) => {
|
|
2238
2257
|
const attId = getAttachmentId(att);
|
|
2239
2258
|
return {
|
|
2240
2259
|
...att,
|
|
2241
|
-
isPinned: attId ? pinnedKeys.has(pinKey(
|
|
2260
|
+
isPinned: attId ? pinnedKeys.has(pinKey(messageId2, attId)) : !!att.isPinned
|
|
2242
2261
|
};
|
|
2243
2262
|
});
|
|
2244
2263
|
return {
|
|
@@ -2300,13 +2319,13 @@ var init_pin_handlers = __esm({
|
|
|
2300
2319
|
});
|
|
2301
2320
|
return;
|
|
2302
2321
|
}
|
|
2303
|
-
const { messageId, conversationId, isPinned, attachmentId } = extractMessageData(payload);
|
|
2304
|
-
if (!
|
|
2322
|
+
const { messageId: messageId2, conversationId, isPinned, attachmentId } = extractMessageData(payload);
|
|
2323
|
+
if (!messageId2 || !conversationId) return;
|
|
2305
2324
|
set((state) => {
|
|
2306
|
-
const sid = conversationId || findConversationIdByMessageId(state.messagesByConversation,
|
|
2325
|
+
const sid = conversationId || findConversationIdByMessageId(state.messagesByConversation, messageId2);
|
|
2307
2326
|
if (!sid) return state;
|
|
2308
2327
|
const messages = state.messagesByConversation[sid] || [];
|
|
2309
|
-
const index = messages.findIndex((m) => String(m._id || m.id) === String(
|
|
2328
|
+
const index = messages.findIndex((m) => String(m._id || m.id) === String(messageId2));
|
|
2310
2329
|
let newMessagesByConversation = state.messagesByConversation;
|
|
2311
2330
|
const msg = index !== -1 ? messages[index] : null;
|
|
2312
2331
|
const wasPinned = attachmentId ? !!msg?.attachments?.some(
|
|
@@ -2328,9 +2347,9 @@ var init_pin_handlers = __esm({
|
|
|
2328
2347
|
const newPinnedByConv = { ...state.pinnedMessagesByConversation };
|
|
2329
2348
|
if (isPinned) {
|
|
2330
2349
|
const currentPinned = newPinnedByConv[sid] || [];
|
|
2331
|
-
if (!currentPinned.some((m) => matchesPinEntry(m,
|
|
2350
|
+
if (!currentPinned.some((m) => matchesPinEntry(m, messageId2, attachmentId || null))) {
|
|
2332
2351
|
const fullMsg = msg ? attachmentId ? {
|
|
2333
|
-
messageId,
|
|
2352
|
+
messageId: messageId2,
|
|
2334
2353
|
attachmentId,
|
|
2335
2354
|
attachment: msg.attachments?.find(
|
|
2336
2355
|
(att) => getAttachmentId(att) === String(attachmentId)
|
|
@@ -2342,7 +2361,7 @@ var init_pin_handlers = __esm({
|
|
|
2342
2361
|
}
|
|
2343
2362
|
} else {
|
|
2344
2363
|
newPinnedByConv[sid] = (newPinnedByConv[sid] || []).filter(
|
|
2345
|
-
(m) => !matchesPinEntry(m,
|
|
2364
|
+
(m) => !matchesPinEntry(m, messageId2, attachmentId || payload.unpinAttachmentId || null)
|
|
2346
2365
|
);
|
|
2347
2366
|
}
|
|
2348
2367
|
const conversation = get().conversations?.find((c) => String(c._id) === String(sid));
|
|
@@ -2357,8 +2376,8 @@ var init_pin_handlers = __esm({
|
|
|
2357
2376
|
pinnedCount = payload.totalCount;
|
|
2358
2377
|
}
|
|
2359
2378
|
const newPendingActions = { ...state.messagePendingActions };
|
|
2360
|
-
if (newPendingActions[
|
|
2361
|
-
delete newPendingActions[
|
|
2379
|
+
if (newPendingActions[messageId2]) {
|
|
2380
|
+
delete newPendingActions[messageId2];
|
|
2362
2381
|
}
|
|
2363
2382
|
return {
|
|
2364
2383
|
lastPinUpdate: payload,
|
|
@@ -2389,13 +2408,13 @@ var init_star_handlers = __esm({
|
|
|
2389
2408
|
init_attachment_helpers();
|
|
2390
2409
|
handleStarUpdate = (set, get, payload) => {
|
|
2391
2410
|
if (payload.starredBy && Array.isArray(payload.starredBy)) {
|
|
2392
|
-
const { messageId:
|
|
2411
|
+
const { messageId: messageId3, attachmentId } = extractMessageData(payload);
|
|
2393
2412
|
const { starredBy } = payload;
|
|
2394
|
-
if (!
|
|
2413
|
+
if (!messageId3) return;
|
|
2395
2414
|
set((state) => {
|
|
2396
|
-
const sid = payload.conversationId || findConversationIdByMessageId(state.messagesByConversation,
|
|
2415
|
+
const sid = payload.conversationId || findConversationIdByMessageId(state.messagesByConversation, messageId3);
|
|
2397
2416
|
const newPendingActions = { ...state.messagePendingActions };
|
|
2398
|
-
const pendingKey = String(
|
|
2417
|
+
const pendingKey = String(messageId3);
|
|
2399
2418
|
if (newPendingActions[pendingKey]) {
|
|
2400
2419
|
delete newPendingActions[pendingKey];
|
|
2401
2420
|
}
|
|
@@ -2405,7 +2424,7 @@ var init_star_handlers = __esm({
|
|
|
2405
2424
|
const loggedUserId = String(get().loggedUserDetails?._id || state.loggedUserDetails?._id || "");
|
|
2406
2425
|
const isStarred2 = starredBy.some((id) => String(id?._id || id) === loggedUserId) || loggedUserId === "" && starredBy.length > 0;
|
|
2407
2426
|
const messages = state.messagesByConversation[sid] || [];
|
|
2408
|
-
const index = messages.findIndex((m) => String(m._id || m.id) === String(
|
|
2427
|
+
const index = messages.findIndex((m) => String(m._id || m.id) === String(messageId3));
|
|
2409
2428
|
let newMessagesByConversation = state.messagesByConversation;
|
|
2410
2429
|
if (index !== -1) {
|
|
2411
2430
|
const newMessages = [...messages];
|
|
@@ -2432,9 +2451,9 @@ var init_star_handlers = __esm({
|
|
|
2432
2451
|
const newStarredByConv = { ...state.starredMessagesByConversation };
|
|
2433
2452
|
const currentStarred = newStarredByConv[sid] || [];
|
|
2434
2453
|
const exists = attachmentId ? currentStarred.some(
|
|
2435
|
-
(m) => m.isAttachment && String(m.messageId) === String(
|
|
2454
|
+
(m) => m.isAttachment && String(m.messageId) === String(messageId3) && String(m.attachmentId) === String(attachmentId)
|
|
2436
2455
|
) : currentStarred.some(
|
|
2437
|
-
(m) => !m.isAttachment && String(m.messageId?._id || m.messageId || m._id || m.id) === String(
|
|
2456
|
+
(m) => !m.isAttachment && String(m.messageId?._id || m.messageId || m._id || m.id) === String(messageId3)
|
|
2438
2457
|
);
|
|
2439
2458
|
const conversation = get().conversations?.find((c) => String(c._id) === String(sid));
|
|
2440
2459
|
const existingCount = state.liveConversationCounts[sid]?.starredCount ?? conversation?.starredCount ?? 0;
|
|
@@ -2442,21 +2461,21 @@ var init_star_handlers = __esm({
|
|
|
2442
2461
|
if (isStarred2 && !exists) {
|
|
2443
2462
|
const fullMessage = attachmentId ? {
|
|
2444
2463
|
_id: attachmentId,
|
|
2445
|
-
messageId:
|
|
2464
|
+
messageId: messageId3,
|
|
2446
2465
|
attachmentId,
|
|
2447
2466
|
isAttachment: true,
|
|
2448
2467
|
attachment: index !== -1 ? newMessagesByConversation[sid][index]?.attachments?.find(
|
|
2449
2468
|
(att) => getAttachmentId(att) === String(attachmentId)
|
|
2450
2469
|
) : payload.attachment,
|
|
2451
2470
|
createdAt: payload.createdAt || (/* @__PURE__ */ new Date()).toISOString()
|
|
2452
|
-
} : index !== -1 ? newMessagesByConversation[sid][index] : { ...payload, _id:
|
|
2471
|
+
} : index !== -1 ? newMessagesByConversation[sid][index] : { ...payload, _id: messageId3 };
|
|
2453
2472
|
newStarredByConv[sid] = [...currentStarred, fullMessage];
|
|
2454
2473
|
starredCount = existingCount + 1;
|
|
2455
2474
|
} else if (!isStarred2 && exists) {
|
|
2456
2475
|
newStarredByConv[sid] = attachmentId ? currentStarred.filter(
|
|
2457
|
-
(m) => !(m.isAttachment && String(m.messageId) === String(
|
|
2476
|
+
(m) => !(m.isAttachment && String(m.messageId) === String(messageId3) && String(m.attachmentId) === String(attachmentId))
|
|
2458
2477
|
) : currentStarred.filter(
|
|
2459
|
-
(m) => String(m.messageId?._id || m.messageId || m._id || m.id) !== String(
|
|
2478
|
+
(m) => String(m.messageId?._id || m.messageId || m._id || m.id) !== String(messageId3)
|
|
2460
2479
|
);
|
|
2461
2480
|
starredCount = Math.max(0, existingCount - 1);
|
|
2462
2481
|
}
|
|
@@ -2482,13 +2501,13 @@ var init_star_handlers = __esm({
|
|
|
2482
2501
|
});
|
|
2483
2502
|
return;
|
|
2484
2503
|
}
|
|
2485
|
-
const { messageId, isStarred, conversationId } = extractMessageData(payload);
|
|
2486
|
-
if (!
|
|
2504
|
+
const { messageId: messageId2, isStarred, conversationId } = extractMessageData(payload);
|
|
2505
|
+
if (!messageId2) return;
|
|
2487
2506
|
set((state) => {
|
|
2488
|
-
const sid = conversationId || findConversationIdByMessageId(state.messagesByConversation,
|
|
2507
|
+
const sid = conversationId || findConversationIdByMessageId(state.messagesByConversation, messageId2);
|
|
2489
2508
|
if (!sid) return { lastStarUpdate: payload };
|
|
2490
2509
|
const messages = state.messagesByConversation[sid] || [];
|
|
2491
|
-
const index = messages.findIndex((m) => String(m._id || m.id) === String(
|
|
2510
|
+
const index = messages.findIndex((m) => String(m._id || m.id) === String(messageId2));
|
|
2492
2511
|
let newMessagesByConversation = state.messagesByConversation;
|
|
2493
2512
|
const msg = index !== -1 ? messages[index] : null;
|
|
2494
2513
|
const wasStarred = msg ? !!msg.isStarred : false;
|
|
@@ -2504,13 +2523,13 @@ var init_star_handlers = __esm({
|
|
|
2504
2523
|
const newStarredByConv = { ...state.starredMessagesByConversation };
|
|
2505
2524
|
if (isStarred) {
|
|
2506
2525
|
const currentStarred = newStarredByConv[sid] || [];
|
|
2507
|
-
if (!currentStarred.some((m) => String(m?._id || m?.id || m.messageId?._id || m.messageId?.id) === String(
|
|
2526
|
+
if (!currentStarred.some((m) => String(m?._id || m?.id || m.messageId?._id || m.messageId?.id) === String(messageId2))) {
|
|
2508
2527
|
const fullMsg = msg ? { ...msg, isStarred: true } : payload;
|
|
2509
2528
|
newStarredByConv[sid] = [...currentStarred, fullMsg];
|
|
2510
2529
|
}
|
|
2511
2530
|
} else {
|
|
2512
2531
|
newStarredByConv[sid] = (newStarredByConv[sid] || []).filter(
|
|
2513
|
-
(m) => String(m?._id || m?.id || m.messageId?._id || m.messageId?.id) !== String(
|
|
2532
|
+
(m) => String(m?._id || m?.id || m.messageId?._id || m.messageId?.id) !== String(messageId2)
|
|
2514
2533
|
);
|
|
2515
2534
|
}
|
|
2516
2535
|
const conversation = get().conversations?.find((c) => String(c._id) === String(sid));
|
|
@@ -2525,7 +2544,7 @@ var init_star_handlers = __esm({
|
|
|
2525
2544
|
starredCount = payload.totalCount;
|
|
2526
2545
|
}
|
|
2527
2546
|
const newPendingActions = { ...state.messagePendingActions };
|
|
2528
|
-
const pendingKey = String(
|
|
2547
|
+
const pendingKey = String(messageId2);
|
|
2529
2548
|
if (newPendingActions[pendingKey]) {
|
|
2530
2549
|
delete newPendingActions[pendingKey];
|
|
2531
2550
|
}
|
|
@@ -2646,15 +2665,15 @@ var init_emit_actions = __esm({
|
|
|
2646
2665
|
exports.socketService.emit("dm_unpin", p);
|
|
2647
2666
|
},
|
|
2648
2667
|
emitDmStar: (p) => {
|
|
2649
|
-
const
|
|
2650
|
-
handleStarUpdate(set, get, { ...p, messageId, isStarred: true });
|
|
2651
|
-
set((state) => ({ messagePendingActions: { ...state.messagePendingActions, [
|
|
2668
|
+
const messageId2 = String(p.messageId);
|
|
2669
|
+
handleStarUpdate(set, get, { ...p, messageId: messageId2, isStarred: true });
|
|
2670
|
+
set((state) => ({ messagePendingActions: { ...state.messagePendingActions, [messageId2]: ["star"] } }));
|
|
2652
2671
|
exports.socketService.emit("dm_star", p);
|
|
2653
2672
|
},
|
|
2654
2673
|
emitDmUnstar: (p) => {
|
|
2655
|
-
const
|
|
2656
|
-
handleStarUpdate(set, get, { ...p, messageId, isStarred: false });
|
|
2657
|
-
set((state) => ({ messagePendingActions: { ...state.messagePendingActions, [
|
|
2674
|
+
const messageId2 = String(p.messageId);
|
|
2675
|
+
handleStarUpdate(set, get, { ...p, messageId: messageId2, isStarred: false });
|
|
2676
|
+
set((state) => ({ messagePendingActions: { ...state.messagePendingActions, [messageId2]: ["unstar"] } }));
|
|
2658
2677
|
exports.socketService.emit("dm_unstar", p);
|
|
2659
2678
|
},
|
|
2660
2679
|
emitDmForward: (p) => {
|
|
@@ -2706,15 +2725,15 @@ var init_emit_actions = __esm({
|
|
|
2706
2725
|
exports.socketService.emitGroupUnpin(p);
|
|
2707
2726
|
},
|
|
2708
2727
|
emitGroupStar: (p) => {
|
|
2709
|
-
const
|
|
2710
|
-
handleStarUpdate(set, get, { ...p, messageId, isStarred: true });
|
|
2711
|
-
set((state) => ({ messagePendingActions: { ...state.messagePendingActions, [
|
|
2728
|
+
const messageId2 = String(p.messageId);
|
|
2729
|
+
handleStarUpdate(set, get, { ...p, messageId: messageId2, isStarred: true });
|
|
2730
|
+
set((state) => ({ messagePendingActions: { ...state.messagePendingActions, [messageId2]: ["star"] } }));
|
|
2712
2731
|
exports.socketService.emitGroupStar(p);
|
|
2713
2732
|
},
|
|
2714
2733
|
emitGroupUnstar: (p) => {
|
|
2715
|
-
const
|
|
2716
|
-
handleStarUpdate(set, get, { ...p, messageId, isStarred: false });
|
|
2717
|
-
set((state) => ({ messagePendingActions: { ...state.messagePendingActions, [
|
|
2734
|
+
const messageId2 = String(p.messageId);
|
|
2735
|
+
handleStarUpdate(set, get, { ...p, messageId: messageId2, isStarred: false });
|
|
2736
|
+
set((state) => ({ messagePendingActions: { ...state.messagePendingActions, [messageId2]: ["unstar"] } }));
|
|
2718
2737
|
exports.socketService.emitGroupUnstar(p);
|
|
2719
2738
|
},
|
|
2720
2739
|
emitGroupForward: (p) => {
|
|
@@ -2733,8 +2752,8 @@ var init_emit_actions = __esm({
|
|
|
2733
2752
|
...p.attachmentId ? { attachmentId: String(p.attachmentId) } : {}
|
|
2734
2753
|
});
|
|
2735
2754
|
},
|
|
2736
|
-
clearForwardPending: (
|
|
2737
|
-
clearForwardPendingActions(set,
|
|
2755
|
+
clearForwardPending: (messageId2) => {
|
|
2756
|
+
clearForwardPendingActions(set, messageId2);
|
|
2738
2757
|
},
|
|
2739
2758
|
emitConversationUpdate: (p) => exports.socketService.emitConversationUpdate(p),
|
|
2740
2759
|
emitGroupLeave: (p) => exports.socketService.emitGroupLeave(p),
|
|
@@ -2759,7 +2778,7 @@ var init_message_handlers = __esm({
|
|
|
2759
2778
|
get().conversations,
|
|
2760
2779
|
loggedUserId
|
|
2761
2780
|
);
|
|
2762
|
-
const { messageId } = extractMessageData(lastDM);
|
|
2781
|
+
const { messageId: messageId2 } = extractMessageData(lastDM);
|
|
2763
2782
|
const tempId = lastDM.tempId;
|
|
2764
2783
|
const isFromSelf = loggedUserDetails && String(lastDM.sender?._id || lastDM.sender) === String(loggedUserDetails._id);
|
|
2765
2784
|
const activeConversationId = get().activeConversationId;
|
|
@@ -2769,14 +2788,14 @@ var init_message_handlers = __esm({
|
|
|
2769
2788
|
const newPendingActions = { ...state.messagePendingActions };
|
|
2770
2789
|
if (conversationId) {
|
|
2771
2790
|
const current = nextMessagesByConversation[conversationId] || [];
|
|
2772
|
-
let matchedId =
|
|
2791
|
+
let matchedId = messageId2;
|
|
2773
2792
|
if (tempId && state.messagePendingActions[tempId]) {
|
|
2774
2793
|
matchedId = tempId;
|
|
2775
2794
|
}
|
|
2776
|
-
const exists = current.some((m) => String(m._id || m.id) === String(
|
|
2795
|
+
const exists = current.some((m) => String(m._id || m.id) === String(messageId2));
|
|
2777
2796
|
if (matchedId && matchedId === tempId) {
|
|
2778
2797
|
nextMessagesByConversation[conversationId] = current.map(
|
|
2779
|
-
(m) => String(m.id || m._id) === String(matchedId) ? { ...m, _id:
|
|
2798
|
+
(m) => String(m.id || m._id) === String(matchedId) ? { ...m, _id: messageId2, id: messageId2, status: messageWithStatus.status } : m
|
|
2780
2799
|
);
|
|
2781
2800
|
delete newPendingActions[matchedId];
|
|
2782
2801
|
} else if (!exists) {
|
|
@@ -2831,27 +2850,27 @@ var init_message_handlers = __esm({
|
|
|
2831
2850
|
}
|
|
2832
2851
|
};
|
|
2833
2852
|
handleEditDM = (set, get, payload) => {
|
|
2834
|
-
const { messageId, content, conversationId, attachmentId, caption } = extractMessageData(payload);
|
|
2835
|
-
if (!
|
|
2853
|
+
const { messageId: messageId2, content, conversationId, attachmentId, caption } = extractMessageData(payload);
|
|
2854
|
+
if (!messageId2) return;
|
|
2836
2855
|
const captionText = caption ?? content ?? "";
|
|
2837
2856
|
set((state) => {
|
|
2838
2857
|
let searchConversationId = conversationId;
|
|
2839
2858
|
if (!searchConversationId) {
|
|
2840
|
-
searchConversationId = findConversationIdByMessageId(state.messagesByConversation,
|
|
2859
|
+
searchConversationId = findConversationIdByMessageId(state.messagesByConversation, messageId2);
|
|
2841
2860
|
}
|
|
2842
2861
|
if (!searchConversationId) {
|
|
2843
2862
|
searchConversationId = state.conversations.find(
|
|
2844
|
-
(c) => String(c.lastMessage?._id || c.lastMessage?.id) === String(
|
|
2863
|
+
(c) => String(c.lastMessage?._id || c.lastMessage?.id) === String(messageId2)
|
|
2845
2864
|
)?._id;
|
|
2846
2865
|
}
|
|
2847
|
-
const normalizedEditPayload = { ...payload, messageId, content, conversationId: searchConversationId, _v: Date.now() };
|
|
2866
|
+
const normalizedEditPayload = { ...payload, messageId: messageId2, content, conversationId: searchConversationId, _v: Date.now() };
|
|
2848
2867
|
const newPendingActions = { ...state.messagePendingActions };
|
|
2849
|
-
if (newPendingActions[
|
|
2850
|
-
delete newPendingActions[
|
|
2868
|
+
if (newPendingActions[messageId2]) {
|
|
2869
|
+
delete newPendingActions[messageId2];
|
|
2851
2870
|
}
|
|
2852
2871
|
if (searchConversationId) {
|
|
2853
2872
|
const messages = state.messagesByConversation[searchConversationId] || [];
|
|
2854
|
-
const index = messages.findIndex((m) => String(m._id || m.id) === String(
|
|
2873
|
+
const index = messages.findIndex((m) => String(m._id || m.id) === String(messageId2));
|
|
2855
2874
|
if (index !== -1) {
|
|
2856
2875
|
const newMessages = [...messages];
|
|
2857
2876
|
if (attachmentId) {
|
|
@@ -2877,15 +2896,15 @@ var init_message_handlers = __esm({
|
|
|
2877
2896
|
});
|
|
2878
2897
|
};
|
|
2879
2898
|
handleDeleteDM = (set, get, payload, type) => {
|
|
2880
|
-
const { messageId, conversationId, attachmentId } = extractMessageData(payload);
|
|
2881
|
-
if (!
|
|
2899
|
+
const { messageId: messageId2, conversationId, attachmentId } = extractMessageData(payload);
|
|
2900
|
+
if (!messageId2) return;
|
|
2882
2901
|
set((state) => {
|
|
2883
|
-
const searchConversationId = conversationId || findConversationIdByMessageId(state.messagesByConversation,
|
|
2902
|
+
const searchConversationId = conversationId || findConversationIdByMessageId(state.messagesByConversation, messageId2);
|
|
2884
2903
|
const messageTombstoned = payload.messageTombstoned === true;
|
|
2885
2904
|
let updatedConversations = state.conversations;
|
|
2886
2905
|
if (searchConversationId && !attachmentId) {
|
|
2887
2906
|
updatedConversations = state.conversations.map((c) => {
|
|
2888
|
-
if (String(c._id) === String(searchConversationId) && String(c.lastMessage?._id || c.lastMessage?.id) === String(
|
|
2907
|
+
if (String(c._id) === String(searchConversationId) && String(c.lastMessage?._id || c.lastMessage?.id) === String(messageId2)) {
|
|
2889
2908
|
return { ...c, lastMessage: type === "me" ? { ...c.lastMessage, content: "" } : { ...c.lastMessage, isDeletedForEveryone: true, content: "This message has been deleted" } };
|
|
2890
2909
|
}
|
|
2891
2910
|
return c;
|
|
@@ -2896,7 +2915,7 @@ var init_message_handlers = __esm({
|
|
|
2896
2915
|
if (searchConversationId) {
|
|
2897
2916
|
if (attachmentId) {
|
|
2898
2917
|
const updatedMessages = messages.map((m) => {
|
|
2899
|
-
if (String(m._id || m.id) !== String(
|
|
2918
|
+
if (String(m._id || m.id) !== String(messageId2)) return m;
|
|
2900
2919
|
if (messageTombstoned || type === "everyone" && payload.content) {
|
|
2901
2920
|
return {
|
|
2902
2921
|
...m,
|
|
@@ -2935,22 +2954,22 @@ var init_message_handlers = __esm({
|
|
|
2935
2954
|
[searchConversationId]: updatedMessages
|
|
2936
2955
|
};
|
|
2937
2956
|
} else if (type === "me") {
|
|
2938
|
-
nextMessagesByConversation = { ...state.messagesByConversation, [searchConversationId]: messages.filter((m) => String(m._id || m.id) !== String(
|
|
2957
|
+
nextMessagesByConversation = { ...state.messagesByConversation, [searchConversationId]: messages.filter((m) => String(m._id || m.id) !== String(messageId2)) };
|
|
2939
2958
|
} else {
|
|
2940
2959
|
nextMessagesByConversation = {
|
|
2941
2960
|
...state.messagesByConversation,
|
|
2942
|
-
[searchConversationId]: messages.map((m) => String(m._id || m.id) === String(
|
|
2961
|
+
[searchConversationId]: messages.map((m) => String(m._id || m.id) === String(messageId2) ? { ...m, isDeletedForEveryone: true, content: "" } : m)
|
|
2943
2962
|
};
|
|
2944
2963
|
}
|
|
2945
2964
|
}
|
|
2946
2965
|
const newPendingActions = { ...state.messagePendingActions };
|
|
2947
|
-
if (newPendingActions[
|
|
2948
|
-
delete newPendingActions[
|
|
2966
|
+
if (newPendingActions[messageId2]) {
|
|
2967
|
+
delete newPendingActions[messageId2];
|
|
2949
2968
|
}
|
|
2950
|
-
const shouldMarkWholeMessageDeleted = type === "me" && !attachmentId && !state.deletedForMeIds.includes(
|
|
2969
|
+
const shouldMarkWholeMessageDeleted = type === "me" && !attachmentId && !state.deletedForMeIds.includes(messageId2);
|
|
2951
2970
|
return {
|
|
2952
2971
|
lastDeleteDM: { ...payload, deleteType: type },
|
|
2953
|
-
deletedForMeIds: shouldMarkWholeMessageDeleted ? [...state.deletedForMeIds,
|
|
2972
|
+
deletedForMeIds: shouldMarkWholeMessageDeleted ? [...state.deletedForMeIds, messageId2] : state.deletedForMeIds,
|
|
2954
2973
|
messagesByConversation: nextMessagesByConversation,
|
|
2955
2974
|
conversations: updatedConversations,
|
|
2956
2975
|
messagePendingActions: newPendingActions
|
|
@@ -3024,15 +3043,15 @@ var init_dm_actions = __esm({
|
|
|
3024
3043
|
},
|
|
3025
3044
|
receivedStatusUpdate: (payload) => {
|
|
3026
3045
|
const data = extractMessageData(payload);
|
|
3027
|
-
const { messageId, status } = data;
|
|
3046
|
+
const { messageId: messageId2, status } = data;
|
|
3028
3047
|
let { conversationId } = data;
|
|
3029
|
-
if (!
|
|
3048
|
+
if (!messageId2 || !status) return;
|
|
3030
3049
|
set({ lastStatusUpdate: payload });
|
|
3031
3050
|
if (!conversationId) {
|
|
3032
|
-
conversationId = findConversationIdByMessageId(get().messagesByConversation,
|
|
3051
|
+
conversationId = findConversationIdByMessageId(get().messagesByConversation, messageId2) || findConversationIdByLastMessageId(get().conversations, messageId2) || void 0;
|
|
3033
3052
|
}
|
|
3034
3053
|
set((state) => ({
|
|
3035
|
-
...applyMessageStatusToStore(state, String(
|
|
3054
|
+
...applyMessageStatusToStore(state, String(messageId2), status, conversationId)
|
|
3036
3055
|
}));
|
|
3037
3056
|
},
|
|
3038
3057
|
receivedDMMarkRead: (payload) => {
|
|
@@ -3089,7 +3108,7 @@ var init_group_handlers = __esm({
|
|
|
3089
3108
|
get().conversations,
|
|
3090
3109
|
loggedUserId
|
|
3091
3110
|
);
|
|
3092
|
-
const { messageId } = extractMessageData(lastDM);
|
|
3111
|
+
const { messageId: messageId2 } = extractMessageData(lastDM);
|
|
3093
3112
|
const tempId = lastDM.tempId;
|
|
3094
3113
|
const activeConversationId = get().activeConversationId;
|
|
3095
3114
|
const isOpenConversation = conversationId && String(conversationId) === String(activeConversationId);
|
|
@@ -3126,23 +3145,23 @@ var init_group_handlers = __esm({
|
|
|
3126
3145
|
);
|
|
3127
3146
|
if (optimisticMsg) matchedTempId = optimisticMsg.id;
|
|
3128
3147
|
}
|
|
3129
|
-
const messageExists = current.some((m) => String(m._id || m.id) === String(
|
|
3148
|
+
const messageExists = current.some((m) => String(m._id || m.id) === String(messageId2));
|
|
3130
3149
|
if (!messageExists) {
|
|
3131
3150
|
nextMessagesByConversation[conversationId] = [...current, {
|
|
3132
3151
|
...lastDM,
|
|
3133
|
-
_id:
|
|
3134
|
-
id:
|
|
3152
|
+
_id: messageId2,
|
|
3153
|
+
id: messageId2,
|
|
3135
3154
|
status: lastDM.status || "sent"
|
|
3136
3155
|
}];
|
|
3137
3156
|
} else {
|
|
3138
3157
|
nextMessagesByConversation[conversationId] = current.map(
|
|
3139
|
-
(m) => String(m._id || m.id) === String(
|
|
3158
|
+
(m) => String(m._id || m.id) === String(messageId2) ? { ...m, status: lastDM.status || "sent" } : m
|
|
3140
3159
|
);
|
|
3141
3160
|
}
|
|
3142
3161
|
if (matchedTempId) {
|
|
3143
3162
|
delete newPendingActions[matchedTempId];
|
|
3144
3163
|
nextMessagesByConversation[conversationId] = nextMessagesByConversation[conversationId].map(
|
|
3145
|
-
(m) => String(m.id || m._id) === String(matchedTempId) ? { ...m, _id:
|
|
3164
|
+
(m) => String(m.id || m._id) === String(matchedTempId) ? { ...m, _id: messageId2, id: messageId2, status: lastDM.status || "sent" } : m
|
|
3146
3165
|
);
|
|
3147
3166
|
}
|
|
3148
3167
|
}
|
|
@@ -3215,10 +3234,10 @@ var init_group_handlers = __esm({
|
|
|
3215
3234
|
(c) => String(c._id) === String(conversationId)
|
|
3216
3235
|
);
|
|
3217
3236
|
const isGroupChat = isGroupConversation(targetConv);
|
|
3218
|
-
if (loggedUserDetails?._id &&
|
|
3237
|
+
if (loggedUserDetails?._id && messageId2 && isGroupChat) {
|
|
3219
3238
|
get().emitGroupMessageDelivered({
|
|
3220
3239
|
conversationId,
|
|
3221
|
-
messageId,
|
|
3240
|
+
messageId: messageId2,
|
|
3222
3241
|
userId: loggedUserDetails._id
|
|
3223
3242
|
});
|
|
3224
3243
|
}
|
|
@@ -3296,15 +3315,15 @@ var init_group_actions2 = __esm({
|
|
|
3296
3315
|
receivedGroupStatusUpdate: (payload) => {
|
|
3297
3316
|
const data = extractMessageData(payload);
|
|
3298
3317
|
let { conversationId } = data;
|
|
3299
|
-
const { messageId, status } = data;
|
|
3318
|
+
const { messageId: messageId2, status } = data;
|
|
3300
3319
|
set({ lastStatusUpdate: payload });
|
|
3301
3320
|
if (!status) return;
|
|
3302
|
-
if (
|
|
3321
|
+
if (messageId2) {
|
|
3303
3322
|
if (!conversationId) {
|
|
3304
|
-
conversationId = findConversationIdByMessageId(get().messagesByConversation,
|
|
3323
|
+
conversationId = findConversationIdByMessageId(get().messagesByConversation, messageId2) || findConversationIdByLastMessageId(get().conversations, messageId2) || void 0;
|
|
3305
3324
|
}
|
|
3306
3325
|
set((state) => ({
|
|
3307
|
-
...applyMessageStatusToStore(state, String(
|
|
3326
|
+
...applyMessageStatusToStore(state, String(messageId2), status, conversationId)
|
|
3308
3327
|
}));
|
|
3309
3328
|
return;
|
|
3310
3329
|
}
|
|
@@ -3520,7 +3539,7 @@ var init_receive = __esm({
|
|
|
3520
3539
|
};
|
|
3521
3540
|
});
|
|
3522
3541
|
},
|
|
3523
|
-
markDeletedForMe: (
|
|
3542
|
+
markDeletedForMe: (messageId2) => set((state) => ({ deletedForMeIds: [...state.deletedForMeIds, messageId2] }))
|
|
3524
3543
|
});
|
|
3525
3544
|
createReceiveActions = (set, get) => ({
|
|
3526
3545
|
...createDmReceiveActions(set, get),
|
|
@@ -3545,13 +3564,13 @@ var init_search_actions = __esm({
|
|
|
3545
3564
|
init_api_service();
|
|
3546
3565
|
init_store_helpers();
|
|
3547
3566
|
createSearchActions = (set, _get) => ({
|
|
3548
|
-
fetchSearchMessageContext: async (
|
|
3567
|
+
fetchSearchMessageContext: async (messageId2, options) => {
|
|
3549
3568
|
const searchMode = options?.searchMode !== false;
|
|
3550
|
-
set({ isSearchActive: searchMode, searchedMessageId:
|
|
3569
|
+
set({ isSearchActive: searchMode, searchedMessageId: messageId2, isFetchingMessages: true });
|
|
3551
3570
|
try {
|
|
3552
|
-
const response = await searchMessagesContext(
|
|
3571
|
+
const response = await searchMessagesContext(messageId2);
|
|
3553
3572
|
const data = response.data?.list || response.data?.messages || response.messages || response.data || [];
|
|
3554
|
-
const highlightId = response.data?.highlightMessageId ||
|
|
3573
|
+
const highlightId = response.data?.highlightMessageId || messageId2;
|
|
3555
3574
|
if (data.length > 0) {
|
|
3556
3575
|
const conversationId = data[0].conversationId;
|
|
3557
3576
|
if (conversationId) {
|
|
@@ -3580,7 +3599,7 @@ var init_search_actions = __esm({
|
|
|
3580
3599
|
}
|
|
3581
3600
|
},
|
|
3582
3601
|
setSearchActive: (active) => set({ isSearchActive: active }),
|
|
3583
|
-
setSearchedMessageId: (
|
|
3602
|
+
setSearchedMessageId: (messageId2) => set({ searchedMessageId: messageId2 })
|
|
3584
3603
|
});
|
|
3585
3604
|
}
|
|
3586
3605
|
});
|
|
@@ -3947,6 +3966,7 @@ var buildIncomingMessageFromDM = (lastDM, loggedUserId, conversations) => {
|
|
|
3947
3966
|
content: lastDM.content || lastDM.message?.content || "",
|
|
3948
3967
|
sender: lastDM.sender?.name || lastDM.fromUserId || (isMe ? "Me" : "User"),
|
|
3949
3968
|
senderId: String(lastDM.sender?._id || lastDM.sender || lastDM.fromUserId || ""),
|
|
3969
|
+
senderImage: lastDM.sender?.image,
|
|
3950
3970
|
timestamp: lastDM.createdAt || (/* @__PURE__ */ new Date()).toISOString(),
|
|
3951
3971
|
isOwnMessage: isMe,
|
|
3952
3972
|
channelId,
|
|
@@ -4104,9 +4124,9 @@ var syncLocalMessagesOnPinUpdate = (prev, lastPinUpdate) => {
|
|
|
4104
4124
|
return next;
|
|
4105
4125
|
};
|
|
4106
4126
|
var syncLocalMessagesOnStarUpdate = (prev, lastStarUpdate, loggedUserId) => {
|
|
4107
|
-
const
|
|
4108
|
-
if (!
|
|
4109
|
-
const mid = String(
|
|
4127
|
+
const messageId2 = lastStarUpdate.messageId || lastStarUpdate._id;
|
|
4128
|
+
if (!messageId2) return null;
|
|
4129
|
+
const mid = String(messageId2);
|
|
4110
4130
|
let isStarred;
|
|
4111
4131
|
if (typeof lastStarUpdate.isStarred === "boolean") {
|
|
4112
4132
|
isStarred = lastStarUpdate.isStarred;
|
|
@@ -4125,9 +4145,9 @@ var syncLocalMessagesOnStarUpdate = (prev, lastStarUpdate, loggedUserId) => {
|
|
|
4125
4145
|
return next;
|
|
4126
4146
|
};
|
|
4127
4147
|
var syncLocalMessagesOnReactionUpdate = (prev, lastReactionUpdate, messagesByConversation) => {
|
|
4128
|
-
const
|
|
4129
|
-
if (!
|
|
4130
|
-
const mid = String(
|
|
4148
|
+
const messageId2 = lastReactionUpdate.messageId || lastReactionUpdate._id;
|
|
4149
|
+
if (!messageId2) return prev;
|
|
4150
|
+
const mid = String(messageId2);
|
|
4131
4151
|
let storeReactions;
|
|
4132
4152
|
for (const msgs of Object.values(messagesByConversation)) {
|
|
4133
4153
|
const found = msgs.find((m) => String(m._id || m.id) === mid);
|
|
@@ -4178,7 +4198,7 @@ var syncLocalMessagesOnReactionUpdate = (prev, lastReactionUpdate, messagesByCon
|
|
|
4178
4198
|
return changed ? next : prev;
|
|
4179
4199
|
};
|
|
4180
4200
|
var syncLocalMessagesOnDelete = (prev, lastDeleteDM) => {
|
|
4181
|
-
const
|
|
4201
|
+
const messageId2 = lastDeleteDM.messageId || lastDeleteDM._id;
|
|
4182
4202
|
const deleteType = lastDeleteDM.deleteType || "everyone";
|
|
4183
4203
|
const attachmentId = lastDeleteDM.attachmentId ? String(lastDeleteDM.attachmentId) : null;
|
|
4184
4204
|
const messageTombstoned = lastDeleteDM.messageTombstoned === true;
|
|
@@ -4186,7 +4206,7 @@ var syncLocalMessagesOnDelete = (prev, lastDeleteDM) => {
|
|
|
4186
4206
|
Object.keys(next).forEach((channelId) => {
|
|
4187
4207
|
if (attachmentId) {
|
|
4188
4208
|
next[channelId] = next[channelId].map((message) => {
|
|
4189
|
-
if (String(message._id || message.id) !== String(
|
|
4209
|
+
if (String(message._id || message.id) !== String(messageId2)) {
|
|
4190
4210
|
return message;
|
|
4191
4211
|
}
|
|
4192
4212
|
return applyLocalAttachmentDelete(
|
|
@@ -4200,26 +4220,26 @@ var syncLocalMessagesOnDelete = (prev, lastDeleteDM) => {
|
|
|
4200
4220
|
}
|
|
4201
4221
|
if (deleteType === "me") {
|
|
4202
4222
|
next[channelId] = next[channelId].filter(
|
|
4203
|
-
(m) => String(m._id || m.id) !== String(
|
|
4223
|
+
(m) => String(m._id || m.id) !== String(messageId2)
|
|
4204
4224
|
);
|
|
4205
4225
|
} else {
|
|
4206
4226
|
next[channelId] = next[channelId].map(
|
|
4207
|
-
(m) => String(m._id || m.id) === String(
|
|
4227
|
+
(m) => String(m._id || m.id) === String(messageId2) ? { ...m, isDeletedForEveryone: true } : m
|
|
4208
4228
|
);
|
|
4209
4229
|
}
|
|
4210
4230
|
});
|
|
4211
4231
|
return next;
|
|
4212
4232
|
};
|
|
4213
4233
|
var syncLocalMessagesOnEdit = (prev, lastEditDM) => {
|
|
4214
|
-
const
|
|
4234
|
+
const messageId2 = lastEditDM.messageId || lastEditDM._id;
|
|
4215
4235
|
const content = lastEditDM.content;
|
|
4216
4236
|
const attachmentId = lastEditDM.attachmentId ? String(lastEditDM.attachmentId) : null;
|
|
4217
4237
|
const caption = lastEditDM.caption ?? content;
|
|
4218
|
-
if (!
|
|
4238
|
+
if (!messageId2) return null;
|
|
4219
4239
|
const next = { ...prev };
|
|
4220
4240
|
Object.keys(next).forEach((channelId) => {
|
|
4221
4241
|
const messages = next[channelId];
|
|
4222
|
-
const index = messages.findIndex((m) => String(m._id || m.id) === String(
|
|
4242
|
+
const index = messages.findIndex((m) => String(m._id || m.id) === String(messageId2));
|
|
4223
4243
|
if (index !== -1) {
|
|
4224
4244
|
const updated = [...messages];
|
|
4225
4245
|
const current = updated[index];
|
|
@@ -4489,7 +4509,7 @@ var Chat = ({
|
|
|
4489
4509
|
const status = exports.useChatStore((s) => s.status);
|
|
4490
4510
|
const error = exports.useChatStore((s) => s.error);
|
|
4491
4511
|
useChatSync();
|
|
4492
|
-
|
|
4512
|
+
React2__namespace.default.useEffect(() => {
|
|
4493
4513
|
const clientId = client?.id;
|
|
4494
4514
|
const initializeChat = async () => {
|
|
4495
4515
|
if (!clientId || !loggedUserDetails) return;
|
|
@@ -4578,28 +4598,28 @@ var Chat = ({
|
|
|
4578
4598
|
queryParamApis: queryParamApis ?? ["get"],
|
|
4579
4599
|
queryParamsByApi: queryParamsByApi ?? {}
|
|
4580
4600
|
});
|
|
4581
|
-
|
|
4601
|
+
React2__namespace.default.useEffect(() => {
|
|
4582
4602
|
exports.setChatQueryParams(queryParams);
|
|
4583
4603
|
exports.setChatQueryParamApis(queryParamApis);
|
|
4584
4604
|
exports.setChatQueryParamsByApi(queryParamsByApi);
|
|
4585
4605
|
}, [queryConfigKey]);
|
|
4586
|
-
|
|
4606
|
+
React2__namespace.default.useEffect(() => {
|
|
4587
4607
|
if (lastDM && onMessageReceived) {
|
|
4588
4608
|
onMessageReceived(lastDM);
|
|
4589
4609
|
}
|
|
4590
4610
|
}, [lastDM, onMessageReceived]);
|
|
4591
|
-
|
|
4611
|
+
React2__namespace.default.useEffect(() => {
|
|
4592
4612
|
if (status === "connected" && onSocketConnected) {
|
|
4593
4613
|
const socketId = exports.useChatStore.getState().socketId;
|
|
4594
4614
|
if (socketId) onSocketConnected(socketId);
|
|
4595
4615
|
}
|
|
4596
4616
|
}, [status, onSocketConnected]);
|
|
4597
|
-
|
|
4617
|
+
React2__namespace.default.useEffect(() => {
|
|
4598
4618
|
if (status === "error" && error && onSocketError) {
|
|
4599
4619
|
onSocketError(error);
|
|
4600
4620
|
}
|
|
4601
4621
|
}, [status, error, onSocketError]);
|
|
4602
|
-
const contextValue =
|
|
4622
|
+
const contextValue = React2__namespace.default.useMemo(
|
|
4603
4623
|
() => ({
|
|
4604
4624
|
onSendMessage,
|
|
4605
4625
|
client,
|
|
@@ -4619,7 +4639,7 @@ var Chat = ({
|
|
|
4619
4639
|
messagesData
|
|
4620
4640
|
]
|
|
4621
4641
|
);
|
|
4622
|
-
const customization =
|
|
4642
|
+
const customization = React2__namespace.default.useMemo(
|
|
4623
4643
|
() => ({
|
|
4624
4644
|
components: uiConfig.components,
|
|
4625
4645
|
classNames: uiConfig.classNames,
|
|
@@ -6714,20 +6734,35 @@ init_chat_constants();
|
|
|
6714
6734
|
// src/chat/lib/last-message-preview.ts
|
|
6715
6735
|
init_store_helpers();
|
|
6716
6736
|
|
|
6717
|
-
// src/chat/lib/
|
|
6718
|
-
|
|
6719
|
-
|
|
6720
|
-
|
|
6721
|
-
|
|
6722
|
-
|
|
6723
|
-
|
|
6724
|
-
|
|
6725
|
-
|
|
6737
|
+
// src/chat/lib/attachment-preview-labels.ts
|
|
6738
|
+
function getAttachmentTypePreviewLabel(type) {
|
|
6739
|
+
switch (String(type || "").toLowerCase()) {
|
|
6740
|
+
case "image":
|
|
6741
|
+
return "Photo";
|
|
6742
|
+
case "video":
|
|
6743
|
+
return "Video";
|
|
6744
|
+
case "audio":
|
|
6745
|
+
return "Audio";
|
|
6746
|
+
case "file":
|
|
6747
|
+
case "document":
|
|
6748
|
+
case "spreadsheet":
|
|
6749
|
+
return "Attachment";
|
|
6750
|
+
default:
|
|
6751
|
+
return "Attachment";
|
|
6726
6752
|
}
|
|
6727
|
-
|
|
6728
|
-
|
|
6753
|
+
}
|
|
6754
|
+
function getAttachmentCountPreviewLabel(type, count) {
|
|
6755
|
+
if (count <= 1) return getAttachmentTypePreviewLabel(type);
|
|
6756
|
+
switch (String(type).toLowerCase()) {
|
|
6757
|
+
case "image":
|
|
6758
|
+
return `${count} photos`;
|
|
6759
|
+
case "video":
|
|
6760
|
+
return `${count} videos`;
|
|
6761
|
+
case "audio":
|
|
6762
|
+
return `${count} audio files`;
|
|
6763
|
+
default:
|
|
6764
|
+
return `${count} attachments`;
|
|
6729
6765
|
}
|
|
6730
|
-
return name.trim() || trimmed;
|
|
6731
6766
|
}
|
|
6732
6767
|
|
|
6733
6768
|
// src/chat/lib/last-message-preview.ts
|
|
@@ -6735,21 +6770,30 @@ function getAttachmentOnlyPreviewText(attachments) {
|
|
|
6735
6770
|
const images = attachments.filter((att2) => att2.type === "image" && att2.url);
|
|
6736
6771
|
const videos = attachments.filter((att2) => att2.type === "video" && att2.url);
|
|
6737
6772
|
const audios = attachments.filter((att2) => att2.type === "audio" && att2.url);
|
|
6738
|
-
|
|
6773
|
+
const files = attachments.filter(
|
|
6774
|
+
(att2) => att2.url && !["image", "video", "audio"].includes(att2.type)
|
|
6775
|
+
);
|
|
6776
|
+
if (images.length > 1) return getAttachmentCountPreviewLabel("image", images.length);
|
|
6739
6777
|
if (images.length === 1) {
|
|
6740
|
-
return images[0].caption?.trim() || "
|
|
6778
|
+
return images[0].caption?.trim() || getAttachmentTypePreviewLabel("image");
|
|
6741
6779
|
}
|
|
6742
|
-
if (videos.length > 1) return
|
|
6780
|
+
if (videos.length > 1) return getAttachmentCountPreviewLabel("video", videos.length);
|
|
6743
6781
|
if (videos.length === 1) {
|
|
6744
|
-
return videos[0].caption?.trim() || "
|
|
6782
|
+
return videos[0].caption?.trim() || getAttachmentTypePreviewLabel("video");
|
|
6745
6783
|
}
|
|
6746
|
-
if (audios.length > 1) return
|
|
6784
|
+
if (audios.length > 1) return getAttachmentCountPreviewLabel("audio", audios.length);
|
|
6747
6785
|
if (audios.length === 1) {
|
|
6748
|
-
return audios[0].caption?.trim() || "
|
|
6786
|
+
return audios[0].caption?.trim() || getAttachmentTypePreviewLabel("audio");
|
|
6787
|
+
}
|
|
6788
|
+
if (files.length > 1) return getAttachmentCountPreviewLabel("file", files.length);
|
|
6789
|
+
if (files.length === 1) {
|
|
6790
|
+
return files[0].caption?.trim() || getAttachmentTypePreviewLabel(files[0].type);
|
|
6791
|
+
}
|
|
6792
|
+
if (attachments.length > 1) {
|
|
6793
|
+
return getAttachmentCountPreviewLabel("file", attachments.length);
|
|
6749
6794
|
}
|
|
6750
|
-
if (attachments.length > 1) return `${attachments.length} files`;
|
|
6751
6795
|
const att = attachments[0];
|
|
6752
|
-
return att
|
|
6796
|
+
return att?.caption?.trim() || getAttachmentTypePreviewLabel(att?.type);
|
|
6753
6797
|
}
|
|
6754
6798
|
function getLastMessageSidebarPreview(message) {
|
|
6755
6799
|
const content = String(message?.content || "").trim();
|
|
@@ -6763,6 +6807,10 @@ function getLastMessageSidebarPreview(message) {
|
|
|
6763
6807
|
if (attachments.length > 0) {
|
|
6764
6808
|
return getAttachmentOnlyPreviewText(attachments);
|
|
6765
6809
|
}
|
|
6810
|
+
const messageType = String(message?.type || "").toLowerCase();
|
|
6811
|
+
if (messageType && messageType !== "text") {
|
|
6812
|
+
return getAttachmentTypePreviewLabel(messageType);
|
|
6813
|
+
}
|
|
6766
6814
|
return "No messages yet";
|
|
6767
6815
|
}
|
|
6768
6816
|
function getMessagePreviewText(message, fallback = "Message") {
|
|
@@ -6774,6 +6822,10 @@ function getMessagePreviewText(message, fallback = "Message") {
|
|
|
6774
6822
|
if (attachments.length > 0) {
|
|
6775
6823
|
return getAttachmentOnlyPreviewText(attachments);
|
|
6776
6824
|
}
|
|
6825
|
+
const messageType = String(message?.type || "").toLowerCase();
|
|
6826
|
+
if (messageType && messageType !== "text") {
|
|
6827
|
+
return getAttachmentTypePreviewLabel(messageType);
|
|
6828
|
+
}
|
|
6777
6829
|
return fallback;
|
|
6778
6830
|
}
|
|
6779
6831
|
|
|
@@ -7415,7 +7467,7 @@ function highlightSearchMatch(text, query) {
|
|
|
7415
7467
|
children: part
|
|
7416
7468
|
},
|
|
7417
7469
|
`${part}-${index}`
|
|
7418
|
-
) : /* @__PURE__ */ jsxRuntime.jsx(
|
|
7470
|
+
) : /* @__PURE__ */ jsxRuntime.jsx(React2__namespace.default.Fragment, { children: part }, `${part}-${index}`)
|
|
7419
7471
|
);
|
|
7420
7472
|
}
|
|
7421
7473
|
function getMessagePreview(message) {
|
|
@@ -7830,11 +7882,11 @@ function buildAttachmentSummary(attachments) {
|
|
|
7830
7882
|
else fileCount += 1;
|
|
7831
7883
|
}
|
|
7832
7884
|
const parts = [];
|
|
7833
|
-
if (imageCount) parts.push(
|
|
7834
|
-
if (videoCount) parts.push(
|
|
7835
|
-
if (audioCount) parts.push(
|
|
7836
|
-
if (fileCount) parts.push(
|
|
7837
|
-
return parts.join(", ") || "
|
|
7885
|
+
if (imageCount) parts.push(getAttachmentCountPreviewLabel("image", imageCount));
|
|
7886
|
+
if (videoCount) parts.push(getAttachmentCountPreviewLabel("video", videoCount));
|
|
7887
|
+
if (audioCount) parts.push(getAttachmentCountPreviewLabel("audio", audioCount));
|
|
7888
|
+
if (fileCount) parts.push(getAttachmentCountPreviewLabel("file", fileCount));
|
|
7889
|
+
return parts.join(", ") || getAttachmentTypePreviewLabel("file");
|
|
7838
7890
|
}
|
|
7839
7891
|
function mapSavedMessageAttachments(msg, messageObj, ctx) {
|
|
7840
7892
|
const loggedUserId = String(ctx.loggedUserDetails?._id || "");
|
|
@@ -7896,11 +7948,19 @@ function resolveSavedMessageContent(messageObj, msg) {
|
|
|
7896
7948
|
}
|
|
7897
7949
|
return { content: filename, messageType: "file", previewUrl: void 0 };
|
|
7898
7950
|
}
|
|
7899
|
-
if (messageType === "image")
|
|
7900
|
-
|
|
7901
|
-
|
|
7902
|
-
if (messageType === "
|
|
7903
|
-
|
|
7951
|
+
if (messageType === "image") {
|
|
7952
|
+
return { content: getAttachmentTypePreviewLabel("image"), messageType, previewUrl: void 0 };
|
|
7953
|
+
}
|
|
7954
|
+
if (messageType === "video") {
|
|
7955
|
+
return { content: getAttachmentTypePreviewLabel("video"), messageType, previewUrl: void 0 };
|
|
7956
|
+
}
|
|
7957
|
+
if (messageType === "audio") {
|
|
7958
|
+
return { content: getAttachmentTypePreviewLabel("audio"), messageType, previewUrl: void 0 };
|
|
7959
|
+
}
|
|
7960
|
+
if (messageType === "file") {
|
|
7961
|
+
return { content: getAttachmentTypePreviewLabel("file"), messageType, previewUrl: void 0 };
|
|
7962
|
+
}
|
|
7963
|
+
return { content: getAttachmentTypePreviewLabel("file"), messageType, previewUrl: void 0 };
|
|
7904
7964
|
}
|
|
7905
7965
|
function getMessageId(msg) {
|
|
7906
7966
|
if (msg?.messageId && typeof msg.messageId === "object") {
|
|
@@ -7934,7 +7994,7 @@ function readSenderFromRecord(record) {
|
|
|
7934
7994
|
}
|
|
7935
7995
|
function resolveSenderName(msg, ctx) {
|
|
7936
7996
|
const messageObj = getMessageObject(msg);
|
|
7937
|
-
const
|
|
7997
|
+
const messageId2 = getMessageId(msg);
|
|
7938
7998
|
const loggedId = String(ctx.loggedUserDetails?._id || "");
|
|
7939
7999
|
const tryRecord = (record) => {
|
|
7940
8000
|
const parsed = readSenderFromRecord(record);
|
|
@@ -7951,9 +8011,9 @@ function resolveSenderName(msg, ctx) {
|
|
|
7951
8011
|
const hit = tryRecord(record);
|
|
7952
8012
|
if (hit) return hit;
|
|
7953
8013
|
}
|
|
7954
|
-
if (
|
|
8014
|
+
if (messageId2 && ctx.conversationMessages?.length) {
|
|
7955
8015
|
const found = ctx.conversationMessages.find(
|
|
7956
|
-
(m) => String(m._id || m.id) === String(
|
|
8016
|
+
(m) => String(m._id || m.id) === String(messageId2)
|
|
7957
8017
|
);
|
|
7958
8018
|
if (found) {
|
|
7959
8019
|
const hit = tryRecord(found);
|
|
@@ -8004,7 +8064,7 @@ function parseSavedMessage(msg, ctx = {}) {
|
|
|
8004
8064
|
const mode = ctx.mode || "pinned";
|
|
8005
8065
|
const prefs = ctx.dateTimePrefs ?? {};
|
|
8006
8066
|
if (msg?.isAttachment) {
|
|
8007
|
-
const
|
|
8067
|
+
const messageId3 = String(msg.messageId || "");
|
|
8008
8068
|
const attachmentId2 = String(msg.attachmentId || msg._id || "");
|
|
8009
8069
|
const attachments2 = mapSavedMessageAttachments(msg, null, ctx);
|
|
8010
8070
|
const { content: content2, previewUrl: previewUrl2, messageType: messageType2 } = resolveSavedMessageContent(null, msg);
|
|
@@ -8012,8 +8072,8 @@ function parseSavedMessage(msg, ctx = {}) {
|
|
|
8012
8072
|
const actionAt2 = msg?.createdAt || msg?.updatedAt || "";
|
|
8013
8073
|
const bodyText2 = String(msg.attachment?.caption || "").trim() || void 0;
|
|
8014
8074
|
return {
|
|
8015
|
-
id: attachmentId2 ||
|
|
8016
|
-
messageId:
|
|
8075
|
+
id: attachmentId2 || messageId3,
|
|
8076
|
+
messageId: messageId3,
|
|
8017
8077
|
attachmentId: attachmentId2 || void 0,
|
|
8018
8078
|
content: content2,
|
|
8019
8079
|
bodyText: bodyText2,
|
|
@@ -8032,7 +8092,7 @@ function parseSavedMessage(msg, ctx = {}) {
|
|
|
8032
8092
|
}
|
|
8033
8093
|
const messageObj = getMessageObject(msg);
|
|
8034
8094
|
const id = getMessageId(msg);
|
|
8035
|
-
const
|
|
8095
|
+
const messageId2 = id;
|
|
8036
8096
|
const attachmentId = msg?.attachmentId ? String(msg.attachmentId) : void 0;
|
|
8037
8097
|
const attachments = mapSavedMessageAttachments(msg, messageObj, ctx);
|
|
8038
8098
|
const rawContent = messageObj?.content ?? msg?.content ?? msg?.messageId?.content ?? "";
|
|
@@ -8054,8 +8114,8 @@ function parseSavedMessage(msg, ctx = {}) {
|
|
|
8054
8114
|
metaLabel = "Starred by you";
|
|
8055
8115
|
}
|
|
8056
8116
|
return {
|
|
8057
|
-
id: attachmentId ? `${
|
|
8058
|
-
messageId,
|
|
8117
|
+
id: attachmentId ? `${messageId2}:${attachmentId}` : id,
|
|
8118
|
+
messageId: messageId2,
|
|
8059
8119
|
attachmentId,
|
|
8060
8120
|
content: displayContent,
|
|
8061
8121
|
bodyText,
|
|
@@ -8085,6 +8145,22 @@ function groupSavedMessages(items) {
|
|
|
8085
8145
|
}));
|
|
8086
8146
|
}
|
|
8087
8147
|
|
|
8148
|
+
// src/chat/lib/chat-attachment-display.ts
|
|
8149
|
+
init_chat_constants();
|
|
8150
|
+
function cleanAttachmentDisplayName(filename, fallback = "Attachment") {
|
|
8151
|
+
const trimmed = filename.trim();
|
|
8152
|
+
if (!trimmed) return fallback;
|
|
8153
|
+
let name = trimmed;
|
|
8154
|
+
const prefixPattern = new RegExp(`^\\d{${ATTACHMENT_FILENAME_TIMESTAMP_LENGTH}}_`);
|
|
8155
|
+
while (prefixPattern.test(name)) {
|
|
8156
|
+
name = name.slice(ATTACHMENT_FILENAME_TIMESTAMP_LENGTH + 1);
|
|
8157
|
+
}
|
|
8158
|
+
if (name.length > ATTACHMENT_FILENAME_TIMESTAMP_LENGTH && /^\d+$/.test(name.slice(0, ATTACHMENT_FILENAME_TIMESTAMP_LENGTH)) && name[ATTACHMENT_FILENAME_TIMESTAMP_LENGTH] !== "_") {
|
|
8159
|
+
name = name.slice(ATTACHMENT_FILENAME_TIMESTAMP_LENGTH);
|
|
8160
|
+
}
|
|
8161
|
+
return name.trim() || trimmed;
|
|
8162
|
+
}
|
|
8163
|
+
|
|
8088
8164
|
// src/chat/header/saved-message/saved-message-utils.ts
|
|
8089
8165
|
var AVATAR_PALETTES = [
|
|
8090
8166
|
"bg-violet-500/15 text-violet-600 dark:text-violet-300",
|
|
@@ -8506,6 +8582,18 @@ var MessageStatus = ({ status, isPending, className }) => {
|
|
|
8506
8582
|
) });
|
|
8507
8583
|
};
|
|
8508
8584
|
var MessageStatus_default = MessageStatus;
|
|
8585
|
+
function GroupSenderName({ name, className }) {
|
|
8586
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
8587
|
+
"span",
|
|
8588
|
+
{
|
|
8589
|
+
className: cn(
|
|
8590
|
+
"block max-w-full truncate text-[13px] font-semibold leading-[1.15] tracking-tight text-(--chat-incoming-text)",
|
|
8591
|
+
className
|
|
8592
|
+
),
|
|
8593
|
+
children: name
|
|
8594
|
+
}
|
|
8595
|
+
);
|
|
8596
|
+
}
|
|
8509
8597
|
function ForwardDoubleIcon({ className }) {
|
|
8510
8598
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
8511
8599
|
"svg",
|
|
@@ -8543,22 +8631,10 @@ function MessageForwardedLabel({ isSender, className, overlay }) {
|
|
|
8543
8631
|
}
|
|
8544
8632
|
);
|
|
8545
8633
|
}
|
|
8546
|
-
function GroupSenderName({ name, className }) {
|
|
8547
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
8548
|
-
"span",
|
|
8549
|
-
{
|
|
8550
|
-
className: cn(
|
|
8551
|
-
"block max-w-full truncate text-[13px] font-semibold leading-[1.15] tracking-tight text-(--chat-incoming-text)",
|
|
8552
|
-
className
|
|
8553
|
-
),
|
|
8554
|
-
children: name
|
|
8555
|
-
}
|
|
8556
|
-
);
|
|
8557
|
-
}
|
|
8558
8634
|
|
|
8559
8635
|
// src/chat/lib/chat-message-bubble.ts
|
|
8560
|
-
function getBubbleCornerClasses() {
|
|
8561
|
-
return "rounded-tl-[18px] rounded-tr-[18px] rounded-br-[18px] rounded-bl-none";
|
|
8636
|
+
function getBubbleCornerClasses(isSender) {
|
|
8637
|
+
return isSender ? "rounded-tl-[18px] rounded-tr-[18px] rounded-bl-[18px] rounded-br-none" : "rounded-tl-[18px] rounded-tr-[18px] rounded-br-[18px] rounded-bl-none";
|
|
8562
8638
|
}
|
|
8563
8639
|
function getChatBubbleClasses({
|
|
8564
8640
|
isSender = false,
|
|
@@ -8569,7 +8645,7 @@ function getChatBubbleClasses({
|
|
|
8569
8645
|
const isNeutral = resolvedSurface === "neutral";
|
|
8570
8646
|
return cn(
|
|
8571
8647
|
"relative",
|
|
8572
|
-
getBubbleCornerClasses(),
|
|
8648
|
+
getBubbleCornerClasses(isSender),
|
|
8573
8649
|
resolvedSurface === "sent" && "chat-bubble-sent bg-(--chat-theme) text-white",
|
|
8574
8650
|
resolvedSurface === "received" && "chat-bubble-received border border-(--chat-border)/60 bg-(--chat-incoming-bubble) text-(--chat-incoming-text)",
|
|
8575
8651
|
isNeutral && "chat-bubble-received border border-(--chat-border)/60 bg-(--chat-incoming-bubble) text-(--chat-incoming-text)",
|
|
@@ -10359,7 +10435,8 @@ function MessageAttachmentsView({
|
|
|
10359
10435
|
isGroupedWithPrev = false,
|
|
10360
10436
|
isGroupedWithNext = false,
|
|
10361
10437
|
showSenderLabel = false,
|
|
10362
|
-
senderName
|
|
10438
|
+
senderName,
|
|
10439
|
+
senderId
|
|
10363
10440
|
}) {
|
|
10364
10441
|
const [documentPreview, setDocumentPreview] = React2.useState(null);
|
|
10365
10442
|
const visibleAttachments = getVisibleAttachments(attachments);
|
|
@@ -10416,7 +10493,13 @@ function MessageAttachmentsView({
|
|
|
10416
10493
|
isImageOnlyBubble ? "px-2.5 pt-1.5 pb-1" : "px-0.5 pb-0.5"
|
|
10417
10494
|
),
|
|
10418
10495
|
children: [
|
|
10419
|
-
canShowSenderName ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
10496
|
+
canShowSenderName ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
10497
|
+
GroupSenderName,
|
|
10498
|
+
{
|
|
10499
|
+
name: senderName,
|
|
10500
|
+
colorSeed: senderId || senderName
|
|
10501
|
+
}
|
|
10502
|
+
) : null,
|
|
10420
10503
|
showForwardedInHeader ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
10421
10504
|
MessageForwardedLabel,
|
|
10422
10505
|
{
|
|
@@ -10960,7 +11043,7 @@ function collectConversationAttachments(messages) {
|
|
|
10960
11043
|
const items = [];
|
|
10961
11044
|
for (const message of messages) {
|
|
10962
11045
|
if (message?.isDeletedForEveryone) continue;
|
|
10963
|
-
const
|
|
11046
|
+
const messageId2 = String(message._id || message.id || "");
|
|
10964
11047
|
const createdAt = message.createdAt || message.timestamp;
|
|
10965
11048
|
const messageType = message.type || "text";
|
|
10966
11049
|
for (const attachment of message.attachments || []) {
|
|
@@ -10978,13 +11061,35 @@ function collectConversationAttachments(messages) {
|
|
|
10978
11061
|
url,
|
|
10979
11062
|
name,
|
|
10980
11063
|
type: resolveFileCategory(name, fileType, resolvedType),
|
|
10981
|
-
messageId,
|
|
11064
|
+
messageId: messageId2,
|
|
10982
11065
|
createdAt,
|
|
10983
11066
|
size: typeof attachment.size === "number" ? attachment.size : void 0,
|
|
10984
11067
|
duration: typeof attachment.duration === "number" ? attachment.duration : void 0,
|
|
10985
11068
|
fileType
|
|
10986
11069
|
});
|
|
10987
11070
|
}
|
|
11071
|
+
if ((message.attachments || []).length === 0) {
|
|
11072
|
+
const rootUrl = message.url || message.fileUrl || message.attachmentUrl || message.public_link || message.publicLink || "";
|
|
11073
|
+
if (!rootUrl) continue;
|
|
11074
|
+
const name = message.filename || message.fileName || message.name || "Attachment";
|
|
11075
|
+
const fileType = message.fileType || message.mimeType || "";
|
|
11076
|
+
const dedupeKey = `${rootUrl}|${name}`;
|
|
11077
|
+
if (seen.has(dedupeKey)) continue;
|
|
11078
|
+
seen.add(dedupeKey);
|
|
11079
|
+
const baseType = inferAttachmentType(fileType, name);
|
|
11080
|
+
const resolvedType = messageType === "image" && baseType === "file" ? "image" : baseType;
|
|
11081
|
+
items.push({
|
|
11082
|
+
id: String(message.attachmentId || message.fileId || dedupeKey),
|
|
11083
|
+
url: rootUrl,
|
|
11084
|
+
name,
|
|
11085
|
+
type: resolveFileCategory(name, fileType, resolvedType),
|
|
11086
|
+
messageId: messageId2,
|
|
11087
|
+
createdAt,
|
|
11088
|
+
size: typeof message.size === "number" ? message.size : void 0,
|
|
11089
|
+
duration: typeof message.duration === "number" ? message.duration : void 0,
|
|
11090
|
+
fileType
|
|
11091
|
+
});
|
|
11092
|
+
}
|
|
10988
11093
|
}
|
|
10989
11094
|
return items.sort(
|
|
10990
11095
|
(a, b) => new Date(b.createdAt || 0).getTime() - new Date(a.createdAt || 0).getTime()
|
|
@@ -11195,9 +11300,13 @@ function AttachmentSection({
|
|
|
11195
11300
|
}
|
|
11196
11301
|
var AttachmentsDrawer = ({ isOpen, onOpenChange, conversationId }) => {
|
|
11197
11302
|
const messagesByConversation = exports.useChatStore((s) => s.messagesByConversation);
|
|
11303
|
+
const messagesMetadata = exports.useChatStore((s) => s.messagesMetadata);
|
|
11304
|
+
const fetchMessages2 = exports.useChatStore((s) => s.fetchMessages);
|
|
11198
11305
|
const [sectionVisibleCount, setSectionVisibleCount] = React2.useState({});
|
|
11199
11306
|
const [documentPreview, setDocumentPreview] = React2.useState(null);
|
|
11200
11307
|
const [imageLightboxIndex, setImageLightboxIndex] = React2.useState(null);
|
|
11308
|
+
const hasLoadedMessages = conversationId ? Boolean(messagesMetadata[conversationId]?.isFirstPage) : false;
|
|
11309
|
+
const isLoading = isOpen && !!conversationId && !hasLoadedMessages;
|
|
11201
11310
|
React2.useEffect(() => {
|
|
11202
11311
|
if (!isOpen) {
|
|
11203
11312
|
setSectionVisibleCount({});
|
|
@@ -11208,6 +11317,10 @@ var AttachmentsDrawer = ({ isOpen, onOpenChange, conversationId }) => {
|
|
|
11208
11317
|
React2.useEffect(() => {
|
|
11209
11318
|
setSectionVisibleCount({});
|
|
11210
11319
|
}, [conversationId]);
|
|
11320
|
+
React2.useEffect(() => {
|
|
11321
|
+
if (!isOpen || !conversationId || hasLoadedMessages) return;
|
|
11322
|
+
fetchMessages2(conversationId);
|
|
11323
|
+
}, [isOpen, conversationId, hasLoadedMessages, fetchMessages2]);
|
|
11211
11324
|
const attachments = React2.useMemo(() => {
|
|
11212
11325
|
if (!conversationId) return [];
|
|
11213
11326
|
const messages = messagesByConversation[conversationId] || [];
|
|
@@ -11259,7 +11372,11 @@ var AttachmentsDrawer = ({ isOpen, onOpenChange, conversationId }) => {
|
|
|
11259
11372
|
] }),
|
|
11260
11373
|
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "mt-1 text-[11px] text-(--chat-muted)", children: "Shared media and files" })
|
|
11261
11374
|
] }) }),
|
|
11262
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "chat-message-scroll flex-1 overflow-y-auto bg-(--chat-main-bg) px-2.5 py-2", children:
|
|
11375
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "chat-message-scroll flex-1 overflow-y-auto bg-(--chat-main-bg) px-2.5 py-2", children: isLoading ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex min-h-[220px] flex-col items-center justify-center px-4 text-center", children: [
|
|
11376
|
+
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.Loader2, { className: "mb-3 size-8 animate-spin text-(--chat-theme)" }),
|
|
11377
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-[13px] font-medium text-(--chat-text)", children: "Loading attachments..." }),
|
|
11378
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "mt-1 text-[11px] text-(--chat-muted)", children: "Fetching shared files for this chat" })
|
|
11379
|
+
] }) : attachments.length === 0 ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "chat-saved-empty flex min-h-[220px] flex-col items-center justify-center px-4 text-center", children: [
|
|
11263
11380
|
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "mb-3", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "chat-saved-empty-icon-wrap", children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Paperclip, { size: 22, className: cn("chat-saved-empty-icon !text-(--chat-theme)") }) }) }),
|
|
11264
11381
|
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-[14px] font-semibold text-(--chat-text)", children: "No attachments" }),
|
|
11265
11382
|
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "mt-1.5 max-w-[240px] text-[12px] leading-relaxed text-(--chat-muted)", children: "Shared files will show up here." })
|
|
@@ -11642,7 +11759,7 @@ var ChannelDetailsDrawer = (props) => {
|
|
|
11642
11759
|
{
|
|
11643
11760
|
type: "button",
|
|
11644
11761
|
onClick: () => fileInputRef.current?.click(),
|
|
11645
|
-
className: "absolute -bottom-0.5 -right-0.5 flex size-6 items-center justify-center rounded-full border border-(--chat-border) bg-(--chat-surface) text-(--chat-
|
|
11762
|
+
className: "absolute -bottom-0.5 -right-0.5 flex size-6 items-center justify-center rounded-full border border-(--chat-border) bg-(--chat-surface) text-(--chat-theme) shadow-sm hover:bg-(--chat-theme-10)",
|
|
11646
11763
|
title: "Change group avatar",
|
|
11647
11764
|
children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Camera, { size: 12 })
|
|
11648
11765
|
}
|
|
@@ -11681,7 +11798,7 @@ var ChannelDetailsDrawer = (props) => {
|
|
|
11681
11798
|
{
|
|
11682
11799
|
variant: "outline",
|
|
11683
11800
|
size: "sm",
|
|
11684
|
-
className: "h-8 flex-1 text-[12px]",
|
|
11801
|
+
className: "h-8 flex-1 border-(--chat-border) bg-(--chat-surface) text-[12px] text-(--chat-text) hover:bg-(--chat-hover)",
|
|
11685
11802
|
onClick: () => setIsEditing(false),
|
|
11686
11803
|
children: [
|
|
11687
11804
|
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.X, { className: "mr-1 size-3" }),
|
|
@@ -11693,7 +11810,7 @@ var ChannelDetailsDrawer = (props) => {
|
|
|
11693
11810
|
Button,
|
|
11694
11811
|
{
|
|
11695
11812
|
size: "sm",
|
|
11696
|
-
className: "h-8 flex-1 text-[12px]",
|
|
11813
|
+
className: "h-8 flex-1 border border-(--chat-theme) bg-(--chat-theme) text-[12px] text-white hover:opacity-90 disabled:opacity-50",
|
|
11697
11814
|
onClick: handleSave,
|
|
11698
11815
|
disabled: isSaving || imageUploadStatus === "uploading",
|
|
11699
11816
|
children: isSaving ? /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Loader2, { className: "size-3 animate-spin" }) : /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
@@ -11711,7 +11828,7 @@ var ChannelDetailsDrawer = (props) => {
|
|
|
11711
11828
|
{
|
|
11712
11829
|
variant: "ghost",
|
|
11713
11830
|
size: "sm",
|
|
11714
|
-
className: "mt-2 h-7 gap-1 px-2 text-[11px] text-(--chat-
|
|
11831
|
+
className: "mt-2 h-7 gap-1 px-2 text-[11px] text-(--chat-theme) hover:bg-(--chat-theme-10) hover:text-(--chat-theme)",
|
|
11715
11832
|
onClick: () => setIsEditing(true),
|
|
11716
11833
|
children: [
|
|
11717
11834
|
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.Pencil, { className: "size-3" }),
|
|
@@ -12569,8 +12686,8 @@ function useChannelHeader({
|
|
|
12569
12686
|
}
|
|
12570
12687
|
}
|
|
12571
12688
|
};
|
|
12572
|
-
const handleSelectSearchResult = async (
|
|
12573
|
-
await fetchSearchMessageContext(
|
|
12689
|
+
const handleSelectSearchResult = async (messageId2) => {
|
|
12690
|
+
await fetchSearchMessageContext(messageId2);
|
|
12574
12691
|
handleCloseSearch();
|
|
12575
12692
|
};
|
|
12576
12693
|
const handleSearchOpenChange = (open) => {
|
|
@@ -12606,6 +12723,14 @@ function useChannelHeader({
|
|
|
12606
12723
|
fetchStarredMessages2(conversationId);
|
|
12607
12724
|
}
|
|
12608
12725
|
}, [state.isFavoriteOpen, conversationId, fetchStarredMessages2]);
|
|
12726
|
+
React2.useEffect(() => {
|
|
12727
|
+
if (state.isAttachmentsOpen && conversationId) {
|
|
12728
|
+
const meta = exports.useChatStore.getState().messagesMetadata[conversationId];
|
|
12729
|
+
if (!meta?.isFirstPage) {
|
|
12730
|
+
fetchMessagesStore(conversationId);
|
|
12731
|
+
}
|
|
12732
|
+
}
|
|
12733
|
+
}, [state.isAttachmentsOpen, conversationId, fetchMessagesStore]);
|
|
12609
12734
|
const pinnedCount = liveCounts?.pinnedCount ?? activeChannel?.pinnedCount ?? 0;
|
|
12610
12735
|
const starredCount = liveCounts?.starredCount ?? activeChannel?.starredCount ?? 0;
|
|
12611
12736
|
const handleClearChat = () => {
|
|
@@ -12651,14 +12776,14 @@ function useChannelHeader({
|
|
|
12651
12776
|
updateState({ isBlockAlertOpen: false });
|
|
12652
12777
|
}
|
|
12653
12778
|
};
|
|
12654
|
-
const handleUnpin = (
|
|
12779
|
+
const handleUnpin = (messageId2, attachmentId) => {
|
|
12655
12780
|
if (!loggedUserDetails?._id || !conversationId || !activeChannel) return;
|
|
12656
|
-
const loadingKey = attachmentId ? `${
|
|
12781
|
+
const loadingKey = attachmentId ? `${messageId2}:${attachmentId}` : messageId2;
|
|
12657
12782
|
updateState({ loadingIds: new Set(state.loadingIds).add(loadingKey) });
|
|
12658
12783
|
const basePayload = {
|
|
12659
12784
|
conversationId,
|
|
12660
12785
|
sender: loggedUserDetails._id,
|
|
12661
|
-
messageId,
|
|
12786
|
+
messageId: messageId2,
|
|
12662
12787
|
receiver: activeChannel.id,
|
|
12663
12788
|
...attachmentId ? { attachmentId } : {}
|
|
12664
12789
|
};
|
|
@@ -12678,12 +12803,12 @@ function useChannelHeader({
|
|
|
12678
12803
|
if (!dateStr) return "";
|
|
12679
12804
|
return formatLongDate(dateStr);
|
|
12680
12805
|
};
|
|
12681
|
-
const handleUnstar = (
|
|
12806
|
+
const handleUnstar = (messageId2, attachmentId) => {
|
|
12682
12807
|
if (!loggedUserDetails?._id || !conversationId || !activeChannel) return;
|
|
12683
|
-
const loadingKey = attachmentId ? `${
|
|
12808
|
+
const loadingKey = attachmentId ? `${messageId2}:${attachmentId}` : messageId2;
|
|
12684
12809
|
updateState({ loadingIds: new Set(state.loadingIds).add(loadingKey) });
|
|
12685
12810
|
const basePayload = {
|
|
12686
|
-
messageId,
|
|
12811
|
+
messageId: messageId2,
|
|
12687
12812
|
sender: loggedUserDetails._id,
|
|
12688
12813
|
conversationId,
|
|
12689
12814
|
receiver: activeChannel.id,
|
|
@@ -12953,7 +13078,7 @@ var MessageReactions = ({
|
|
|
12953
13078
|
{
|
|
12954
13079
|
onClick: () => onReactionClick(emoji),
|
|
12955
13080
|
className: cn(
|
|
12956
|
-
"flex items-center gap-
|
|
13081
|
+
"flex items-center gap-0.5 px-1.5 py-0.5 rounded-full text-[11px] border shadow-[0_1px_3px_rgba(15,23,42,0.08)] transition-all outline-none",
|
|
12957
13082
|
isReactedByMe ? "bg-(--chat-theme-10) border-(--chat-theme-20) text-(--chat-theme)" : "bg-(--chat-surface) border-(--chat-border) text-(--chat-text) hover:bg-(--chat-hover)"
|
|
12958
13083
|
),
|
|
12959
13084
|
children: [
|
|
@@ -13007,7 +13132,7 @@ var MessageToolbar = ({
|
|
|
13007
13132
|
"div",
|
|
13008
13133
|
{
|
|
13009
13134
|
className: cn(
|
|
13010
|
-
"absolute -top-8 z-
|
|
13135
|
+
"absolute -top-8 z-50 flex items-center gap-0.5 rounded-full border border-(--chat-border) p-0.5 shadow-md backdrop-blur-sm",
|
|
13011
13136
|
"bg-(--chat-toolbar-bg) text-(--chat-text)",
|
|
13012
13137
|
isSender ? "right-0" : "left-0"
|
|
13013
13138
|
),
|
|
@@ -13283,8 +13408,8 @@ init_useStore();
|
|
|
13283
13408
|
|
|
13284
13409
|
// src/chat/lib/chat-selection.ts
|
|
13285
13410
|
init_attachment_helpers();
|
|
13286
|
-
function buildSelectionKey(
|
|
13287
|
-
return pinKey(
|
|
13411
|
+
function buildSelectionKey(messageId2, attachmentId) {
|
|
13412
|
+
return pinKey(messageId2, attachmentId || null);
|
|
13288
13413
|
}
|
|
13289
13414
|
function parseSelectionKey(key) {
|
|
13290
13415
|
const colonIndex = key.indexOf(":");
|
|
@@ -13299,8 +13424,8 @@ function parseSelectionKey(key) {
|
|
|
13299
13424
|
function messageUsesAttachmentSelection(message) {
|
|
13300
13425
|
return getVisibleAttachments(message.attachments).length > 1;
|
|
13301
13426
|
}
|
|
13302
|
-
function getSelectedAttachmentIdsForMessage(selectedKeys,
|
|
13303
|
-
const prefix = `${
|
|
13427
|
+
function getSelectedAttachmentIdsForMessage(selectedKeys, messageId2) {
|
|
13428
|
+
const prefix = `${messageId2}:`;
|
|
13304
13429
|
const ids = /* @__PURE__ */ new Set();
|
|
13305
13430
|
selectedKeys.forEach((key) => {
|
|
13306
13431
|
if (key.startsWith(prefix)) {
|
|
@@ -13309,14 +13434,14 @@ function getSelectedAttachmentIdsForMessage(selectedKeys, messageId) {
|
|
|
13309
13434
|
});
|
|
13310
13435
|
return ids;
|
|
13311
13436
|
}
|
|
13312
|
-
function isMessageWhollySelected(selectedKeys,
|
|
13313
|
-
return selectedKeys.has(
|
|
13437
|
+
function isMessageWhollySelected(selectedKeys, messageId2) {
|
|
13438
|
+
return selectedKeys.has(messageId2);
|
|
13314
13439
|
}
|
|
13315
13440
|
function resolveForwardItems(selectedKeys, messages) {
|
|
13316
13441
|
const items = [];
|
|
13317
13442
|
selectedKeys.forEach((key) => {
|
|
13318
|
-
const { messageId, attachmentId } = parseSelectionKey(key);
|
|
13319
|
-
const message = messages.find((entry) => String(entry._id || entry.id) ===
|
|
13443
|
+
const { messageId: messageId2, attachmentId } = parseSelectionKey(key);
|
|
13444
|
+
const message = messages.find((entry) => String(entry._id || entry.id) === messageId2);
|
|
13320
13445
|
if (!message) return;
|
|
13321
13446
|
items.push({ message, attachmentId });
|
|
13322
13447
|
});
|
|
@@ -13342,7 +13467,7 @@ function useMessageItemActions({
|
|
|
13342
13467
|
message,
|
|
13343
13468
|
createdAt,
|
|
13344
13469
|
attachments,
|
|
13345
|
-
messageId,
|
|
13470
|
+
messageId: messageId2,
|
|
13346
13471
|
receiver,
|
|
13347
13472
|
isDeletedForEveryone,
|
|
13348
13473
|
reactions,
|
|
@@ -13394,10 +13519,10 @@ function useMessageItemActions({
|
|
|
13394
13519
|
const allUsers = exports.useChatStore((s) => s.allUsers);
|
|
13395
13520
|
const loggedUserDetails = exports.useChatStore((s) => s.loggedUserDetails);
|
|
13396
13521
|
const pinnedMessagesByConversation = exports.useChatStore((s) => s.pinnedMessagesByConversation);
|
|
13397
|
-
const mid = String(
|
|
13522
|
+
const mid = String(messageId2 || "");
|
|
13398
13523
|
const pendingActions = mid ? messagePendingActions[mid] || [] : [];
|
|
13399
13524
|
const isPending = Boolean(
|
|
13400
|
-
isSender && (String(
|
|
13525
|
+
isSender && (String(messageId2 || "").startsWith("temp-") || mid && (messagePendingActions[mid] || []).includes("send"))
|
|
13401
13526
|
);
|
|
13402
13527
|
const isEditPending = pendingActions.includes("edit");
|
|
13403
13528
|
const isDeletePending = pendingActions.includes("delete");
|
|
@@ -13435,13 +13560,13 @@ function useMessageItemActions({
|
|
|
13435
13560
|
};
|
|
13436
13561
|
const handleSaveAttachmentCaption = (caption, attachment) => {
|
|
13437
13562
|
const target = attachment ?? state.captionModalAttachment;
|
|
13438
|
-
if (!
|
|
13563
|
+
if (!messageId2 || !loggedUserDetails || !target) return;
|
|
13439
13564
|
const attachmentId = target.id;
|
|
13440
13565
|
if (isGroup) {
|
|
13441
13566
|
if (!conversationId) return;
|
|
13442
13567
|
emitGroupEdit({
|
|
13443
13568
|
content: caption,
|
|
13444
|
-
messageId,
|
|
13569
|
+
messageId: messageId2,
|
|
13445
13570
|
sender: loggedUserDetails._id,
|
|
13446
13571
|
conversationId,
|
|
13447
13572
|
attachmentId
|
|
@@ -13450,7 +13575,7 @@ function useMessageItemActions({
|
|
|
13450
13575
|
if (!receiver) return;
|
|
13451
13576
|
emitDmEdit({
|
|
13452
13577
|
content: caption,
|
|
13453
|
-
messageId,
|
|
13578
|
+
messageId: messageId2,
|
|
13454
13579
|
sender: loggedUserDetails._id,
|
|
13455
13580
|
receiver,
|
|
13456
13581
|
attachmentId
|
|
@@ -13467,12 +13592,12 @@ function useMessageItemActions({
|
|
|
13467
13592
|
onEnterSelectionMode?.();
|
|
13468
13593
|
};
|
|
13469
13594
|
const handleSaveEdit = () => {
|
|
13470
|
-
if (!
|
|
13595
|
+
if (!messageId2 || !loggedUserDetails) return;
|
|
13471
13596
|
if (isGroup) {
|
|
13472
13597
|
if (!conversationId) return;
|
|
13473
13598
|
emitGroupEdit({
|
|
13474
13599
|
content: state.editValue.trim(),
|
|
13475
|
-
messageId,
|
|
13600
|
+
messageId: messageId2,
|
|
13476
13601
|
sender: loggedUserDetails._id,
|
|
13477
13602
|
conversationId
|
|
13478
13603
|
});
|
|
@@ -13480,7 +13605,7 @@ function useMessageItemActions({
|
|
|
13480
13605
|
if (!receiver) return;
|
|
13481
13606
|
emitDmEdit({
|
|
13482
13607
|
content: state.editValue.trim(),
|
|
13483
|
-
messageId,
|
|
13608
|
+
messageId: messageId2,
|
|
13484
13609
|
sender: loggedUserDetails._id,
|
|
13485
13610
|
receiver
|
|
13486
13611
|
});
|
|
@@ -13491,7 +13616,7 @@ function useMessageItemActions({
|
|
|
13491
13616
|
updateState({ isEditing: false, editValue: message });
|
|
13492
13617
|
};
|
|
13493
13618
|
const handleDeleteMessage = (deleteType) => {
|
|
13494
|
-
if (!
|
|
13619
|
+
if (!messageId2 || !loggedUserDetails) return;
|
|
13495
13620
|
if (deleteType === "everyone" && !isSender) return;
|
|
13496
13621
|
if (deleteType === "everyone" && !isWithinEditWindow()) return;
|
|
13497
13622
|
const attachmentIds = hasAttachments ? deleteAttachmentIds : [];
|
|
@@ -13499,7 +13624,7 @@ function useMessageItemActions({
|
|
|
13499
13624
|
if (isGroup) {
|
|
13500
13625
|
if (!conversationId) return;
|
|
13501
13626
|
emitGroupDelete({
|
|
13502
|
-
messageId,
|
|
13627
|
+
messageId: messageId2,
|
|
13503
13628
|
sender: loggedUserDetails._id,
|
|
13504
13629
|
deleteType,
|
|
13505
13630
|
conversationId,
|
|
@@ -13508,7 +13633,7 @@ function useMessageItemActions({
|
|
|
13508
13633
|
} else {
|
|
13509
13634
|
if (!receiver) return;
|
|
13510
13635
|
emitDmDelete({
|
|
13511
|
-
messageId,
|
|
13636
|
+
messageId: messageId2,
|
|
13512
13637
|
sender: loggedUserDetails._id,
|
|
13513
13638
|
receiver,
|
|
13514
13639
|
deleteType,
|
|
@@ -13530,7 +13655,7 @@ function useMessageItemActions({
|
|
|
13530
13655
|
onForward?.();
|
|
13531
13656
|
};
|
|
13532
13657
|
const handleReactionClick = (emojiObject) => {
|
|
13533
|
-
if (!
|
|
13658
|
+
if (!messageId2 || !loggedUserDetails) return;
|
|
13534
13659
|
const reaction = typeof emojiObject === "string" ? emojiObject : emojiObject.emoji || emojiObject.native;
|
|
13535
13660
|
const hasReacted = reactions?.some(
|
|
13536
13661
|
(r) => r.reaction === reaction && String(r.addedBy?._id || r.addedBy || r.sender?._id || r.sender) === String(loggedUserDetails._id)
|
|
@@ -13539,7 +13664,7 @@ function useMessageItemActions({
|
|
|
13539
13664
|
if (isGroup) {
|
|
13540
13665
|
if (!conversationId) return;
|
|
13541
13666
|
emitGroupReactionRemove({
|
|
13542
|
-
messageId,
|
|
13667
|
+
messageId: messageId2,
|
|
13543
13668
|
sender: loggedUserDetails._id,
|
|
13544
13669
|
reaction,
|
|
13545
13670
|
conversationId
|
|
@@ -13547,7 +13672,7 @@ function useMessageItemActions({
|
|
|
13547
13672
|
} else {
|
|
13548
13673
|
if (!receiver) return;
|
|
13549
13674
|
emitDmReactionRemove({
|
|
13550
|
-
messageId,
|
|
13675
|
+
messageId: messageId2,
|
|
13551
13676
|
sender: loggedUserDetails._id,
|
|
13552
13677
|
receiver,
|
|
13553
13678
|
reaction,
|
|
@@ -13558,7 +13683,7 @@ function useMessageItemActions({
|
|
|
13558
13683
|
if (isGroup) {
|
|
13559
13684
|
if (!conversationId) return;
|
|
13560
13685
|
emitGroupReactionAdd({
|
|
13561
|
-
messageId,
|
|
13686
|
+
messageId: messageId2,
|
|
13562
13687
|
sender: loggedUserDetails._id,
|
|
13563
13688
|
reaction,
|
|
13564
13689
|
conversationId
|
|
@@ -13566,7 +13691,7 @@ function useMessageItemActions({
|
|
|
13566
13691
|
} else {
|
|
13567
13692
|
if (!receiver) return;
|
|
13568
13693
|
emitDmReactionAdd({
|
|
13569
|
-
messageId,
|
|
13694
|
+
messageId: messageId2,
|
|
13570
13695
|
sender: loggedUserDetails._id,
|
|
13571
13696
|
receiver,
|
|
13572
13697
|
reaction,
|
|
@@ -13576,7 +13701,7 @@ function useMessageItemActions({
|
|
|
13576
13701
|
}
|
|
13577
13702
|
};
|
|
13578
13703
|
const handlePinClick = () => {
|
|
13579
|
-
if (!
|
|
13704
|
+
if (!messageId2 || !loggedUserDetails) return;
|
|
13580
13705
|
if (isPinned) {
|
|
13581
13706
|
if (!isPinnedByMe) return;
|
|
13582
13707
|
if (isGroup) {
|
|
@@ -13584,14 +13709,14 @@ function useMessageItemActions({
|
|
|
13584
13709
|
emitGroupUnpin({
|
|
13585
13710
|
conversationId,
|
|
13586
13711
|
sender: loggedUserDetails._id,
|
|
13587
|
-
messageId,
|
|
13712
|
+
messageId: messageId2,
|
|
13588
13713
|
receiver: ""
|
|
13589
13714
|
});
|
|
13590
13715
|
} else {
|
|
13591
13716
|
emitDmUnpin({
|
|
13592
13717
|
conversationId,
|
|
13593
13718
|
sender: loggedUserDetails._id,
|
|
13594
|
-
messageId,
|
|
13719
|
+
messageId: messageId2,
|
|
13595
13720
|
receiver: receiver || ""
|
|
13596
13721
|
});
|
|
13597
13722
|
}
|
|
@@ -13601,32 +13726,32 @@ function useMessageItemActions({
|
|
|
13601
13726
|
emitGroupPin({
|
|
13602
13727
|
conversationId,
|
|
13603
13728
|
sender: loggedUserDetails._id,
|
|
13604
|
-
messageId,
|
|
13729
|
+
messageId: messageId2,
|
|
13605
13730
|
receiver: ""
|
|
13606
13731
|
});
|
|
13607
13732
|
} else {
|
|
13608
13733
|
emitDmPin({
|
|
13609
13734
|
conversationId,
|
|
13610
13735
|
sender: loggedUserDetails._id,
|
|
13611
|
-
messageId,
|
|
13736
|
+
messageId: messageId2,
|
|
13612
13737
|
receiver: receiver || ""
|
|
13613
13738
|
});
|
|
13614
13739
|
}
|
|
13615
13740
|
}
|
|
13616
13741
|
};
|
|
13617
13742
|
const handleStarClick = () => {
|
|
13618
|
-
if (!
|
|
13743
|
+
if (!messageId2 || !loggedUserDetails || !conversationId) return;
|
|
13619
13744
|
if (isStarred) {
|
|
13620
13745
|
if (isGroup) {
|
|
13621
|
-
emitGroupUnstar({ messageId, sender: loggedUserDetails._id, conversationId });
|
|
13746
|
+
emitGroupUnstar({ messageId: messageId2, sender: loggedUserDetails._id, conversationId });
|
|
13622
13747
|
} else {
|
|
13623
|
-
emitDmUnstar({ messageId, sender: loggedUserDetails._id, conversationId });
|
|
13748
|
+
emitDmUnstar({ messageId: messageId2, sender: loggedUserDetails._id, conversationId });
|
|
13624
13749
|
}
|
|
13625
13750
|
} else {
|
|
13626
13751
|
if (isGroup) {
|
|
13627
|
-
emitGroupStar({ messageId, sender: loggedUserDetails._id, conversationId });
|
|
13752
|
+
emitGroupStar({ messageId: messageId2, sender: loggedUserDetails._id, conversationId });
|
|
13628
13753
|
} else {
|
|
13629
|
-
emitDmStar({ messageId, sender: loggedUserDetails._id, conversationId });
|
|
13754
|
+
emitDmStar({ messageId: messageId2, sender: loggedUserDetails._id, conversationId });
|
|
13630
13755
|
}
|
|
13631
13756
|
}
|
|
13632
13757
|
};
|
|
@@ -13848,6 +13973,7 @@ function MessageItemTextBubble({
|
|
|
13848
13973
|
isForwarded,
|
|
13849
13974
|
showSenderLabel,
|
|
13850
13975
|
senderName,
|
|
13976
|
+
senderId,
|
|
13851
13977
|
replyTo,
|
|
13852
13978
|
loggedUserDetails,
|
|
13853
13979
|
allUsers,
|
|
@@ -13886,7 +14012,13 @@ function MessageItemTextBubble({
|
|
|
13886
14012
|
),
|
|
13887
14013
|
children: [
|
|
13888
14014
|
(canShowSenderName || isForwarded) && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex min-w-0 flex-col gap-0.5", children: [
|
|
13889
|
-
canShowSenderName ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
14015
|
+
canShowSenderName ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
14016
|
+
GroupSenderName,
|
|
14017
|
+
{
|
|
14018
|
+
name: senderName,
|
|
14019
|
+
colorSeed: senderId || senderName
|
|
14020
|
+
}
|
|
14021
|
+
) : null,
|
|
13890
14022
|
isForwarded ? /* @__PURE__ */ jsxRuntime.jsx(MessageForwardedLabel, { isSender, className: "px-0 pt-0 pb-0" }) : null
|
|
13891
14023
|
] }),
|
|
13892
14024
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -13937,7 +14069,7 @@ function MessageItemTextBubble({
|
|
|
13937
14069
|
}
|
|
13938
14070
|
)
|
|
13939
14071
|
] })
|
|
13940
|
-
] }) : /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-
|
|
14072
|
+
] }) : /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-1", children: [
|
|
13941
14073
|
hasText && /* @__PURE__ */ jsxRuntime.jsxs("p", { className: "whitespace-pre-wrap break-words leading-snug", children: [
|
|
13942
14074
|
message,
|
|
13943
14075
|
isEdited && /* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -13995,6 +14127,7 @@ function MessageItemAttachmentBubble({
|
|
|
13995
14127
|
isGroupedWithNext,
|
|
13996
14128
|
showSenderLabel,
|
|
13997
14129
|
senderName,
|
|
14130
|
+
senderId,
|
|
13998
14131
|
formattedTime,
|
|
13999
14132
|
status,
|
|
14000
14133
|
isPending,
|
|
@@ -14043,6 +14176,7 @@ function MessageItemAttachmentBubble({
|
|
|
14043
14176
|
isGroupedWithNext,
|
|
14044
14177
|
showSenderLabel,
|
|
14045
14178
|
senderName,
|
|
14179
|
+
senderId,
|
|
14046
14180
|
formattedTime,
|
|
14047
14181
|
status,
|
|
14048
14182
|
isPending,
|
|
@@ -14102,6 +14236,7 @@ function MessageItemView(props) {
|
|
|
14102
14236
|
isGroup,
|
|
14103
14237
|
isHighlighted,
|
|
14104
14238
|
senderName,
|
|
14239
|
+
senderId,
|
|
14105
14240
|
senderImage,
|
|
14106
14241
|
showSenderLabel,
|
|
14107
14242
|
senderAvatarImage,
|
|
@@ -14278,6 +14413,7 @@ function MessageItemView(props) {
|
|
|
14278
14413
|
isGroupedWithNext,
|
|
14279
14414
|
showSenderLabel,
|
|
14280
14415
|
senderName,
|
|
14416
|
+
senderId,
|
|
14281
14417
|
formattedTime,
|
|
14282
14418
|
status,
|
|
14283
14419
|
isPending,
|
|
@@ -14319,6 +14455,7 @@ function MessageItemView(props) {
|
|
|
14319
14455
|
isForwarded,
|
|
14320
14456
|
showSenderLabel,
|
|
14321
14457
|
senderName,
|
|
14458
|
+
senderId,
|
|
14322
14459
|
replyTo,
|
|
14323
14460
|
loggedUserDetails,
|
|
14324
14461
|
allUsers,
|
|
@@ -14509,6 +14646,28 @@ function MessageSelectionBar({
|
|
|
14509
14646
|
|
|
14510
14647
|
// src/chat/active-channel-messages/utils.ts
|
|
14511
14648
|
var getMessageSenderId2 = (msg) => msg ? String(msg.senderId || msg.sender?._id || "") : "";
|
|
14649
|
+
var isLikelyObjectId = (value) => /^[a-f\d]{24}$/i.test(value);
|
|
14650
|
+
function resolveGroupSenderDisplay(message, allUsers = [], participants = []) {
|
|
14651
|
+
const senderId = getMessageSenderId2(message);
|
|
14652
|
+
if (senderId) {
|
|
14653
|
+
const fromUsers = allUsers.find((user) => String(user._id) === senderId);
|
|
14654
|
+
if (fromUsers?.name?.trim()) {
|
|
14655
|
+
return { name: fromUsers.name.trim(), image: fromUsers.image };
|
|
14656
|
+
}
|
|
14657
|
+
const fromParticipants = participants.find((participant) => {
|
|
14658
|
+
const id = typeof participant === "string" ? participant : participant?._id;
|
|
14659
|
+
return String(id) === senderId;
|
|
14660
|
+
});
|
|
14661
|
+
if (fromParticipants && typeof fromParticipants === "object" && fromParticipants.name?.trim()) {
|
|
14662
|
+
return { name: fromParticipants.name.trim(), image: fromParticipants.image };
|
|
14663
|
+
}
|
|
14664
|
+
}
|
|
14665
|
+
const sender = message.sender;
|
|
14666
|
+
if (typeof sender === "string" && sender.trim() && !isLikelyObjectId(sender.trim())) {
|
|
14667
|
+
return { name: sender.trim(), image: message.senderImage };
|
|
14668
|
+
}
|
|
14669
|
+
return { name: "User", image: void 0 };
|
|
14670
|
+
}
|
|
14512
14671
|
var isSameMessageSide = (a, b, isGroupChat) => {
|
|
14513
14672
|
if (!!a.isOwnMessage !== !!b.isOwnMessage) return false;
|
|
14514
14673
|
if (a.isOwnMessage) return true;
|
|
@@ -14522,8 +14681,8 @@ function canDeleteSelectionForEveryone(selectedKeys, messages, isGroup) {
|
|
|
14522
14681
|
const parsed = [...selectedKeys].map((key) => parseSelectionKey(key));
|
|
14523
14682
|
const messageIds = new Set(parsed.map((entry) => entry.messageId));
|
|
14524
14683
|
if (messageIds.size !== 1) return false;
|
|
14525
|
-
const
|
|
14526
|
-
const message = messages.find((entry) => String(entry._id || entry.id) ===
|
|
14684
|
+
const messageId2 = [...messageIds][0];
|
|
14685
|
+
const message = messages.find((entry) => String(entry._id || entry.id) === messageId2);
|
|
14527
14686
|
if (!message?.isOwnMessage) return false;
|
|
14528
14687
|
if (!isWithinMessageEditWindow(message.timestamp, isGroup)) return false;
|
|
14529
14688
|
const hasAttachmentKey = parsed.some((entry) => entry.attachmentId);
|
|
@@ -14537,6 +14696,9 @@ function canDeleteSelectionForEveryone(selectedKeys, messages, isGroup) {
|
|
|
14537
14696
|
});
|
|
14538
14697
|
}
|
|
14539
14698
|
|
|
14699
|
+
// src/chat/active-channel-messages/ActiveChannelMessagesView.tsx
|
|
14700
|
+
init_useStore();
|
|
14701
|
+
|
|
14540
14702
|
// src/chat/active-channel-messages/useActiveChannelMessages.ts
|
|
14541
14703
|
init_useStore();
|
|
14542
14704
|
init_store_helpers();
|
|
@@ -14552,6 +14714,7 @@ function mapApiMessage(m, activeChannel, conversationId, loggedUserId, activeCon
|
|
|
14552
14714
|
content: m.content,
|
|
14553
14715
|
sender: m.sender?.name || "User",
|
|
14554
14716
|
senderId: String(m.sender?._id || m.sender || ""),
|
|
14717
|
+
senderImage: m.sender?.image,
|
|
14555
14718
|
receiver: activeChannel?.id,
|
|
14556
14719
|
timestamp: m.createdAt,
|
|
14557
14720
|
isOwnMessage: isOwn,
|
|
@@ -14579,7 +14742,101 @@ function mapApiMessage(m, activeChannel, conversationId, loggedUserId, activeCon
|
|
|
14579
14742
|
};
|
|
14580
14743
|
}
|
|
14581
14744
|
|
|
14745
|
+
// src/chat/active-channel-messages/jump-to-date.ts
|
|
14746
|
+
function startOfLocalDay(date) {
|
|
14747
|
+
return new Date(date.getFullYear(), date.getMonth(), date.getDate()).getTime();
|
|
14748
|
+
}
|
|
14749
|
+
function toDateInputValue(date) {
|
|
14750
|
+
const y = date.getFullYear();
|
|
14751
|
+
const m = String(date.getMonth() + 1).padStart(2, "0");
|
|
14752
|
+
const d = String(date.getDate()).padStart(2, "0");
|
|
14753
|
+
return `${y}-${m}-${d}`;
|
|
14754
|
+
}
|
|
14755
|
+
function clampJumpDate(picked, minDay, maxDay) {
|
|
14756
|
+
if (!Number.isFinite(minDay) || !Number.isFinite(maxDay) || minDay > maxDay) return null;
|
|
14757
|
+
const at = startOfLocalDay(picked);
|
|
14758
|
+
const clamped = Math.min(Math.max(at, minDay), maxDay);
|
|
14759
|
+
return new Date(clamped);
|
|
14760
|
+
}
|
|
14761
|
+
function resolveJumpDateBounds(createdAt, oldestMessageTimestamp, now = /* @__PURE__ */ new Date()) {
|
|
14762
|
+
const today = startOfLocalDay(now);
|
|
14763
|
+
const createdDay = createdAt ? startOfLocalDay(new Date(createdAt)) : null;
|
|
14764
|
+
const oldestDay = oldestMessageTimestamp ? startOfLocalDay(new Date(oldestMessageTimestamp)) : null;
|
|
14765
|
+
let minDay = today;
|
|
14766
|
+
if (createdDay != null && oldestDay != null) {
|
|
14767
|
+
minDay = Math.max(createdDay, oldestDay);
|
|
14768
|
+
} else if (oldestDay != null) {
|
|
14769
|
+
minDay = oldestDay;
|
|
14770
|
+
} else if (createdDay != null) {
|
|
14771
|
+
minDay = createdDay;
|
|
14772
|
+
}
|
|
14773
|
+
return { minDay: Math.min(minDay, today), maxDay: today };
|
|
14774
|
+
}
|
|
14775
|
+
function resolveJumpPreset(preset, now = /* @__PURE__ */ new Date()) {
|
|
14776
|
+
const day = new Date(now.getFullYear(), now.getMonth(), now.getDate());
|
|
14777
|
+
if (preset === "today") return day.getTime();
|
|
14778
|
+
if (preset === "yesterday") {
|
|
14779
|
+
day.setDate(day.getDate() - 1);
|
|
14780
|
+
return day.getTime();
|
|
14781
|
+
}
|
|
14782
|
+
if (preset === "lastWeek") {
|
|
14783
|
+
day.setDate(day.getDate() - 7);
|
|
14784
|
+
return day.getTime();
|
|
14785
|
+
}
|
|
14786
|
+
day.setMonth(day.getMonth() - 1);
|
|
14787
|
+
return day.getTime();
|
|
14788
|
+
}
|
|
14789
|
+
function messageId(m) {
|
|
14790
|
+
return String(m._id || m.id);
|
|
14791
|
+
}
|
|
14792
|
+
function findNearestMessageByDay(messages, targetDay) {
|
|
14793
|
+
let best = messages[0];
|
|
14794
|
+
let bestDist = Infinity;
|
|
14795
|
+
let bestDay = startOfLocalDay(new Date(best.timestamp));
|
|
14796
|
+
for (const m of messages) {
|
|
14797
|
+
const day = startOfLocalDay(new Date(m.timestamp));
|
|
14798
|
+
const dist = Math.abs(day - targetDay);
|
|
14799
|
+
if (dist < bestDist || dist === bestDist && day < bestDay) {
|
|
14800
|
+
best = m;
|
|
14801
|
+
bestDist = dist;
|
|
14802
|
+
bestDay = day;
|
|
14803
|
+
}
|
|
14804
|
+
}
|
|
14805
|
+
return best;
|
|
14806
|
+
}
|
|
14807
|
+
function resolveJumpStep(messages, pending, hasMore) {
|
|
14808
|
+
if (messages.length === 0) {
|
|
14809
|
+
return hasMore ? { action: "loadOlder" } : { action: "done" };
|
|
14810
|
+
}
|
|
14811
|
+
if (pending.kind === "beginning") {
|
|
14812
|
+
if (hasMore) return { action: "loadOlder" };
|
|
14813
|
+
return { action: "scroll", messageId: messageId(messages[0]) };
|
|
14814
|
+
}
|
|
14815
|
+
const oldestDay = startOfLocalDay(new Date(messages[0].timestamp));
|
|
14816
|
+
if (hasMore && oldestDay > pending.at) {
|
|
14817
|
+
return { action: "loadOlder" };
|
|
14818
|
+
}
|
|
14819
|
+
const onDay = messages.find(
|
|
14820
|
+
(m) => startOfLocalDay(new Date(m.timestamp)) === pending.at
|
|
14821
|
+
);
|
|
14822
|
+
if (onDay) {
|
|
14823
|
+
return { action: "scroll", messageId: messageId(onDay) };
|
|
14824
|
+
}
|
|
14825
|
+
const nearest = findNearestMessageByDay(messages, pending.at);
|
|
14826
|
+
return { action: "scroll", messageId: messageId(nearest) };
|
|
14827
|
+
}
|
|
14828
|
+
function smoothScrollToMessage(container, messageEl) {
|
|
14829
|
+
const containerRect = container.getBoundingClientRect();
|
|
14830
|
+
const messageRect = messageEl.getBoundingClientRect();
|
|
14831
|
+
const delta = messageRect.top - containerRect.top - Math.min(120, container.clientHeight * 0.25);
|
|
14832
|
+
container.scrollTo({
|
|
14833
|
+
top: Math.max(0, container.scrollTop + delta),
|
|
14834
|
+
behavior: "smooth"
|
|
14835
|
+
});
|
|
14836
|
+
}
|
|
14837
|
+
|
|
14582
14838
|
// src/chat/active-channel-messages/useActiveChannelMessages.ts
|
|
14839
|
+
var MAX_JUMP_OLDER_PAGES = 40;
|
|
14583
14840
|
function useActiveChannelMessages({
|
|
14584
14841
|
activeChannel,
|
|
14585
14842
|
loggedUserId,
|
|
@@ -14602,6 +14859,11 @@ function useActiveChannelMessages({
|
|
|
14602
14859
|
const previousMessageCountRef = React2.useRef(0);
|
|
14603
14860
|
const previousLastMessageIdRef = React2.useRef(null);
|
|
14604
14861
|
const [enteringMessageIds, setEnteringMessageIds] = React2.useState(/* @__PURE__ */ new Set());
|
|
14862
|
+
const [showScrollToBottom, setShowScrollToBottom] = React2.useState(false);
|
|
14863
|
+
const stickToBottomRef = React2.useRef(true);
|
|
14864
|
+
const pendingJumpRef = React2.useRef(null);
|
|
14865
|
+
const jumpPagesRef = React2.useRef(0);
|
|
14866
|
+
const [jumpNonce, setJumpNonce] = React2.useState(0);
|
|
14605
14867
|
const { fetchMessages: fetchMessages2, messagesMetadata, deletedForMeIds, searchedMessageId, isSearchActive, setSearchActive, setSearchedMessageId, fetchSearchMessageContext } = exports.useChatStore();
|
|
14606
14868
|
const loggedUserImage = exports.useChatStore((s) => s.loggedUserDetails?.image);
|
|
14607
14869
|
const conversations = exports.useChatStore((s) => s.conversations);
|
|
@@ -14625,6 +14887,13 @@ function useActiveChannelMessages({
|
|
|
14625
14887
|
})),
|
|
14626
14888
|
[displayMessages, messagesById, loggedUserId]
|
|
14627
14889
|
);
|
|
14890
|
+
const jumpDateBounds = React2.useMemo(
|
|
14891
|
+
() => resolveJumpDateBounds(
|
|
14892
|
+
conversationInfo?.createdAt,
|
|
14893
|
+
displayMessages[0]?.timestamp
|
|
14894
|
+
),
|
|
14895
|
+
[conversationInfo?.createdAt, displayMessages]
|
|
14896
|
+
);
|
|
14628
14897
|
React2.useEffect(() => {
|
|
14629
14898
|
const messages = messagesWithResolvedReplies;
|
|
14630
14899
|
const lastMessage = messages[messages.length - 1];
|
|
@@ -14662,6 +14931,10 @@ function useActiveChannelMessages({
|
|
|
14662
14931
|
previousMessageCountRef.current = 0;
|
|
14663
14932
|
previousLastMessageIdRef.current = null;
|
|
14664
14933
|
setEnteringMessageIds(/* @__PURE__ */ new Set());
|
|
14934
|
+
pendingJumpRef.current = null;
|
|
14935
|
+
jumpPagesRef.current = 0;
|
|
14936
|
+
stickToBottomRef.current = true;
|
|
14937
|
+
setShowScrollToBottom(false);
|
|
14665
14938
|
}, [conversationId, clearSelection]);
|
|
14666
14939
|
const onSelectionModeChangeRef = React2.useRef(onSelectionModeChange);
|
|
14667
14940
|
React2.useEffect(() => {
|
|
@@ -14671,10 +14944,10 @@ function useActiveChannelMessages({
|
|
|
14671
14944
|
onSelectionModeChangeRef.current?.(selectionMode);
|
|
14672
14945
|
}, [selectionMode]);
|
|
14673
14946
|
const toggleSelection = React2.useCallback((message, attachmentId) => {
|
|
14674
|
-
const
|
|
14675
|
-
if (!
|
|
14947
|
+
const messageId2 = String(message._id || message.id);
|
|
14948
|
+
if (!messageId2) return;
|
|
14676
14949
|
const useAttachmentSelection = messageUsesAttachmentSelection(message);
|
|
14677
|
-
const key = useAttachmentSelection && attachmentId ? buildSelectionKey(
|
|
14950
|
+
const key = useAttachmentSelection && attachmentId ? buildSelectionKey(messageId2, attachmentId) : messageId2;
|
|
14678
14951
|
setSelectedKeys((prev) => {
|
|
14679
14952
|
const next = new Set(prev);
|
|
14680
14953
|
if (next.has(key)) next.delete(key);
|
|
@@ -14684,17 +14957,17 @@ function useActiveChannelMessages({
|
|
|
14684
14957
|
});
|
|
14685
14958
|
}, []);
|
|
14686
14959
|
const enterSelectionMode = React2.useCallback((message, attachmentId) => {
|
|
14687
|
-
const
|
|
14688
|
-
if (!
|
|
14960
|
+
const messageId2 = String(message._id || message.id);
|
|
14961
|
+
if (!messageId2) return;
|
|
14689
14962
|
setSelectionMode(true);
|
|
14690
14963
|
const useAttachmentSelection = messageUsesAttachmentSelection(message);
|
|
14691
14964
|
if (useAttachmentSelection) {
|
|
14692
14965
|
if (attachmentId) {
|
|
14693
|
-
setSelectedKeys((prev) => new Set(prev).add(buildSelectionKey(
|
|
14966
|
+
setSelectedKeys((prev) => new Set(prev).add(buildSelectionKey(messageId2, attachmentId)));
|
|
14694
14967
|
}
|
|
14695
14968
|
return;
|
|
14696
14969
|
}
|
|
14697
|
-
setSelectedKeys((prev) => new Set(prev).add(
|
|
14970
|
+
setSelectedKeys((prev) => new Set(prev).add(messageId2));
|
|
14698
14971
|
}, []);
|
|
14699
14972
|
const selectedForwardItems = resolveForwardItems(selectedKeys, displayMessages);
|
|
14700
14973
|
const canDeleteForEveryone = React2.useMemo(
|
|
@@ -14713,14 +14986,14 @@ function useActiveChannelMessages({
|
|
|
14713
14986
|
}
|
|
14714
14987
|
const isGroupChat = !!activeChannel?.isGroup;
|
|
14715
14988
|
selectedKeys.forEach((key) => {
|
|
14716
|
-
const { messageId, attachmentId } = parseSelectionKey(key);
|
|
14717
|
-
if (!
|
|
14718
|
-
const message = displayMessages.find((entry) => String(entry._id || entry.id) ===
|
|
14989
|
+
const { messageId: messageId2, attachmentId } = parseSelectionKey(key);
|
|
14990
|
+
if (!messageId2 || messageId2.startsWith("temp-")) return;
|
|
14991
|
+
const message = displayMessages.find((entry) => String(entry._id || entry.id) === messageId2);
|
|
14719
14992
|
if (isGroupChat) {
|
|
14720
14993
|
const convId = String(message?.conversationId || conversationId || "");
|
|
14721
14994
|
if (!convId) return;
|
|
14722
14995
|
emitGroupDelete({
|
|
14723
|
-
messageId,
|
|
14996
|
+
messageId: messageId2,
|
|
14724
14997
|
sender: loggedUserDetails._id,
|
|
14725
14998
|
deleteType,
|
|
14726
14999
|
conversationId: convId,
|
|
@@ -14730,7 +15003,7 @@ function useActiveChannelMessages({
|
|
|
14730
15003
|
const receiver = message?.receiver || activeChannel?.id;
|
|
14731
15004
|
if (!receiver) return;
|
|
14732
15005
|
emitDmDelete({
|
|
14733
|
-
messageId,
|
|
15006
|
+
messageId: messageId2,
|
|
14734
15007
|
sender: loggedUserDetails._id,
|
|
14735
15008
|
receiver: String(receiver),
|
|
14736
15009
|
deleteType,
|
|
@@ -14769,43 +15042,138 @@ function useActiveChannelMessages({
|
|
|
14769
15042
|
fetchMessages2(conversationId);
|
|
14770
15043
|
}
|
|
14771
15044
|
};
|
|
14772
|
-
const handleReplyTargetClick = async (
|
|
14773
|
-
if (!
|
|
14774
|
-
|
|
14775
|
-
|
|
15045
|
+
const handleReplyTargetClick = async (messageId2) => {
|
|
15046
|
+
if (!messageId2) return;
|
|
15047
|
+
stickToBottomRef.current = false;
|
|
15048
|
+
if (messagesById.has(messageId2)) {
|
|
15049
|
+
setSearchedMessageId(messageId2);
|
|
14776
15050
|
return;
|
|
14777
15051
|
}
|
|
14778
|
-
await fetchSearchMessageContext(
|
|
15052
|
+
await fetchSearchMessageContext(messageId2, { searchMode: false });
|
|
14779
15053
|
};
|
|
15054
|
+
const handleJumpTo = React2.useCallback((preset, specificDate) => {
|
|
15055
|
+
stickToBottomRef.current = false;
|
|
15056
|
+
if (preset === "beginning") {
|
|
15057
|
+
pendingJumpRef.current = { kind: "beginning" };
|
|
15058
|
+
} else if (preset === "specific") {
|
|
15059
|
+
if (!specificDate) return;
|
|
15060
|
+
const clamped = clampJumpDate(
|
|
15061
|
+
specificDate,
|
|
15062
|
+
jumpDateBounds.minDay,
|
|
15063
|
+
jumpDateBounds.maxDay
|
|
15064
|
+
);
|
|
15065
|
+
if (!clamped) return;
|
|
15066
|
+
pendingJumpRef.current = { kind: "date", at: startOfLocalDay(clamped) };
|
|
15067
|
+
} else {
|
|
15068
|
+
const raw = resolveJumpPreset(preset);
|
|
15069
|
+
const at = Math.min(Math.max(raw, jumpDateBounds.minDay), jumpDateBounds.maxDay);
|
|
15070
|
+
pendingJumpRef.current = { kind: "date", at };
|
|
15071
|
+
}
|
|
15072
|
+
jumpPagesRef.current = 0;
|
|
15073
|
+
setJumpNonce((n) => n + 1);
|
|
15074
|
+
}, [jumpDateBounds.minDay, jumpDateBounds.maxDay]);
|
|
15075
|
+
React2.useEffect(() => {
|
|
15076
|
+
const pending = pendingJumpRef.current;
|
|
15077
|
+
if (!pending || isLoading) return;
|
|
15078
|
+
const step = resolveJumpStep(
|
|
15079
|
+
messagesWithResolvedReplies,
|
|
15080
|
+
pending,
|
|
15081
|
+
!!currentMeta?.hasMore
|
|
15082
|
+
);
|
|
15083
|
+
if (step.action === "loadOlder") {
|
|
15084
|
+
if (!conversationId || !currentMeta?.nextCursor || jumpPagesRef.current >= MAX_JUMP_OLDER_PAGES) {
|
|
15085
|
+
pendingJumpRef.current = null;
|
|
15086
|
+
const fallback = messagesWithResolvedReplies[0];
|
|
15087
|
+
if (fallback) setSearchedMessageId(String(fallback._id || fallback.id));
|
|
15088
|
+
return;
|
|
15089
|
+
}
|
|
15090
|
+
jumpPagesRef.current += 1;
|
|
15091
|
+
const prevScrollHeight = scrollContainerRef.current?.scrollHeight ?? 0;
|
|
15092
|
+
fetchMessages2(conversationId, DEFAULT_MESSAGES_LIMIT, currentMeta.nextCursor).then(() => {
|
|
15093
|
+
if (scrollContainerRef.current && prevScrollHeight) {
|
|
15094
|
+
scrollContainerRef.current.scrollTop = scrollContainerRef.current.scrollHeight - prevScrollHeight;
|
|
15095
|
+
}
|
|
15096
|
+
});
|
|
15097
|
+
return;
|
|
15098
|
+
}
|
|
15099
|
+
pendingJumpRef.current = null;
|
|
15100
|
+
if (step.action === "scroll") {
|
|
15101
|
+
setSearchedMessageId(null);
|
|
15102
|
+
requestAnimationFrame(() => setSearchedMessageId(step.messageId));
|
|
15103
|
+
}
|
|
15104
|
+
}, [
|
|
15105
|
+
jumpNonce,
|
|
15106
|
+
isLoading,
|
|
15107
|
+
messagesWithResolvedReplies,
|
|
15108
|
+
currentMeta?.hasMore,
|
|
15109
|
+
currentMeta?.nextCursor,
|
|
15110
|
+
conversationId,
|
|
15111
|
+
fetchMessages2,
|
|
15112
|
+
setSearchedMessageId
|
|
15113
|
+
]);
|
|
15114
|
+
const updateScrollToBottomVisibility = React2.useCallback((el) => {
|
|
15115
|
+
const distanceFromBottom = el.scrollHeight - el.scrollTop - el.clientHeight;
|
|
15116
|
+
const nearBottom = distanceFromBottom <= 96;
|
|
15117
|
+
stickToBottomRef.current = nearBottom;
|
|
15118
|
+
setShowScrollToBottom(!nearBottom);
|
|
15119
|
+
}, []);
|
|
15120
|
+
const handleScrollToBottom = React2.useCallback(() => {
|
|
15121
|
+
stickToBottomRef.current = true;
|
|
15122
|
+
if (isSearchActive) {
|
|
15123
|
+
setSearchActive(false);
|
|
15124
|
+
setSearchedMessageId(null);
|
|
15125
|
+
if (conversationId) fetchMessages2(conversationId);
|
|
15126
|
+
setShowScrollToBottom(false);
|
|
15127
|
+
return;
|
|
15128
|
+
}
|
|
15129
|
+
bottomRef.current?.scrollIntoView({ behavior: "smooth" });
|
|
15130
|
+
setShowScrollToBottom(false);
|
|
15131
|
+
}, [isSearchActive, conversationId, setSearchActive, setSearchedMessageId, fetchMessages2]);
|
|
14780
15132
|
const handleScroll = (e) => {
|
|
14781
15133
|
const target = e.currentTarget;
|
|
15134
|
+
updateScrollToBottomVisibility(target);
|
|
15135
|
+
if (pendingJumpRef.current) return;
|
|
14782
15136
|
if (target.scrollTop === 0 && currentMeta?.hasMore && !isLoading && conversationId && currentMeta.nextCursor) {
|
|
14783
15137
|
const prevScrollHeight = target.scrollHeight;
|
|
14784
15138
|
fetchMessages2(conversationId, DEFAULT_MESSAGES_LIMIT, currentMeta.nextCursor).then(() => {
|
|
14785
15139
|
if (scrollContainerRef.current) {
|
|
14786
15140
|
const newScrollHeight = scrollContainerRef.current.scrollHeight;
|
|
14787
15141
|
scrollContainerRef.current.scrollTop = newScrollHeight - prevScrollHeight;
|
|
15142
|
+
updateScrollToBottomVisibility(scrollContainerRef.current);
|
|
14788
15143
|
}
|
|
14789
15144
|
});
|
|
14790
15145
|
}
|
|
14791
15146
|
};
|
|
14792
15147
|
React2.useLayoutEffect(() => {
|
|
14793
|
-
if (!isInitialLoading &&
|
|
15148
|
+
if (!isInitialLoading && stickToBottomRef.current && !pendingJumpRef.current) {
|
|
14794
15149
|
bottomRef.current?.scrollIntoView({ behavior: "smooth" });
|
|
14795
15150
|
}
|
|
14796
|
-
}, [messagesWithResolvedReplies.length, isInitialLoading
|
|
15151
|
+
}, [messagesWithResolvedReplies.length, isInitialLoading]);
|
|
14797
15152
|
React2.useEffect(() => {
|
|
14798
15153
|
if (searchedMessageId && !isLoading) {
|
|
15154
|
+
stickToBottomRef.current = false;
|
|
15155
|
+
const container = scrollContainerRef.current;
|
|
14799
15156
|
const element = document.getElementById(`message-${searchedMessageId}`);
|
|
14800
|
-
if (element) {
|
|
14801
|
-
|
|
15157
|
+
if (container && element) {
|
|
15158
|
+
requestAnimationFrame(() => {
|
|
15159
|
+
requestAnimationFrame(() => {
|
|
15160
|
+
smoothScrollToMessage(container, element);
|
|
15161
|
+
updateScrollToBottomVisibility(container);
|
|
15162
|
+
});
|
|
15163
|
+
});
|
|
14802
15164
|
}
|
|
14803
15165
|
if (!isSearchActive) {
|
|
14804
15166
|
const timer = window.setTimeout(() => setSearchedMessageId(null), 2500);
|
|
14805
15167
|
return () => window.clearTimeout(timer);
|
|
14806
15168
|
}
|
|
14807
15169
|
}
|
|
14808
|
-
}, [
|
|
15170
|
+
}, [
|
|
15171
|
+
searchedMessageId,
|
|
15172
|
+
isLoading,
|
|
15173
|
+
isSearchActive,
|
|
15174
|
+
setSearchedMessageId,
|
|
15175
|
+
updateScrollToBottomVisibility
|
|
15176
|
+
]);
|
|
14809
15177
|
return {
|
|
14810
15178
|
activeChannel,
|
|
14811
15179
|
conversationId,
|
|
@@ -14831,11 +15199,297 @@ function useActiveChannelMessages({
|
|
|
14831
15199
|
canDeleteForEveryone,
|
|
14832
15200
|
handleResetToNormal,
|
|
14833
15201
|
handleReplyTargetClick,
|
|
15202
|
+
handleJumpTo,
|
|
15203
|
+
jumpDateBounds,
|
|
15204
|
+
showScrollToBottom,
|
|
15205
|
+
handleScrollToBottom,
|
|
14834
15206
|
handleScroll
|
|
14835
15207
|
};
|
|
14836
15208
|
}
|
|
15209
|
+
function Calendar({
|
|
15210
|
+
className,
|
|
15211
|
+
classNames,
|
|
15212
|
+
showOutsideDays = true,
|
|
15213
|
+
captionLayout = "label",
|
|
15214
|
+
buttonVariant = "ghost",
|
|
15215
|
+
formatters,
|
|
15216
|
+
components,
|
|
15217
|
+
...props
|
|
15218
|
+
}) {
|
|
15219
|
+
const defaultClassNames = reactDayPicker.getDefaultClassNames();
|
|
15220
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
15221
|
+
reactDayPicker.DayPicker,
|
|
15222
|
+
{
|
|
15223
|
+
showOutsideDays,
|
|
15224
|
+
className: cn(
|
|
15225
|
+
"group/calendar bg-background p-3 [--cell-size:--spacing(8)] [[data-slot=card-content]_&]:bg-transparent [[data-slot=popover-content]_&]:bg-transparent",
|
|
15226
|
+
String.raw`rtl:**:[.rdp-button\_next>svg]:rotate-180`,
|
|
15227
|
+
String.raw`rtl:**:[.rdp-button\_previous>svg]:rotate-180`,
|
|
15228
|
+
className
|
|
15229
|
+
),
|
|
15230
|
+
captionLayout,
|
|
15231
|
+
formatters: {
|
|
15232
|
+
formatMonthDropdown: (date) => date.toLocaleString("default", { month: "short" }),
|
|
15233
|
+
...formatters
|
|
15234
|
+
},
|
|
15235
|
+
classNames: {
|
|
15236
|
+
root: cn("w-fit", defaultClassNames.root),
|
|
15237
|
+
months: cn(
|
|
15238
|
+
"relative flex flex-col gap-4 md:flex-row",
|
|
15239
|
+
defaultClassNames.months
|
|
15240
|
+
),
|
|
15241
|
+
month: cn("flex w-full flex-col gap-4", defaultClassNames.month),
|
|
15242
|
+
nav: cn(
|
|
15243
|
+
"absolute inset-x-0 top-0 flex w-full items-center justify-between gap-1",
|
|
15244
|
+
defaultClassNames.nav
|
|
15245
|
+
),
|
|
15246
|
+
button_previous: cn(
|
|
15247
|
+
buttonVariants({ variant: buttonVariant }),
|
|
15248
|
+
"size-(--cell-size) p-0 select-none aria-disabled:opacity-50",
|
|
15249
|
+
defaultClassNames.button_previous
|
|
15250
|
+
),
|
|
15251
|
+
button_next: cn(
|
|
15252
|
+
buttonVariants({ variant: buttonVariant }),
|
|
15253
|
+
"size-(--cell-size) p-0 select-none aria-disabled:opacity-50",
|
|
15254
|
+
defaultClassNames.button_next
|
|
15255
|
+
),
|
|
15256
|
+
month_caption: cn(
|
|
15257
|
+
"flex h-(--cell-size) w-full items-center justify-center px-(--cell-size)",
|
|
15258
|
+
defaultClassNames.month_caption
|
|
15259
|
+
),
|
|
15260
|
+
dropdowns: cn(
|
|
15261
|
+
"flex h-(--cell-size) w-full items-center justify-center gap-1.5 text-sm font-medium",
|
|
15262
|
+
defaultClassNames.dropdowns
|
|
15263
|
+
),
|
|
15264
|
+
dropdown_root: cn(
|
|
15265
|
+
"relative rounded-md border border-input shadow-xs has-focus:border-ring has-focus:ring-[3px] has-focus:ring-ring/50",
|
|
15266
|
+
defaultClassNames.dropdown_root
|
|
15267
|
+
),
|
|
15268
|
+
dropdown: cn(
|
|
15269
|
+
"absolute inset-0 bg-popover opacity-0",
|
|
15270
|
+
defaultClassNames.dropdown
|
|
15271
|
+
),
|
|
15272
|
+
caption_label: cn(
|
|
15273
|
+
"font-medium select-none",
|
|
15274
|
+
captionLayout === "label" ? "text-sm" : "flex h-8 items-center gap-1 rounded-md pr-1 pl-2 text-sm [&>svg]:size-3.5 [&>svg]:text-muted-foreground",
|
|
15275
|
+
defaultClassNames.caption_label
|
|
15276
|
+
),
|
|
15277
|
+
month_grid: cn("w-full border-collapse", defaultClassNames.month_grid),
|
|
15278
|
+
weekdays: cn("flex", defaultClassNames.weekdays),
|
|
15279
|
+
weekday: cn(
|
|
15280
|
+
"flex-1 rounded-md text-[0.8rem] font-normal text-muted-foreground select-none",
|
|
15281
|
+
defaultClassNames.weekday
|
|
15282
|
+
),
|
|
15283
|
+
week: cn("mt-2 flex w-full", defaultClassNames.week),
|
|
15284
|
+
week_number_header: cn(
|
|
15285
|
+
"w-(--cell-size) select-none",
|
|
15286
|
+
defaultClassNames.week_number_header
|
|
15287
|
+
),
|
|
15288
|
+
week_number: cn(
|
|
15289
|
+
"text-[0.8rem] text-muted-foreground select-none",
|
|
15290
|
+
defaultClassNames.week_number
|
|
15291
|
+
),
|
|
15292
|
+
day: cn(
|
|
15293
|
+
"group/day relative aspect-square h-full w-full p-0 text-center select-none [&:last-child[data-selected=true]_button]:rounded-r-md",
|
|
15294
|
+
props.showWeekNumber ? "[&:nth-child(2)[data-selected=true]_button]:rounded-l-md" : "[&:first-child[data-selected=true]_button]:rounded-l-md",
|
|
15295
|
+
defaultClassNames.day
|
|
15296
|
+
),
|
|
15297
|
+
range_start: cn(
|
|
15298
|
+
"rounded-l-md bg-accent",
|
|
15299
|
+
defaultClassNames.range_start
|
|
15300
|
+
),
|
|
15301
|
+
range_middle: cn("rounded-none", defaultClassNames.range_middle),
|
|
15302
|
+
range_end: cn("rounded-r-md bg-accent", defaultClassNames.range_end),
|
|
15303
|
+
today: cn(
|
|
15304
|
+
"rounded-md bg-accent text-accent-foreground data-[selected=true]:rounded-none",
|
|
15305
|
+
defaultClassNames.today
|
|
15306
|
+
),
|
|
15307
|
+
outside: cn(
|
|
15308
|
+
"text-muted-foreground aria-selected:text-muted-foreground",
|
|
15309
|
+
defaultClassNames.outside
|
|
15310
|
+
),
|
|
15311
|
+
disabled: cn(
|
|
15312
|
+
"text-muted-foreground opacity-50",
|
|
15313
|
+
defaultClassNames.disabled
|
|
15314
|
+
),
|
|
15315
|
+
hidden: cn("invisible", defaultClassNames.hidden),
|
|
15316
|
+
...classNames
|
|
15317
|
+
},
|
|
15318
|
+
components: {
|
|
15319
|
+
Root: ({ className: className2, rootRef, ...props2 }) => {
|
|
15320
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
15321
|
+
"div",
|
|
15322
|
+
{
|
|
15323
|
+
"data-slot": "calendar",
|
|
15324
|
+
ref: rootRef,
|
|
15325
|
+
className: cn(className2),
|
|
15326
|
+
...props2
|
|
15327
|
+
}
|
|
15328
|
+
);
|
|
15329
|
+
},
|
|
15330
|
+
Chevron: ({ className: className2, orientation, ...props2 }) => {
|
|
15331
|
+
if (orientation === "left") {
|
|
15332
|
+
return /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ChevronLeftIcon, { className: cn("size-4", className2), ...props2 });
|
|
15333
|
+
}
|
|
15334
|
+
if (orientation === "right") {
|
|
15335
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
15336
|
+
lucideReact.ChevronRightIcon,
|
|
15337
|
+
{
|
|
15338
|
+
className: cn("size-4", className2),
|
|
15339
|
+
...props2
|
|
15340
|
+
}
|
|
15341
|
+
);
|
|
15342
|
+
}
|
|
15343
|
+
return /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ChevronDownIcon, { className: cn("size-4", className2), ...props2 });
|
|
15344
|
+
},
|
|
15345
|
+
DayButton: CalendarDayButton,
|
|
15346
|
+
WeekNumber: ({ children, ...props2 }) => {
|
|
15347
|
+
return /* @__PURE__ */ jsxRuntime.jsx("td", { ...props2, children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex size-(--cell-size) items-center justify-center text-center", children }) });
|
|
15348
|
+
},
|
|
15349
|
+
...components
|
|
15350
|
+
},
|
|
15351
|
+
...props
|
|
15352
|
+
}
|
|
15353
|
+
);
|
|
15354
|
+
}
|
|
15355
|
+
function CalendarDayButton({
|
|
15356
|
+
className,
|
|
15357
|
+
day,
|
|
15358
|
+
modifiers,
|
|
15359
|
+
...props
|
|
15360
|
+
}) {
|
|
15361
|
+
const defaultClassNames = reactDayPicker.getDefaultClassNames();
|
|
15362
|
+
const ref = React2__namespace.useRef(null);
|
|
15363
|
+
React2__namespace.useEffect(() => {
|
|
15364
|
+
if (modifiers.focused) ref.current?.focus();
|
|
15365
|
+
}, [modifiers.focused]);
|
|
15366
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
15367
|
+
Button,
|
|
15368
|
+
{
|
|
15369
|
+
ref,
|
|
15370
|
+
variant: "ghost",
|
|
15371
|
+
size: "icon",
|
|
15372
|
+
"data-day": day.date.toLocaleDateString(),
|
|
15373
|
+
"data-selected-single": modifiers.selected && !modifiers.range_start && !modifiers.range_end && !modifiers.range_middle,
|
|
15374
|
+
"data-range-start": modifiers.range_start,
|
|
15375
|
+
"data-range-end": modifiers.range_end,
|
|
15376
|
+
"data-range-middle": modifiers.range_middle,
|
|
15377
|
+
className: cn(
|
|
15378
|
+
"flex aspect-square size-auto w-full min-w-(--cell-size) flex-col gap-1 leading-none font-normal group-data-[focused=true]/day:relative group-data-[focused=true]/day:z-10 group-data-[focused=true]/day:border-ring group-data-[focused=true]/day:ring-[3px] group-data-[focused=true]/day:ring-ring/50 data-[range-end=true]:rounded-md data-[range-end=true]:rounded-r-md data-[range-end=true]:bg-primary data-[range-end=true]:text-primary-foreground data-[range-middle=true]:rounded-none data-[range-middle=true]:bg-accent data-[range-middle=true]:text-accent-foreground data-[range-start=true]:rounded-md data-[range-start=true]:rounded-l-md data-[range-start=true]:bg-primary data-[range-start=true]:text-primary-foreground data-[selected-single=true]:bg-primary data-[selected-single=true]:text-primary-foreground dark:hover:text-accent-foreground [&>span]:text-xs [&>span]:opacity-70",
|
|
15379
|
+
defaultClassNames.day,
|
|
15380
|
+
className
|
|
15381
|
+
),
|
|
15382
|
+
...props
|
|
15383
|
+
}
|
|
15384
|
+
);
|
|
15385
|
+
}
|
|
15386
|
+
var PRESETS = [
|
|
15387
|
+
{ preset: "today", label: "Today" },
|
|
15388
|
+
{ preset: "yesterday", label: "Yesterday" },
|
|
15389
|
+
{ preset: "lastWeek", label: "Last week" },
|
|
15390
|
+
{ preset: "lastMonth", label: "Last month" },
|
|
15391
|
+
{ preset: "beginning", label: "The very beginning" }
|
|
15392
|
+
];
|
|
15393
|
+
function ChatDateJumpMenu({ label, minDay, maxDay, onJump }) {
|
|
15394
|
+
const { scopeClassName } = useChatTheme();
|
|
15395
|
+
const [open, setOpen] = React2.useState(false);
|
|
15396
|
+
const [showCalendar, setShowCalendar] = React2.useState(false);
|
|
15397
|
+
const [calendarMonth, setCalendarMonth] = React2.useState(() => new Date(maxDay));
|
|
15398
|
+
const minDate = new Date(minDay);
|
|
15399
|
+
const maxDate = new Date(maxDay);
|
|
15400
|
+
React2.useEffect(() => {
|
|
15401
|
+
if (showCalendar) setCalendarMonth(new Date(maxDay));
|
|
15402
|
+
}, [showCalendar, maxDay]);
|
|
15403
|
+
const queueJump = (preset, specificDate) => {
|
|
15404
|
+
window.setTimeout(() => onJump(preset, specificDate), 0);
|
|
15405
|
+
};
|
|
15406
|
+
const handleOpenChange = (next) => {
|
|
15407
|
+
setOpen(next);
|
|
15408
|
+
if (!next) setShowCalendar(false);
|
|
15409
|
+
};
|
|
15410
|
+
const handlePreset = (preset) => {
|
|
15411
|
+
setOpen(false);
|
|
15412
|
+
setShowCalendar(false);
|
|
15413
|
+
queueJump(preset);
|
|
15414
|
+
};
|
|
15415
|
+
const handleDateSelect = (date) => {
|
|
15416
|
+
if (!date) return;
|
|
15417
|
+
const clamped = clampJumpDate(date, minDay, maxDay);
|
|
15418
|
+
if (!clamped) return;
|
|
15419
|
+
setOpen(false);
|
|
15420
|
+
setShowCalendar(false);
|
|
15421
|
+
queueJump("specific", clamped);
|
|
15422
|
+
};
|
|
15423
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(Popover, { open, onOpenChange: handleOpenChange, children: [
|
|
15424
|
+
/* @__PURE__ */ jsxRuntime.jsx(PopoverTrigger, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
15425
|
+
"button",
|
|
15426
|
+
{
|
|
15427
|
+
type: "button",
|
|
15428
|
+
className: "chat-date-divider-pill chat-date-divider-pill--interactive",
|
|
15429
|
+
"aria-label": `Jump to date, currently ${label}`,
|
|
15430
|
+
children: [
|
|
15431
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { children: label }),
|
|
15432
|
+
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.ChevronDown, { className: "chat-date-divider-chevron", "aria-hidden": true })
|
|
15433
|
+
]
|
|
15434
|
+
}
|
|
15435
|
+
) }),
|
|
15436
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
15437
|
+
PopoverContent,
|
|
15438
|
+
{
|
|
15439
|
+
align: "center",
|
|
15440
|
+
sideOffset: 8,
|
|
15441
|
+
className: cn(
|
|
15442
|
+
scopeClassName,
|
|
15443
|
+
chatPopoverContentClass,
|
|
15444
|
+
"w-auto overflow-hidden rounded-2xl p-0",
|
|
15445
|
+
showCalendar ? "min-w-[300px]" : "min-w-[220px]"
|
|
15446
|
+
),
|
|
15447
|
+
onCloseAutoFocus: (event) => event.preventDefault(),
|
|
15448
|
+
children: showCalendar ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "p-2", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
15449
|
+
Calendar,
|
|
15450
|
+
{
|
|
15451
|
+
mode: "single",
|
|
15452
|
+
month: calendarMonth,
|
|
15453
|
+
onMonthChange: setCalendarMonth,
|
|
15454
|
+
startMonth: minDate,
|
|
15455
|
+
endMonth: maxDate,
|
|
15456
|
+
showOutsideDays: false,
|
|
15457
|
+
disabled: { before: minDate, after: maxDate },
|
|
15458
|
+
onSelect: handleDateSelect,
|
|
15459
|
+
className: "chat-jump-calendar rounded-xl bg-transparent p-1 [--cell-size:2.125rem]"
|
|
15460
|
+
}
|
|
15461
|
+
) }) : /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
15462
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "px-3 pt-3 pb-2", children: [
|
|
15463
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { className: chatOptionsMenuLabelClass, children: "Jump to\u2026" }),
|
|
15464
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "mt-1 flex flex-col", children: PRESETS.map(({ preset, label: itemLabel }) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
15465
|
+
"button",
|
|
15466
|
+
{
|
|
15467
|
+
type: "button",
|
|
15468
|
+
className: cn(chatOptionsMenuItemClass, "w-full border-0 bg-transparent text-left"),
|
|
15469
|
+
onClick: () => handlePreset(preset),
|
|
15470
|
+
children: itemLabel
|
|
15471
|
+
},
|
|
15472
|
+
preset
|
|
15473
|
+
)) })
|
|
15474
|
+
] }),
|
|
15475
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: cn(chatOptionsMenuSeparatorClass, "mx-3") }),
|
|
15476
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "px-1 pb-2", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
15477
|
+
"button",
|
|
15478
|
+
{
|
|
15479
|
+
type: "button",
|
|
15480
|
+
className: cn(chatOptionsMenuItemClass, "w-full border-0 bg-transparent text-left"),
|
|
15481
|
+
onClick: () => setShowCalendar(true),
|
|
15482
|
+
children: "Jump to a specific date"
|
|
15483
|
+
}
|
|
15484
|
+
) })
|
|
15485
|
+
] })
|
|
15486
|
+
}
|
|
15487
|
+
)
|
|
15488
|
+
] });
|
|
15489
|
+
}
|
|
14837
15490
|
var ActiveChannelMessagesView = (props) => {
|
|
14838
15491
|
const { formatDateDivider } = useChatLocale();
|
|
15492
|
+
const allUsers = exports.useChatStore((s) => s.allUsers);
|
|
14839
15493
|
const {
|
|
14840
15494
|
activeChannel,
|
|
14841
15495
|
conversationId,
|
|
@@ -14861,6 +15515,10 @@ var ActiveChannelMessagesView = (props) => {
|
|
|
14861
15515
|
canDeleteForEveryone,
|
|
14862
15516
|
handleResetToNormal,
|
|
14863
15517
|
handleReplyTargetClick,
|
|
15518
|
+
handleJumpTo,
|
|
15519
|
+
jumpDateBounds,
|
|
15520
|
+
showScrollToBottom,
|
|
15521
|
+
handleScrollToBottom,
|
|
14864
15522
|
handleScroll
|
|
14865
15523
|
} = useActiveChannelMessages(props);
|
|
14866
15524
|
const { onReply, onForward } = props;
|
|
@@ -14873,7 +15531,7 @@ var ActiveChannelMessagesView = (props) => {
|
|
|
14873
15531
|
] })
|
|
14874
15532
|
] });
|
|
14875
15533
|
}
|
|
14876
|
-
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "chat-message-canvas relative flex h-full
|
|
15534
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "chat-message-canvas relative flex h-full flex-col", children: [
|
|
14877
15535
|
isSearchActive && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "absolute top-6 left-1/2 -translate-x-1/2 z-40 animate-in slide-in-from-top-4 duration-500", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center overflow-hidden rounded-2xl border border-(--chat-border) bg-(--chat-surface) shadow-lg ring-4 ring-(--chat-surface)", children: [
|
|
14878
15536
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2 bg-(--chat-theme) px-4 py-2.5", children: [
|
|
14879
15537
|
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.History, { className: "size-3.5 animate-pulse text-white" }),
|
|
@@ -14910,11 +15568,20 @@ var ActiveChannelMessagesView = (props) => {
|
|
|
14910
15568
|
return groups;
|
|
14911
15569
|
}, {})
|
|
14912
15570
|
).map(([date, messages]) => /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "mb-2 flex flex-col", children: [
|
|
14913
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "
|
|
15571
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "sticky top-1.5 z-20 mb-2 flex justify-center py-1", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
15572
|
+
ChatDateJumpMenu,
|
|
15573
|
+
{
|
|
15574
|
+
label: date,
|
|
15575
|
+
minDay: jumpDateBounds.minDay,
|
|
15576
|
+
maxDay: jumpDateBounds.maxDay,
|
|
15577
|
+
onJump: handleJumpTo
|
|
15578
|
+
}
|
|
15579
|
+
) }),
|
|
14914
15580
|
messages.map((m, msgIndex) => {
|
|
14915
|
-
const senderLabel = typeof m.sender === "string" ? m.sender : "User";
|
|
14916
|
-
const senderImage = !m.isOwnMessage ? activeChannel?.isGroup ? void 0 : activeChannel?.image : void 0;
|
|
14917
15581
|
const isGroupChat = !!activeChannel?.isGroup;
|
|
15582
|
+
const participants = conversationInfo?.participants ?? [];
|
|
15583
|
+
const { name: senderLabel, image: groupSenderImage } = isGroupChat && !m.isOwnMessage ? resolveGroupSenderDisplay(m, allUsers, participants) : { name: typeof m.sender === "string" ? m.sender : "User", image: void 0 };
|
|
15584
|
+
const senderImage = !m.isOwnMessage ? isGroupChat ? groupSenderImage : activeChannel?.image : void 0;
|
|
14918
15585
|
const prevMessage = msgIndex > 0 ? messages[msgIndex - 1] : null;
|
|
14919
15586
|
const nextMessage = msgIndex < messages.length - 1 ? messages[msgIndex + 1] : null;
|
|
14920
15587
|
const isGroupedWithPrev = !!prevMessage && isSameMessageSide(prevMessage, m, isGroupChat);
|
|
@@ -14961,6 +15628,7 @@ var ActiveChannelMessagesView = (props) => {
|
|
|
14961
15628
|
conversationInfo,
|
|
14962
15629
|
isHighlighted: String(m._id || m.id) === String(searchedMessageId),
|
|
14963
15630
|
senderName: senderLabel,
|
|
15631
|
+
senderId: getMessageSenderId2(m),
|
|
14964
15632
|
senderImage,
|
|
14965
15633
|
showSenderName,
|
|
14966
15634
|
showSenderLabel,
|
|
@@ -15001,6 +15669,16 @@ var ActiveChannelMessagesView = (props) => {
|
|
|
15001
15669
|
onForward: handleBatchForward
|
|
15002
15670
|
}
|
|
15003
15671
|
),
|
|
15672
|
+
showScrollToBottom && !selectionMode && /* @__PURE__ */ jsxRuntime.jsx(
|
|
15673
|
+
"button",
|
|
15674
|
+
{
|
|
15675
|
+
type: "button",
|
|
15676
|
+
onClick: handleScrollToBottom,
|
|
15677
|
+
className: "chat-scroll-to-bottom",
|
|
15678
|
+
"aria-label": "Scroll to latest messages",
|
|
15679
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ChevronDown, { className: "size-5", strokeWidth: 2.25 })
|
|
15680
|
+
}
|
|
15681
|
+
),
|
|
15004
15682
|
isInitialLoading && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pointer-events-none absolute bottom-6 left-1/2 z-30 flex -translate-x-1/2 animate-in items-center gap-3 rounded-2xl border border-(--chat-border) bg-(--chat-surface)/80 px-5 py-2.5 shadow-xl backdrop-blur-md duration-400 fade-in slide-in-from-bottom-2", children: [
|
|
15005
15683
|
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.Loader2, { className: "h-3.5 w-3.5 animate-spin text-(--chat-theme)" }),
|
|
15006
15684
|
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-[10px] font-bold uppercase tracking-[0.15em] text-(--chat-muted)", children: "Loading messages..." })
|
|
@@ -15624,10 +16302,10 @@ function useChannelMessageBox({
|
|
|
15624
16302
|
const composerDisabledReason = conversationId ? composerDisabledByConversation[conversationId] : void 0;
|
|
15625
16303
|
const fileInputRef = React2.useRef(null);
|
|
15626
16304
|
const attachmentsCountRef = React2.useRef(0);
|
|
15627
|
-
|
|
16305
|
+
React2__namespace.default.useEffect(() => {
|
|
15628
16306
|
attachmentsCountRef.current = state.attachments.length;
|
|
15629
16307
|
}, [state.attachments.length]);
|
|
15630
|
-
|
|
16308
|
+
React2__namespace.default.useEffect(() => {
|
|
15631
16309
|
const draft = {
|
|
15632
16310
|
messageInput: state.messageInput,
|
|
15633
16311
|
attachments: state.attachments
|
|
@@ -15635,7 +16313,7 @@ function useChannelMessageBox({
|
|
|
15635
16313
|
syncComposerRef(draft);
|
|
15636
16314
|
updateConversationDraft(conversationIdRef.current, draft);
|
|
15637
16315
|
}, [state.messageInput, state.attachments, syncComposerRef]);
|
|
15638
|
-
|
|
16316
|
+
React2__namespace.default.useEffect(() => {
|
|
15639
16317
|
if (typingTimeoutRef.current) {
|
|
15640
16318
|
clearTimeout(typingTimeoutRef.current);
|
|
15641
16319
|
typingTimeoutRef.current = null;
|
|
@@ -16186,10 +16864,10 @@ function useForwardModal({ isOpen, onClose, items, onForwardComplete }) {
|
|
|
16186
16864
|
targetChannelRef.current = channel;
|
|
16187
16865
|
const targetConversationIds = [String(channel.conversationId)];
|
|
16188
16866
|
items.forEach((item) => {
|
|
16189
|
-
const
|
|
16190
|
-
if (!
|
|
16867
|
+
const messageId2 = String(item.message._id || item.message.id || "");
|
|
16868
|
+
if (!messageId2) return;
|
|
16191
16869
|
const payload = {
|
|
16192
|
-
messageId,
|
|
16870
|
+
messageId: messageId2,
|
|
16193
16871
|
sender: String(loggedUserDetails._id),
|
|
16194
16872
|
sourceConversationId: item.message.conversationId ? String(item.message.conversationId) : void 0,
|
|
16195
16873
|
targetConversationIds,
|
|
@@ -16666,8 +17344,8 @@ var ChatMain = ({
|
|
|
16666
17344
|
viewportHeight = "full",
|
|
16667
17345
|
viewportClassName
|
|
16668
17346
|
}) => {
|
|
16669
|
-
const clientObj =
|
|
16670
|
-
const uiConfigObj =
|
|
17347
|
+
const clientObj = React2__namespace.default.useMemo(() => ({ id: clientId }), [clientId]);
|
|
17348
|
+
const uiConfigObj = React2__namespace.default.useMemo(
|
|
16671
17349
|
() => ({
|
|
16672
17350
|
...uiConfig || {},
|
|
16673
17351
|
components: { ...uiConfig?.components, ...components },
|
|
@@ -17102,6 +17780,8 @@ var packageDefaultComponents = {
|
|
|
17102
17780
|
// src/index.ts
|
|
17103
17781
|
var index_default = ChatMain_default;
|
|
17104
17782
|
|
|
17783
|
+
exports.Calendar = Calendar;
|
|
17784
|
+
exports.CalendarDayButton = CalendarDayButton;
|
|
17105
17785
|
exports.Channel = Channel;
|
|
17106
17786
|
exports.ChannelHeader = ChannelHeaderView_default;
|
|
17107
17787
|
exports.ChannelList = ChannelListView_default;
|
|
@@ -17110,6 +17790,7 @@ exports.Chat = Chat;
|
|
|
17110
17790
|
exports.ChatAlertsProvider = ChatAlertsProvider;
|
|
17111
17791
|
exports.ChatAvatar = ChatAvatar_default;
|
|
17112
17792
|
exports.ChatCustomizationProvider = ChatCustomizationProvider;
|
|
17793
|
+
exports.ChatDateJumpMenu = ChatDateJumpMenu;
|
|
17113
17794
|
exports.ChatLayout = ChatLayout_default;
|
|
17114
17795
|
exports.ChatLocaleProvider = ChatLocaleProvider;
|
|
17115
17796
|
exports.ChatMain = ChatMain_default;
|
|
@@ -17125,6 +17806,7 @@ exports.MessageInput = ChannelMessageBoxView_default;
|
|
|
17125
17806
|
exports.MessageItem = MessageItemView;
|
|
17126
17807
|
exports.MessageList = ActiveChannelMessagesView_default;
|
|
17127
17808
|
exports.capitalizeFirst = capitalizeFirst;
|
|
17809
|
+
exports.clampJumpDate = clampJumpDate;
|
|
17128
17810
|
exports.default = index_default;
|
|
17129
17811
|
exports.defaultChatClassNames = defaultChatClassNames;
|
|
17130
17812
|
exports.defaultChatComponents = defaultChatComponents;
|
|
@@ -17140,8 +17822,14 @@ exports.mergeChatLayoutConfig = mergeChatLayoutConfig;
|
|
|
17140
17822
|
exports.packageDefaultComponents = packageDefaultComponents;
|
|
17141
17823
|
exports.resolveApiUrl = resolveApiUrl;
|
|
17142
17824
|
exports.resolveChatApiKey = resolveChatApiKey;
|
|
17825
|
+
exports.resolveJumpDateBounds = resolveJumpDateBounds;
|
|
17826
|
+
exports.resolveJumpPreset = resolveJumpPreset;
|
|
17827
|
+
exports.resolveJumpStep = resolveJumpStep;
|
|
17143
17828
|
exports.resolveSocketUrl = resolveSocketUrl;
|
|
17144
17829
|
exports.showNotification = showNotification;
|
|
17830
|
+
exports.smoothScrollToMessage = smoothScrollToMessage;
|
|
17831
|
+
exports.startOfLocalDay = startOfLocalDay;
|
|
17832
|
+
exports.toDateInputValue = toDateInputValue;
|
|
17145
17833
|
exports.uniqueList = uniqueList;
|
|
17146
17834
|
exports.useChatAlerts = useChatAlerts;
|
|
17147
17835
|
exports.useChatContext = useChatContext;
|