@realtimexsco/live-chat 1.3.0 → 1.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +29 -1628
- package/dist/index.cjs +311 -146
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +78 -10
- package/dist/index.d.ts +78 -10
- package/dist/index.mjs +311 -147
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -370,7 +370,6 @@ var init_socket_service = __esm({
|
|
|
370
370
|
});
|
|
371
371
|
this.disconnect();
|
|
372
372
|
}
|
|
373
|
-
console.log("Socket: Starting connection to", config.url);
|
|
374
373
|
this.currentConfig = config;
|
|
375
374
|
this.isConnecting = true;
|
|
376
375
|
const store = getStore();
|
|
@@ -379,7 +378,6 @@ var init_socket_service = __esm({
|
|
|
379
378
|
this.socket = io(config.url, config.options);
|
|
380
379
|
this.socket.on("connect", () => {
|
|
381
380
|
this.isConnecting = false;
|
|
382
|
-
console.log("Connected to socket with ID:", this.socket?.id);
|
|
383
381
|
setConnected({ socketId: this.socket?.id || "" });
|
|
384
382
|
this.emitGetOnlineUsers();
|
|
385
383
|
});
|
|
@@ -557,7 +555,7 @@ var init_group_display_helpers = __esm({
|
|
|
557
555
|
});
|
|
558
556
|
|
|
559
557
|
// src/store/helpers/message.helpers.ts
|
|
560
|
-
var getMessageSenderId, extractMessageData, mergeLastMessage, messageHasPreviewBody, getLatestMessageFromList, isOwnMessage, getMessageContent, getMessageTimestamp,
|
|
558
|
+
var getMessageSenderId, extractMessageData, statusRank, preferHigherStatus, mergeLastMessage, messageHasPreviewBody, getLatestMessageFromList, isOwnMessage, getMessageContent, getMessageTimestamp, resolveMessageStatus, mergeChatMessages;
|
|
561
559
|
var init_message_helpers = __esm({
|
|
562
560
|
"src/store/helpers/message.helpers.ts"() {
|
|
563
561
|
getMessageSenderId = (message) => String(message?.sender?._id || message?.sender?.id || message?.senderId || message?.fromUserId || message?.sender || "");
|
|
@@ -572,21 +570,32 @@ var init_message_helpers = __esm({
|
|
|
572
570
|
const caption = payload.caption ?? payload.message?.caption ?? null;
|
|
573
571
|
return { messageId, content, conversationId, status, isPinned, isStarred, attachmentId, caption };
|
|
574
572
|
};
|
|
573
|
+
statusRank = { sent: 0, delivered: 1, read: 2 };
|
|
574
|
+
preferHigherStatus = (base, incoming) => {
|
|
575
|
+
const baseRank = statusRank[base?.status] ?? 0;
|
|
576
|
+
const incomingRank = statusRank[incoming?.status] ?? 0;
|
|
577
|
+
if (incomingRank > baseRank) {
|
|
578
|
+
return { ...base, status: incoming.status };
|
|
579
|
+
}
|
|
580
|
+
return base;
|
|
581
|
+
};
|
|
575
582
|
mergeLastMessage = (existing, incoming) => {
|
|
576
583
|
if (!incoming) return existing ?? null;
|
|
577
584
|
if (!existing) return incoming;
|
|
578
585
|
const content = incoming.content?.trim() ? incoming.content : existing.content;
|
|
579
586
|
const createdAt = incoming.createdAt ?? incoming.timestamp ?? existing.createdAt ?? existing.timestamp;
|
|
580
|
-
const
|
|
581
|
-
const
|
|
582
|
-
const newer = incomingTime >= existingTime ? incoming : existing;
|
|
587
|
+
const incomingSenderId = getMessageSenderId(incoming);
|
|
588
|
+
const resolvedSender = incomingSenderId ? incoming.sender ?? incoming.senderId ?? incoming.fromUserId : existing.sender ?? existing.senderId ?? existing.fromUserId ?? incoming.sender;
|
|
583
589
|
return {
|
|
584
590
|
...existing,
|
|
585
591
|
...incoming,
|
|
586
592
|
...content !== void 0 ? { content } : {},
|
|
587
593
|
...createdAt !== void 0 ? { createdAt } : {},
|
|
588
594
|
attachments: incoming.attachments?.length ? incoming.attachments : existing.attachments,
|
|
589
|
-
status:
|
|
595
|
+
status: preferHigherStatus(existing, incoming).status ?? existing.status ?? incoming.status,
|
|
596
|
+
...resolvedSender !== void 0 ? { sender: resolvedSender } : {},
|
|
597
|
+
senderId: incoming.senderId ?? existing.senderId,
|
|
598
|
+
fromUserId: incoming.fromUserId ?? existing.fromUserId
|
|
590
599
|
};
|
|
591
600
|
};
|
|
592
601
|
messageHasPreviewBody = (message) => Boolean(String(message?.content || "").trim()) || Array.isArray(message?.attachments) && message.attachments.length > 0;
|
|
@@ -609,15 +618,6 @@ var init_message_helpers = __esm({
|
|
|
609
618
|
const time = value ? new Date(value).getTime() : NaN;
|
|
610
619
|
return Number.isFinite(time) ? time : 0;
|
|
611
620
|
};
|
|
612
|
-
statusRank = { sent: 0, delivered: 1, read: 2 };
|
|
613
|
-
preferHigherStatus = (base, incoming) => {
|
|
614
|
-
const baseRank = statusRank[base?.status] ?? 0;
|
|
615
|
-
const incomingRank = statusRank[incoming?.status] ?? 0;
|
|
616
|
-
if (incomingRank > baseRank) {
|
|
617
|
-
return { ...base, status: incoming.status };
|
|
618
|
-
}
|
|
619
|
-
return base;
|
|
620
|
-
};
|
|
621
621
|
resolveMessageStatus = (message, conversation, loggedUserId) => {
|
|
622
622
|
const existing = message?.status || "sent";
|
|
623
623
|
if (!loggedUserId || !isOwnMessage(message, loggedUserId)) return existing;
|
|
@@ -792,7 +792,7 @@ var init_unread_helpers = __esm({
|
|
|
792
792
|
});
|
|
793
793
|
|
|
794
794
|
// src/store/helpers/conversation.helpers.ts
|
|
795
|
-
var findConversationIdByMessageId, isGroupConversation, normalizeConversationRecord, resolveConversationLastMessage, syncConversationLastMessage, upsertConversationInList, findConversationById, findConversationForChannel, resolveConversationIdForChannel;
|
|
795
|
+
var findConversationIdByMessageId, applyMessageStatusToStore, isGroupConversation, normalizeConversationRecord, resolveConversationLastMessage, syncConversationLastMessage, upsertConversationInList, findConversationById, findConversationIdByLastMessageId, findConversationForChannel, resolveConversationIdForChannel;
|
|
796
796
|
var init_conversation_helpers = __esm({
|
|
797
797
|
"src/store/helpers/conversation.helpers.ts"() {
|
|
798
798
|
init_group_display_helpers();
|
|
@@ -806,6 +806,40 @@ var init_conversation_helpers = __esm({
|
|
|
806
806
|
)
|
|
807
807
|
);
|
|
808
808
|
};
|
|
809
|
+
applyMessageStatusToStore = (state, messageId, status, conversationId) => {
|
|
810
|
+
const normalizedMessageId = String(messageId);
|
|
811
|
+
const resolvedConversationId = conversationId ? String(conversationId) : findConversationIdByMessageId(state.messagesByConversation, normalizedMessageId) || findConversationIdByLastMessageId(state.conversations, normalizedMessageId) || null;
|
|
812
|
+
const nextConversations = state.conversations.map((conversation) => {
|
|
813
|
+
const lastMessageId = String(
|
|
814
|
+
conversation?.lastMessage?._id || conversation?.lastMessage?.id || ""
|
|
815
|
+
);
|
|
816
|
+
if (lastMessageId !== normalizedMessageId) return conversation;
|
|
817
|
+
return {
|
|
818
|
+
...conversation,
|
|
819
|
+
lastMessage: mergeLastMessage(conversation.lastMessage, { status })
|
|
820
|
+
};
|
|
821
|
+
});
|
|
822
|
+
const nextMessagesByConversation = { ...state.messagesByConversation };
|
|
823
|
+
const patchMessages = (messages) => messages.map(
|
|
824
|
+
(message) => String(message._id || message.id) === normalizedMessageId ? preferHigherStatus(message, { status }) : message
|
|
825
|
+
);
|
|
826
|
+
if (resolvedConversationId && nextMessagesByConversation[resolvedConversationId]) {
|
|
827
|
+
nextMessagesByConversation[resolvedConversationId] = patchMessages(
|
|
828
|
+
nextMessagesByConversation[resolvedConversationId]
|
|
829
|
+
);
|
|
830
|
+
} else {
|
|
831
|
+
for (const cid of Object.keys(nextMessagesByConversation)) {
|
|
832
|
+
const patched = patchMessages(nextMessagesByConversation[cid]);
|
|
833
|
+
if (patched !== nextMessagesByConversation[cid]) {
|
|
834
|
+
nextMessagesByConversation[cid] = patched;
|
|
835
|
+
}
|
|
836
|
+
}
|
|
837
|
+
}
|
|
838
|
+
return {
|
|
839
|
+
conversations: nextConversations,
|
|
840
|
+
messagesByConversation: nextMessagesByConversation
|
|
841
|
+
};
|
|
842
|
+
};
|
|
809
843
|
isGroupConversation = (conversation) => {
|
|
810
844
|
if (!conversation) return false;
|
|
811
845
|
return conversation.conversationType === "group" || !!conversation.isGroup;
|
|
@@ -880,13 +914,29 @@ var init_conversation_helpers = __esm({
|
|
|
880
914
|
},
|
|
881
915
|
existing
|
|
882
916
|
);
|
|
883
|
-
|
|
884
|
-
|
|
917
|
+
if (index < 0) {
|
|
918
|
+
return [normalized, ...conversations];
|
|
919
|
+
}
|
|
920
|
+
if (lastMessageChanged) {
|
|
921
|
+
const withoutExisting = conversations.filter((_, itemIndex) => itemIndex !== index);
|
|
922
|
+
return [normalized, ...withoutExisting];
|
|
923
|
+
}
|
|
924
|
+
const next = [...conversations];
|
|
925
|
+
next[index] = normalized;
|
|
926
|
+
return next;
|
|
885
927
|
};
|
|
886
928
|
findConversationById = (conversations, conversationId) => {
|
|
887
929
|
if (!conversationId) return void 0;
|
|
888
930
|
return conversations.find((c) => String(c._id) === String(conversationId));
|
|
889
931
|
};
|
|
932
|
+
findConversationIdByLastMessageId = (conversations, messageId) => {
|
|
933
|
+
if (!messageId) return null;
|
|
934
|
+
const normalizedMessageId = String(messageId);
|
|
935
|
+
const match = conversations.find(
|
|
936
|
+
(conversation) => String(conversation?.lastMessage?._id || conversation?.lastMessage?.id || "") === normalizedMessageId
|
|
937
|
+
);
|
|
938
|
+
return match?._id ? String(match._id) : null;
|
|
939
|
+
};
|
|
890
940
|
findConversationForChannel = (channel, loggedUserId, conversations) => {
|
|
891
941
|
if (!channel || !loggedUserId) return void 0;
|
|
892
942
|
if (channel.conversationId) {
|
|
@@ -1086,13 +1136,109 @@ var init_connection_actions = __esm({
|
|
|
1086
1136
|
});
|
|
1087
1137
|
}
|
|
1088
1138
|
});
|
|
1089
|
-
|
|
1139
|
+
|
|
1140
|
+
// src/services/api/query-params.ts
|
|
1141
|
+
function resolveChatApiKey(url) {
|
|
1142
|
+
if (!url) return null;
|
|
1143
|
+
const path = url.split("?")[0] || "";
|
|
1144
|
+
if (path.includes("/user/login/client-user")) return "login";
|
|
1145
|
+
if (path.includes("/user/list")) return "users";
|
|
1146
|
+
if (path.includes("/conversation/list")) return "conversations";
|
|
1147
|
+
if (path.includes("/conversation/get/information/")) return "conversationInfo";
|
|
1148
|
+
if (path.includes("/message/get-all-from-conversation")) return "messages";
|
|
1149
|
+
if (path.includes("message/pinned-messages") || path.includes("/message/pinned-messages")) {
|
|
1150
|
+
return "pinnedMessages";
|
|
1151
|
+
}
|
|
1152
|
+
if (path.includes("message/starred-messages") || path.includes("/message/starred-messages")) {
|
|
1153
|
+
return "starredMessages";
|
|
1154
|
+
}
|
|
1155
|
+
if (path.includes("/message/search-messages")) return "searchMessages";
|
|
1156
|
+
if (path.includes("/message/searched-message/context")) return "searchMessagesContext";
|
|
1157
|
+
if (path.includes("/conversation/group/create")) return "createGroup";
|
|
1158
|
+
if (path.includes("/conversation/group/permission/update")) return "updateGroupPermissions";
|
|
1159
|
+
if (path.includes("/conversation/group/information/update")) return "updateGroupInfo";
|
|
1160
|
+
if (path.includes("/conversation/group/participants/add-remove")) return "manageMembers";
|
|
1161
|
+
if (path.includes("/conversation/group/admins/add-remove")) return "manageAdmins";
|
|
1162
|
+
if (path.includes("/user/block-unblock")) return "blockUnblock";
|
|
1163
|
+
if (path.includes("/aws/upload/get-presigned-urls")) return "presignedUrls";
|
|
1164
|
+
return null;
|
|
1165
|
+
}
|
|
1166
|
+
function isChatGetApiKey(key) {
|
|
1167
|
+
return !!key && CHAT_GET_API_KEYS.includes(key);
|
|
1168
|
+
}
|
|
1169
|
+
function normalizeQueryParams(params) {
|
|
1170
|
+
if (!params || typeof params !== "object") return {};
|
|
1171
|
+
const next = {};
|
|
1172
|
+
for (const [key, value] of Object.entries(params)) {
|
|
1173
|
+
if (value === void 0 || value === null) continue;
|
|
1174
|
+
const trimmedKey = String(key).trim();
|
|
1175
|
+
if (!trimmedKey) continue;
|
|
1176
|
+
next[trimmedKey] = String(value);
|
|
1177
|
+
}
|
|
1178
|
+
return next;
|
|
1179
|
+
}
|
|
1180
|
+
function normalizeQueryParamsByApi(byApi) {
|
|
1181
|
+
if (!byApi || typeof byApi !== "object") return {};
|
|
1182
|
+
const next = {};
|
|
1183
|
+
for (const [apiKey, params] of Object.entries(byApi)) {
|
|
1184
|
+
if (apiKey === "all" || apiKey === "get") continue;
|
|
1185
|
+
next[apiKey] = normalizeQueryParams(params);
|
|
1186
|
+
}
|
|
1187
|
+
return next;
|
|
1188
|
+
}
|
|
1189
|
+
var CHAT_GET_API_KEYS, CHAT_API_KEYS;
|
|
1190
|
+
var init_query_params = __esm({
|
|
1191
|
+
"src/services/api/query-params.ts"() {
|
|
1192
|
+
CHAT_GET_API_KEYS = [
|
|
1193
|
+
"users",
|
|
1194
|
+
"conversations",
|
|
1195
|
+
"conversationInfo",
|
|
1196
|
+
"messages",
|
|
1197
|
+
"pinnedMessages",
|
|
1198
|
+
"starredMessages",
|
|
1199
|
+
"searchMessages",
|
|
1200
|
+
"searchMessagesContext"
|
|
1201
|
+
];
|
|
1202
|
+
CHAT_API_KEYS = [
|
|
1203
|
+
"all",
|
|
1204
|
+
/** All GET endpoints listed in CHAT_GET_API_KEYS */
|
|
1205
|
+
"get",
|
|
1206
|
+
"login",
|
|
1207
|
+
...CHAT_GET_API_KEYS,
|
|
1208
|
+
"createGroup",
|
|
1209
|
+
"updateGroupPermissions",
|
|
1210
|
+
"updateGroupInfo",
|
|
1211
|
+
"manageMembers",
|
|
1212
|
+
"manageAdmins",
|
|
1213
|
+
"blockUnblock",
|
|
1214
|
+
"presignedUrls"
|
|
1215
|
+
];
|
|
1216
|
+
}
|
|
1217
|
+
});
|
|
1218
|
+
function resolveParamsForRequest(url, method) {
|
|
1219
|
+
const apiKey = resolveChatApiKey(url);
|
|
1220
|
+
const httpMethod = (method || "get").toLowerCase();
|
|
1221
|
+
const isGet = httpMethod === "get";
|
|
1222
|
+
const perApi = apiKey ? chatQueryParamsByApi[apiKey] : void 0;
|
|
1223
|
+
const applyShared = Object.keys(chatQueryParams).length > 0 && (chatQueryParamApis.includes("all") || chatQueryParamApis.includes("get") && isGet && isChatGetApiKey(apiKey) || apiKey != null && chatQueryParamApis.includes(apiKey));
|
|
1224
|
+
if (!applyShared && !perApi) return {};
|
|
1225
|
+
return {
|
|
1226
|
+
...applyShared ? chatQueryParams : {},
|
|
1227
|
+
...perApi || {}
|
|
1228
|
+
};
|
|
1229
|
+
}
|
|
1230
|
+
var chatClientId, chatAccessToken, chatBaseUrl, chatSocketUrl, chatQueryParams, chatQueryParamApis, chatQueryParamsByApi, setChatClientId, getChatClientId, setChatAccessToken, setChatBaseURL, getChatBaseUrl, setChatSocketUrl, getChatSocketUrl, setChatQueryParams, getChatQueryParams, setChatQueryParamApis, getChatQueryParamApis, setChatQueryParamsByApi, getChatQueryParamsByApi, rateLimitResetAt, isRateLimited, apiClient;
|
|
1090
1231
|
var init_client = __esm({
|
|
1091
1232
|
"src/services/api/client.ts"() {
|
|
1233
|
+
init_query_params();
|
|
1234
|
+
init_query_params();
|
|
1092
1235
|
chatClientId = "";
|
|
1093
1236
|
chatAccessToken = "";
|
|
1094
1237
|
chatBaseUrl = "";
|
|
1095
1238
|
chatSocketUrl = "";
|
|
1239
|
+
chatQueryParams = {};
|
|
1240
|
+
chatQueryParamApis = ["get"];
|
|
1241
|
+
chatQueryParamsByApi = {};
|
|
1096
1242
|
setChatClientId = (id) => {
|
|
1097
1243
|
chatClientId = id.trim();
|
|
1098
1244
|
};
|
|
@@ -1109,6 +1255,22 @@ var init_client = __esm({
|
|
|
1109
1255
|
chatSocketUrl = url.trim();
|
|
1110
1256
|
};
|
|
1111
1257
|
getChatSocketUrl = () => chatSocketUrl;
|
|
1258
|
+
setChatQueryParams = (params) => {
|
|
1259
|
+
chatQueryParams = normalizeQueryParams(params);
|
|
1260
|
+
};
|
|
1261
|
+
getChatQueryParams = () => ({ ...chatQueryParams });
|
|
1262
|
+
setChatQueryParamApis = (apis) => {
|
|
1263
|
+
if (!apis?.length) {
|
|
1264
|
+
chatQueryParamApis = ["get"];
|
|
1265
|
+
return;
|
|
1266
|
+
}
|
|
1267
|
+
chatQueryParamApis = [...apis];
|
|
1268
|
+
};
|
|
1269
|
+
getChatQueryParamApis = () => [...chatQueryParamApis];
|
|
1270
|
+
setChatQueryParamsByApi = (byApi) => {
|
|
1271
|
+
chatQueryParamsByApi = normalizeQueryParamsByApi(byApi);
|
|
1272
|
+
};
|
|
1273
|
+
getChatQueryParamsByApi = () => ({ ...chatQueryParamsByApi });
|
|
1112
1274
|
rateLimitResetAt = 0;
|
|
1113
1275
|
isRateLimited = () => Date.now() < rateLimitResetAt;
|
|
1114
1276
|
apiClient = axios.create({
|
|
@@ -1125,6 +1287,11 @@ var init_client = __esm({
|
|
|
1125
1287
|
config.headers.set("platform", "web");
|
|
1126
1288
|
config.headers.set("is-tenant", "true");
|
|
1127
1289
|
config.headers.set("x-client-id", chatClientId);
|
|
1290
|
+
const requestUrl = String(config.url || "");
|
|
1291
|
+
const scopedParams = resolveParamsForRequest(requestUrl, config.method);
|
|
1292
|
+
if (Object.keys(scopedParams).length > 0) {
|
|
1293
|
+
config.params = { ...scopedParams, ...config.params };
|
|
1294
|
+
}
|
|
1128
1295
|
try {
|
|
1129
1296
|
const { useStore: useStore2 } = (init_useStore(), __toCommonJS(useStore_exports));
|
|
1130
1297
|
const accessToken = useStore2.getState().accessToken || chatAccessToken;
|
|
@@ -2842,28 +3009,16 @@ var init_dm_actions = __esm({
|
|
|
2842
3009
|
},
|
|
2843
3010
|
receivedStatusUpdate: (payload) => {
|
|
2844
3011
|
const data = extractMessageData(payload);
|
|
2845
|
-
let { conversationId } = data;
|
|
2846
3012
|
const { messageId, status } = data;
|
|
2847
|
-
|
|
3013
|
+
let { conversationId } = data;
|
|
3014
|
+
if (!messageId || !status) return;
|
|
2848
3015
|
set({ lastStatusUpdate: payload });
|
|
2849
3016
|
if (!conversationId) {
|
|
2850
|
-
conversationId = findConversationIdByMessageId(get().messagesByConversation, messageId);
|
|
3017
|
+
conversationId = findConversationIdByMessageId(get().messagesByConversation, messageId) || findConversationIdByLastMessageId(get().conversations, messageId) || void 0;
|
|
2851
3018
|
}
|
|
2852
|
-
|
|
2853
|
-
|
|
2854
|
-
|
|
2855
|
-
return {
|
|
2856
|
-
messagesByConversation: {
|
|
2857
|
-
...state.messagesByConversation,
|
|
2858
|
-
[conversationId]: messages.map(
|
|
2859
|
-
(m) => String(m._id || m.id) === String(messageId) ? preferHigherStatus(m, { status }) : m
|
|
2860
|
-
)
|
|
2861
|
-
},
|
|
2862
|
-
conversations: state.conversations.map(
|
|
2863
|
-
(c) => String(c._id) === String(conversationId) && c.lastMessage && String(c.lastMessage._id || c.lastMessage.id) === String(messageId) ? { ...c, lastMessage: mergeLastMessage(c.lastMessage, { status }) } : c
|
|
2864
|
-
)
|
|
2865
|
-
};
|
|
2866
|
-
});
|
|
3019
|
+
set((state) => ({
|
|
3020
|
+
...applyMessageStatusToStore(state, String(messageId), status, conversationId)
|
|
3021
|
+
}));
|
|
2867
3022
|
},
|
|
2868
3023
|
receivedDMMarkRead: (payload) => {
|
|
2869
3024
|
const { conversationId } = payload;
|
|
@@ -3124,25 +3279,14 @@ var init_group_actions2 = __esm({
|
|
|
3124
3279
|
let { conversationId } = data;
|
|
3125
3280
|
const { messageId, status } = data;
|
|
3126
3281
|
set({ lastStatusUpdate: payload });
|
|
3282
|
+
if (!status) return;
|
|
3127
3283
|
if (messageId) {
|
|
3128
3284
|
if (!conversationId) {
|
|
3129
|
-
conversationId = findConversationIdByMessageId(get().messagesByConversation, messageId);
|
|
3285
|
+
conversationId = findConversationIdByMessageId(get().messagesByConversation, messageId) || findConversationIdByLastMessageId(get().conversations, messageId) || void 0;
|
|
3130
3286
|
}
|
|
3131
|
-
|
|
3132
|
-
|
|
3133
|
-
|
|
3134
|
-
return {
|
|
3135
|
-
messagesByConversation: {
|
|
3136
|
-
...state.messagesByConversation,
|
|
3137
|
-
[conversationId]: messages.map(
|
|
3138
|
-
(m) => String(m._id || m.id) === String(messageId) ? { ...m, status } : m
|
|
3139
|
-
)
|
|
3140
|
-
},
|
|
3141
|
-
conversations: state.conversations.map(
|
|
3142
|
-
(c) => String(c._id) === String(conversationId) && c.lastMessage && String(c.lastMessage._id || c.lastMessage.id) === String(messageId) ? { ...c, lastMessage: { ...c.lastMessage, status } } : c
|
|
3143
|
-
)
|
|
3144
|
-
};
|
|
3145
|
-
});
|
|
3287
|
+
set((state) => ({
|
|
3288
|
+
...applyMessageStatusToStore(state, String(messageId), status, conversationId)
|
|
3289
|
+
}));
|
|
3146
3290
|
return;
|
|
3147
3291
|
}
|
|
3148
3292
|
if (conversationId && status === "read") {
|
|
@@ -3157,7 +3301,7 @@ var init_group_actions2 = __esm({
|
|
|
3157
3301
|
if (String(c._id) !== String(conversationId)) return c;
|
|
3158
3302
|
let nextLastMessage = c.lastMessage;
|
|
3159
3303
|
if (nextLastMessage && String(nextLastMessage.sender?._id || nextLastMessage.sender) === String(myId)) {
|
|
3160
|
-
nextLastMessage =
|
|
3304
|
+
nextLastMessage = mergeLastMessage(nextLastMessage, { status: "read" });
|
|
3161
3305
|
}
|
|
3162
3306
|
return { ...c, lastMessage: nextLastMessage };
|
|
3163
3307
|
});
|
|
@@ -4310,6 +4454,9 @@ var Chat = ({
|
|
|
4310
4454
|
loggedUserDetails,
|
|
4311
4455
|
apiUrl,
|
|
4312
4456
|
socketUrl,
|
|
4457
|
+
queryParams,
|
|
4458
|
+
queryParamApis,
|
|
4459
|
+
queryParamsByApi,
|
|
4313
4460
|
channelsData,
|
|
4314
4461
|
messagesData,
|
|
4315
4462
|
onMessageReceived,
|
|
@@ -4329,6 +4476,9 @@ var Chat = ({
|
|
|
4329
4476
|
if (!clientId || !loggedUserDetails) return;
|
|
4330
4477
|
setSessionReady(false);
|
|
4331
4478
|
setChatClientId(clientId);
|
|
4479
|
+
setChatQueryParams(queryParams);
|
|
4480
|
+
setChatQueryParamApis(queryParamApis);
|
|
4481
|
+
setChatQueryParamsByApi(queryParamsByApi);
|
|
4332
4482
|
const resolvedApiUrl = resolveApiUrl(apiUrl);
|
|
4333
4483
|
const resolvedSocketUrl = resolveSocketUrl(socketUrl, resolvedApiUrl);
|
|
4334
4484
|
if (resolvedApiUrl) setChatBaseURL(resolvedApiUrl);
|
|
@@ -4398,9 +4548,22 @@ var Chat = ({
|
|
|
4398
4548
|
initializeChat();
|
|
4399
4549
|
return () => {
|
|
4400
4550
|
setSessionReady(false);
|
|
4551
|
+
setChatQueryParams({});
|
|
4552
|
+
setChatQueryParamApis(["get"]);
|
|
4553
|
+
setChatQueryParamsByApi({});
|
|
4401
4554
|
socket_service_default.disconnect();
|
|
4402
4555
|
};
|
|
4403
4556
|
}, [client?.id, loggedUserDetails?._id, loggedUserDetails?.email, accessToken, apiUrl, socketUrl, setSession, setSessionReady]);
|
|
4557
|
+
const queryConfigKey = JSON.stringify({
|
|
4558
|
+
queryParams: queryParams ?? {},
|
|
4559
|
+
queryParamApis: queryParamApis ?? ["get"],
|
|
4560
|
+
queryParamsByApi: queryParamsByApi ?? {}
|
|
4561
|
+
});
|
|
4562
|
+
React2.useEffect(() => {
|
|
4563
|
+
setChatQueryParams(queryParams);
|
|
4564
|
+
setChatQueryParamApis(queryParamApis);
|
|
4565
|
+
setChatQueryParamsByApi(queryParamsByApi);
|
|
4566
|
+
}, [queryConfigKey]);
|
|
4404
4567
|
React2.useEffect(() => {
|
|
4405
4568
|
if (lastDM && onMessageReceived) {
|
|
4406
4569
|
onMessageReceived(lastDM);
|
|
@@ -5272,19 +5435,6 @@ function SheetTitle({
|
|
|
5272
5435
|
}
|
|
5273
5436
|
);
|
|
5274
5437
|
}
|
|
5275
|
-
function SheetDescription({
|
|
5276
|
-
className,
|
|
5277
|
-
...props
|
|
5278
|
-
}) {
|
|
5279
|
-
return /* @__PURE__ */ jsx(
|
|
5280
|
-
Dialog$1.Description,
|
|
5281
|
-
{
|
|
5282
|
-
"data-slot": "sheet-description",
|
|
5283
|
-
className: cn("text-muted-foreground text-sm", className),
|
|
5284
|
-
...props
|
|
5285
|
-
}
|
|
5286
|
-
);
|
|
5287
|
-
}
|
|
5288
5438
|
function AlertDialog({
|
|
5289
5439
|
...props
|
|
5290
5440
|
}) {
|
|
@@ -5612,7 +5762,7 @@ function useCreateChatDialog({
|
|
|
5612
5762
|
onUserSelect?.({
|
|
5613
5763
|
id: user._id,
|
|
5614
5764
|
name: user.name.charAt(0).toUpperCase() + user.name.slice(1),
|
|
5615
|
-
image: user.image ||
|
|
5765
|
+
image: user.image || void 0,
|
|
5616
5766
|
email: user.email,
|
|
5617
5767
|
isOnline: onlineUsersIds.includes(user._id),
|
|
5618
5768
|
isGroup: false,
|
|
@@ -6024,14 +6174,14 @@ var LoggedUserDetails = ({
|
|
|
6024
6174
|
isActive: loggedUserDetails?.isActive ?? true,
|
|
6025
6175
|
createdAt: loggedUserDetails?.createdAt ? new Date(loggedUserDetails.createdAt) : /* @__PURE__ */ new Date(),
|
|
6026
6176
|
updatedAt: loggedUserDetails?.updatedAt ? new Date(loggedUserDetails.updatedAt) : /* @__PURE__ */ new Date(),
|
|
6027
|
-
image: loggedUserDetails?.image ||
|
|
6177
|
+
image: loggedUserDetails?.image || void 0
|
|
6028
6178
|
};
|
|
6029
6179
|
return /* @__PURE__ */ jsxs("div", { className: "shrink-0 border-b border-(--chat-border) bg-(--chat-surface) px-3 pb-3 pt-3", children: [
|
|
6030
6180
|
/* @__PURE__ */ jsxs("div", { className: "flex min-w-0 items-center gap-2.5", children: [
|
|
6031
6181
|
/* @__PURE__ */ jsxs("div", { className: "relative shrink-0", children: [
|
|
6032
6182
|
/* @__PURE__ */ jsxs(Avatar, { className: "size-8 ring-1 ring-(--chat-surface)", children: [
|
|
6033
|
-
/* @__PURE__ */ jsx(AvatarImage, { src: user
|
|
6034
|
-
/* @__PURE__ */ jsx(AvatarFallback, { className: "bg-(--chat-theme-10) text-[10px] font-medium text-(--chat-theme)", children: user.name.charAt(0).toUpperCase() })
|
|
6183
|
+
user.image ? /* @__PURE__ */ jsx(AvatarImage, { src: user.image, alt: user.name }) : null,
|
|
6184
|
+
/* @__PURE__ */ jsx(AvatarFallback, { className: "bg-(--chat-theme-10) text-[10px] font-medium text-(--chat-theme)", children: (user.name || "?").charAt(0).toUpperCase() })
|
|
6035
6185
|
] }),
|
|
6036
6186
|
/* @__PURE__ */ jsx("span", { className: "absolute -bottom-0.5 -right-0.5 size-2 rounded-full border-2 border-(--chat-surface) bg-(--chat-online)" })
|
|
6037
6187
|
] }),
|
|
@@ -6650,7 +6800,7 @@ function useChannelList({ debouncedSearch = "" }) {
|
|
|
6650
6800
|
const conversationId = String(c._id);
|
|
6651
6801
|
const { id: otherParticipantId, user: resolvedUser } = isGroup ? { id: conversationId, user: null } : resolveOtherParticipant(c, loggedUserDetails?._id, allUsers);
|
|
6652
6802
|
const name = isGroup ? c.groupName || c.name || "Group Chat" : resolvedUser?.name || "Unknown User";
|
|
6653
|
-
const image = isGroup ? resolveGroupImage(c) : resolvedUser?.image ||
|
|
6803
|
+
const image = isGroup ? resolveGroupImage(c) : resolvedUser?.image || void 0;
|
|
6654
6804
|
const isOnline = isGroup ? false : otherParticipantId ? onlineUserIds.includes(otherParticipantId) : false;
|
|
6655
6805
|
const unreadCount = normalizeUnreadCount(c.unreadCount, loggedUserDetails?._id);
|
|
6656
6806
|
const isTyping = typingUsersByConv[String(c._id)]?.length > 0;
|
|
@@ -6666,15 +6816,13 @@ function useChannelList({ debouncedSearch = "" }) {
|
|
|
6666
6816
|
}
|
|
6667
6817
|
}
|
|
6668
6818
|
const draftPreview = getConversationDraftPreview(conversationId);
|
|
6669
|
-
const
|
|
6670
|
-
|
|
6671
|
-
);
|
|
6672
|
-
const
|
|
6673
|
-
|
|
6674
|
-
resolvedLastMessage
|
|
6675
|
-
|
|
6676
|
-
loggedUserDetails?._id
|
|
6677
|
-
);
|
|
6819
|
+
const storedLastMessage = c.lastMessage;
|
|
6820
|
+
const storedLastMessageId = String(storedLastMessage?._id || storedLastMessage?.id || "");
|
|
6821
|
+
const resolvedLastMessageId = String(resolvedLastMessage?._id || resolvedLastMessage?.id || "");
|
|
6822
|
+
const lastMessageStatus = storedLastMessageId && resolvedLastMessageId && storedLastMessageId === resolvedLastMessageId ? preferHigherStatus(
|
|
6823
|
+
{ status: storedLastMessage?.status },
|
|
6824
|
+
{ status: resolvedLastMessage?.status }
|
|
6825
|
+
).status ?? storedLastMessage?.status ?? resolvedLastMessage?.status : storedLastMessage?.status;
|
|
6678
6826
|
return {
|
|
6679
6827
|
id: isGroup ? conversationId : otherParticipantId,
|
|
6680
6828
|
conversationId,
|
|
@@ -6688,12 +6836,11 @@ function useChannelList({ debouncedSearch = "" }) {
|
|
|
6688
6836
|
unreadCount,
|
|
6689
6837
|
isTyping,
|
|
6690
6838
|
draftPreview,
|
|
6691
|
-
isOwnLastMessage,
|
|
6692
6839
|
pinnedCount: c.pinnedCount,
|
|
6693
6840
|
starredCount: c.starredCount,
|
|
6694
6841
|
lastMessage: {
|
|
6695
6842
|
content: lastMessageContent,
|
|
6696
|
-
timestamp: resolvedLastMessage?.createdAt ? formatSidebarTime(resolvedLastMessage.createdAt) : "",
|
|
6843
|
+
timestamp: resolvedLastMessage?.createdAt ? formatSidebarTime(resolvedLastMessage.createdAt) : c.lastMessage?.createdAt ? formatSidebarTime(c.lastMessage.createdAt) : "",
|
|
6697
6844
|
status: lastMessageStatus,
|
|
6698
6845
|
sender: "User"
|
|
6699
6846
|
}
|
|
@@ -6722,7 +6869,7 @@ function useChannelList({ debouncedSearch = "" }) {
|
|
|
6722
6869
|
init_store_helpers();
|
|
6723
6870
|
function ChannelListItem({ channel, activeChannel, onChannelSelect }) {
|
|
6724
6871
|
const isActive = activeChannel?.conversationId ? String(activeChannel.conversationId) === String(channel.conversationId) : activeChannel?.id === channel.id;
|
|
6725
|
-
const showReadReceipt = channel.
|
|
6872
|
+
const showReadReceipt = !!channel.lastMessage?.status && !channel.unreadCount && !channel.isTyping && !channel.draftPreview;
|
|
6726
6873
|
const lastStatus = channel.lastMessage?.status;
|
|
6727
6874
|
return /* @__PURE__ */ jsxs(
|
|
6728
6875
|
"div",
|
|
@@ -6735,7 +6882,7 @@ function ChannelListItem({ channel, activeChannel, onChannelSelect }) {
|
|
|
6735
6882
|
children: [
|
|
6736
6883
|
/* @__PURE__ */ jsxs("div", { className: "relative shrink-0", children: [
|
|
6737
6884
|
/* @__PURE__ */ jsxs(Avatar, { className: "size-9", children: [
|
|
6738
|
-
/* @__PURE__ */ jsx(AvatarImage, { src: channel.image, alt: channel.name }),
|
|
6885
|
+
channel.image ? /* @__PURE__ */ jsx(AvatarImage, { src: channel.image, alt: channel.name }) : null,
|
|
6739
6886
|
/* @__PURE__ */ jsx(AvatarFallback, { className: cn(
|
|
6740
6887
|
"text-[10px] font-medium",
|
|
6741
6888
|
isActive ? "bg-(--chat-theme-20) text-(--chat-theme)" : "bg-(--chat-input-bg) text-(--chat-muted)"
|
|
@@ -8377,34 +8524,33 @@ function MessageForwardedLabel({ isSender, className, overlay }) {
|
|
|
8377
8524
|
}
|
|
8378
8525
|
);
|
|
8379
8526
|
}
|
|
8527
|
+
function GroupSenderName({ name, className }) {
|
|
8528
|
+
return /* @__PURE__ */ jsx(
|
|
8529
|
+
"span",
|
|
8530
|
+
{
|
|
8531
|
+
className: cn(
|
|
8532
|
+
"block max-w-full truncate text-[13px] font-semibold leading-[1.15] tracking-tight text-(--chat-incoming-text)",
|
|
8533
|
+
className
|
|
8534
|
+
),
|
|
8535
|
+
children: name
|
|
8536
|
+
}
|
|
8537
|
+
);
|
|
8538
|
+
}
|
|
8380
8539
|
|
|
8381
8540
|
// src/chat/lib/chat-message-bubble.ts
|
|
8382
|
-
function getBubbleCornerClasses(
|
|
8383
|
-
|
|
8384
|
-
return cn(
|
|
8385
|
-
"rounded-tl-[18px] rounded-bl-[18px]",
|
|
8386
|
-
isGroupedWithPrev ? "rounded-tr-[6px]" : "rounded-tr-[18px]",
|
|
8387
|
-
isGroupedWithNext ? "rounded-br-[6px]" : "rounded-br-[4px]"
|
|
8388
|
-
);
|
|
8389
|
-
}
|
|
8390
|
-
return cn(
|
|
8391
|
-
"rounded-tr-[18px] rounded-br-[18px]",
|
|
8392
|
-
isGroupedWithPrev ? "rounded-tl-[6px]" : "rounded-tl-[18px]",
|
|
8393
|
-
isGroupedWithNext ? "rounded-bl-[6px]" : "rounded-bl-[4px]"
|
|
8394
|
-
);
|
|
8541
|
+
function getBubbleCornerClasses() {
|
|
8542
|
+
return "rounded-tl-[18px] rounded-tr-[18px] rounded-br-[18px] rounded-bl-none";
|
|
8395
8543
|
}
|
|
8396
8544
|
function getChatBubbleClasses({
|
|
8397
8545
|
isSender = false,
|
|
8398
|
-
isGroupedWithPrev = false,
|
|
8399
|
-
isGroupedWithNext = false,
|
|
8400
8546
|
surface,
|
|
8401
8547
|
className
|
|
8402
8548
|
}) {
|
|
8403
8549
|
const resolvedSurface = surface ?? (isSender ? "sent" : "received");
|
|
8404
8550
|
const isNeutral = resolvedSurface === "neutral";
|
|
8405
8551
|
return cn(
|
|
8406
|
-
"relative
|
|
8407
|
-
getBubbleCornerClasses(
|
|
8552
|
+
"relative",
|
|
8553
|
+
getBubbleCornerClasses(),
|
|
8408
8554
|
resolvedSurface === "sent" && "chat-bubble-sent bg-(--chat-theme) text-white",
|
|
8409
8555
|
resolvedSurface === "received" && "chat-bubble-received border border-(--chat-border)/60 bg-(--chat-incoming-bubble) text-(--chat-incoming-text)",
|
|
8410
8556
|
isNeutral && "chat-bubble-received border border-(--chat-border)/60 bg-(--chat-incoming-bubble) text-(--chat-incoming-text)",
|
|
@@ -10219,8 +10365,6 @@ function MessageAttachmentsView({
|
|
|
10219
10365
|
"relative w-full",
|
|
10220
10366
|
isBubbleLayout && getChatBubbleClasses({
|
|
10221
10367
|
isSender,
|
|
10222
|
-
isGroupedWithPrev,
|
|
10223
|
-
isGroupedWithNext,
|
|
10224
10368
|
surface: bubbleSurface,
|
|
10225
10369
|
className: cn(
|
|
10226
10370
|
isImageOnlyBubble ? "p-0" : isForwarded ? "px-2 py-0.5" : "px-2.5 py-1"
|
|
@@ -10228,7 +10372,7 @@ function MessageAttachmentsView({
|
|
|
10228
10372
|
})
|
|
10229
10373
|
),
|
|
10230
10374
|
children: [
|
|
10231
|
-
!isSender && showSenderLabel && senderName && /* @__PURE__ */ jsx("
|
|
10375
|
+
!isSender && showSenderLabel && senderName && /* @__PURE__ */ jsx("div", { className: "px-0.5 pb-1", children: /* @__PURE__ */ jsx(GroupSenderName, { name: senderName }) }),
|
|
10232
10376
|
isBubbleLayout && isForwarded && !isForwardedImageOnly && /* @__PURE__ */ jsx(MessageForwardedLabel, { isSender, className: "px-0 pt-0 pb-0" }),
|
|
10233
10377
|
isBubbleLayout && replySnippet ? /* @__PURE__ */ jsx("div", { className: "px-2 pb-1", children: replySnippet }) : null,
|
|
10234
10378
|
/* @__PURE__ */ jsxs("div", { className: cn(
|
|
@@ -11640,42 +11784,60 @@ var PermissionDrawer = ({ isOpen, onOpenChange, conversationId, conversationInfo
|
|
|
11640
11784
|
{ key: "allowMemberRemove", label: "Only Admin Can Remove Members", desc: "Only administrators can remove other participants.", inverted: true },
|
|
11641
11785
|
{ key: "moderationEnabled", label: "Moderation Enabled", desc: "Enables advanced message moderation features." }
|
|
11642
11786
|
];
|
|
11643
|
-
return /* @__PURE__ */ jsx(Sheet, { open: isOpen, onOpenChange, children: /* @__PURE__ */ jsxs(ChatSheetContent, { className: "
|
|
11644
|
-
/* @__PURE__ */
|
|
11645
|
-
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-
|
|
11646
|
-
/* @__PURE__ */ jsx(
|
|
11647
|
-
/* @__PURE__ */ jsx(SheetTitle, { className:
|
|
11787
|
+
return /* @__PURE__ */ jsx(Sheet, { open: isOpen, onOpenChange, children: /* @__PURE__ */ jsxs(ChatSheetContent, { showCloseButton: true, className: "sm:max-w-[380px]", children: [
|
|
11788
|
+
/* @__PURE__ */ jsxs(SheetHeader, { className: chatSheetHeaderClass, children: [
|
|
11789
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
|
|
11790
|
+
/* @__PURE__ */ jsx(UserKey, { size: 15, className: "shrink-0 text-(--chat-theme)" }),
|
|
11791
|
+
/* @__PURE__ */ jsx(SheetTitle, { className: chatSheetTitleClass, children: "Group Permissions" })
|
|
11648
11792
|
] }),
|
|
11649
|
-
/* @__PURE__ */ jsx(
|
|
11650
|
-
] })
|
|
11651
|
-
/* @__PURE__ */
|
|
11652
|
-
/* @__PURE__ */ jsxs("
|
|
11653
|
-
/* @__PURE__ */ jsx("
|
|
11654
|
-
/* @__PURE__ */ jsx("
|
|
11793
|
+
/* @__PURE__ */ jsx("p", { className: chatSheetSubtitleClass, children: "Manage what members can and cannot do in this group." })
|
|
11794
|
+
] }),
|
|
11795
|
+
/* @__PURE__ */ jsxs("div", { className: cn(chatSheetBodyClass, "flex flex-col px-2.5 py-2"), children: [
|
|
11796
|
+
/* @__PURE__ */ jsxs("section", { className: "mb-2.5 flex-1", children: [
|
|
11797
|
+
/* @__PURE__ */ jsx("h3", { className: "mb-1 px-0.5 text-[10px] font-semibold uppercase tracking-wide text-(--chat-muted)", children: "Permissions" }),
|
|
11798
|
+
/* @__PURE__ */ jsx("div", { className: "rounded-lg border border-(--chat-border) px-3", children: permissionItems.map((item, index) => /* @__PURE__ */ jsxs(
|
|
11799
|
+
"div",
|
|
11800
|
+
{
|
|
11801
|
+
className: cn(
|
|
11802
|
+
"flex items-start justify-between gap-3 py-2.5",
|
|
11803
|
+
index < permissionItems.length - 1 && "border-b border-(--chat-border)"
|
|
11804
|
+
),
|
|
11805
|
+
children: [
|
|
11806
|
+
/* @__PURE__ */ jsxs("div", { className: "min-w-0 space-y-0.5", children: [
|
|
11807
|
+
/* @__PURE__ */ jsx("p", { className: "text-[12px] font-semibold leading-snug text-(--chat-text)", children: item.label }),
|
|
11808
|
+
/* @__PURE__ */ jsx("p", { className: "text-[10px] leading-relaxed text-(--chat-muted)", children: item.desc })
|
|
11809
|
+
] }),
|
|
11810
|
+
/* @__PURE__ */ jsx(
|
|
11811
|
+
Switch,
|
|
11812
|
+
{
|
|
11813
|
+
size: "sm",
|
|
11814
|
+
className: "mt-0.5 shrink-0 data-[state=checked]:bg-(--chat-theme) data-[state=unchecked]:bg-(--chat-border)",
|
|
11815
|
+
checked: "inverted" in item && item.inverted ? !permissions[item.key] : permissions[item.key],
|
|
11816
|
+
onCheckedChange: () => handleToggle(item.key)
|
|
11817
|
+
}
|
|
11818
|
+
)
|
|
11819
|
+
]
|
|
11820
|
+
},
|
|
11821
|
+
item.key
|
|
11822
|
+
)) })
|
|
11655
11823
|
] }),
|
|
11656
|
-
/* @__PURE__ */ jsx(
|
|
11657
|
-
|
|
11824
|
+
/* @__PURE__ */ jsx("div", { className: "sticky bottom-0 border-t border-(--chat-border) bg-(--chat-surface) px-0.5 pt-2.5 pb-1", children: /* @__PURE__ */ jsx(
|
|
11825
|
+
Button,
|
|
11658
11826
|
{
|
|
11659
|
-
|
|
11660
|
-
|
|
11827
|
+
size: "sm",
|
|
11828
|
+
className: "h-8 w-full border border-(--chat-theme) bg-(--chat-theme) text-[12px] text-white hover:opacity-90 disabled:opacity-50",
|
|
11829
|
+
onClick: handleSave,
|
|
11830
|
+
disabled: isSaving,
|
|
11831
|
+
children: isSaving ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
11832
|
+
/* @__PURE__ */ jsx(Loader2, { className: "mr-1 size-3 animate-spin" }),
|
|
11833
|
+
"Saving..."
|
|
11834
|
+
] }) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
11835
|
+
/* @__PURE__ */ jsx(Save, { className: "mr-1 size-3" }),
|
|
11836
|
+
"Save Permissions"
|
|
11837
|
+
] })
|
|
11661
11838
|
}
|
|
11662
|
-
)
|
|
11663
|
-
] }
|
|
11664
|
-
/* @__PURE__ */ jsx("div", { className: "border-t border-(--chat-border) bg-(--chat-elevated) p-6", children: /* @__PURE__ */ jsx(
|
|
11665
|
-
Button,
|
|
11666
|
-
{
|
|
11667
|
-
className: "w-full h-11 font-bold shadow-sm",
|
|
11668
|
-
onClick: handleSave,
|
|
11669
|
-
disabled: isSaving,
|
|
11670
|
-
children: isSaving ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
11671
|
-
/* @__PURE__ */ jsx(Loader2, { className: "mr-2 h-4 w-4 animate-spin" }),
|
|
11672
|
-
"Saving Changes..."
|
|
11673
|
-
] }) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
11674
|
-
/* @__PURE__ */ jsx(Save, { className: "mr-2 h-4 w-4" }),
|
|
11675
|
-
"Save Permissions"
|
|
11676
|
-
] })
|
|
11677
|
-
}
|
|
11678
|
-
) })
|
|
11839
|
+
) })
|
|
11840
|
+
] })
|
|
11679
11841
|
] }) });
|
|
11680
11842
|
};
|
|
11681
11843
|
var PermissionDrawer_default = PermissionDrawer;
|
|
@@ -12846,7 +13008,7 @@ var MessageToolbar = ({
|
|
|
12846
13008
|
}
|
|
12847
13009
|
),
|
|
12848
13010
|
/* @__PURE__ */ jsxs(Popover, { open: isReactionOpen, onOpenChange: setIsReactionOpen, children: [
|
|
12849
|
-
/* @__PURE__ */ jsx(PopoverTrigger, { asChild: true, children: /* @__PURE__ */ jsx(Button, { variant: "ghost", size: "icon", className: "size-7 rounded-full text-(--chat-
|
|
13011
|
+
/* @__PURE__ */ jsx(PopoverTrigger, { asChild: true, children: /* @__PURE__ */ jsx(Button, { variant: "ghost", size: "icon", className: "size-7 rounded-full text-(--chat-text) hover:bg-(--chat-hover)", children: /* @__PURE__ */ jsx(Smile, { className: "size-3.5" }) }) }),
|
|
12850
13012
|
/* @__PURE__ */ jsx(
|
|
12851
13013
|
PopoverContent,
|
|
12852
13014
|
{
|
|
@@ -13663,8 +13825,6 @@ function MessageItemTextBubble({
|
|
|
13663
13825
|
}) {
|
|
13664
13826
|
const bubbleClasses = (extra) => getChatBubbleClasses({
|
|
13665
13827
|
isSender,
|
|
13666
|
-
isGroupedWithPrev,
|
|
13667
|
-
isGroupedWithNext,
|
|
13668
13828
|
className: extra
|
|
13669
13829
|
});
|
|
13670
13830
|
return /* @__PURE__ */ jsxs(
|
|
@@ -13682,7 +13842,7 @@ function MessageItemTextBubble({
|
|
|
13682
13842
|
),
|
|
13683
13843
|
children: [
|
|
13684
13844
|
isForwarded && /* @__PURE__ */ jsx(MessageForwardedLabel, { isSender, className: "px-0 pt-0 pb-0" }),
|
|
13685
|
-
!isSender && showSenderLabel && senderName && /* @__PURE__ */ jsx(
|
|
13845
|
+
!isSender && showSenderLabel && senderName && /* @__PURE__ */ jsx(GroupSenderName, { name: senderName, className: "mb-0.5" }),
|
|
13686
13846
|
/* @__PURE__ */ jsx(
|
|
13687
13847
|
MessageReplySnippet_default,
|
|
13688
13848
|
{
|
|
@@ -13957,8 +14117,6 @@ function MessageItemView(props) {
|
|
|
13957
14117
|
const showMessageSelectionRadio = selectionMode && !isDeletedForEveryone && !!mid && !hasMultiAttachments;
|
|
13958
14118
|
const bubbleClasses = (extra) => getChatBubbleClasses({
|
|
13959
14119
|
isSender,
|
|
13960
|
-
isGroupedWithPrev,
|
|
13961
|
-
isGroupedWithNext,
|
|
13962
14120
|
className: extra
|
|
13963
14121
|
});
|
|
13964
14122
|
return /* @__PURE__ */ jsxs(
|
|
@@ -15965,7 +16123,7 @@ function useForwardModal({ isOpen, onClose, items, onForwardComplete }) {
|
|
|
15965
16123
|
(u) => String(u._id) === otherParticipantId
|
|
15966
16124
|
);
|
|
15967
16125
|
const name = isGroup ? c.groupName || "Group Chat" : resolvedUser?.name || otherParticipantData?.name || "Unknown User";
|
|
15968
|
-
const image = isGroup ? c.image || "" : resolvedUser?.image || otherParticipantData?.image ||
|
|
16126
|
+
const image = isGroup ? c.image || "" : resolvedUser?.image || otherParticipantData?.image || void 0;
|
|
15969
16127
|
return {
|
|
15970
16128
|
id: isGroup ? String(c._id) : otherParticipantId,
|
|
15971
16129
|
conversationId: String(c._id),
|
|
@@ -16433,6 +16591,9 @@ var ChatMain = ({
|
|
|
16433
16591
|
accessToken,
|
|
16434
16592
|
apiUrl,
|
|
16435
16593
|
socketUrl,
|
|
16594
|
+
queryParams,
|
|
16595
|
+
queryParamApis,
|
|
16596
|
+
queryParamsByApi,
|
|
16436
16597
|
themeColor = "#7494ec",
|
|
16437
16598
|
theme,
|
|
16438
16599
|
uiConfig,
|
|
@@ -16499,6 +16660,9 @@ var ChatMain = ({
|
|
|
16499
16660
|
uiConfig: uiConfigObj,
|
|
16500
16661
|
apiUrl,
|
|
16501
16662
|
socketUrl,
|
|
16663
|
+
queryParams,
|
|
16664
|
+
queryParamApis,
|
|
16665
|
+
queryParamsByApi,
|
|
16502
16666
|
children: /* @__PURE__ */ jsx(
|
|
16503
16667
|
ChatAlertsProvider,
|
|
16504
16668
|
{
|
|
@@ -16706,7 +16870,7 @@ var DefaultChannelListItem = ({
|
|
|
16706
16870
|
onSelect
|
|
16707
16871
|
}) => {
|
|
16708
16872
|
const { slotClassName } = useChatCustomizationOptional();
|
|
16709
|
-
const showReadReceipt = channel.
|
|
16873
|
+
const showReadReceipt = !!channel.lastMessage?.status && !channel.unreadCount && !channel.isTyping && !channel.draftPreview;
|
|
16710
16874
|
const lastStatus = channel.lastMessage?.status;
|
|
16711
16875
|
return /* @__PURE__ */ jsxs(
|
|
16712
16876
|
"div",
|
|
@@ -16892,6 +17056,6 @@ var packageDefaultComponents = {
|
|
|
16892
17056
|
// src/index.ts
|
|
16893
17057
|
var index_default = ChatMain_default;
|
|
16894
17058
|
|
|
16895
|
-
export { Channel, ChannelHeaderView_default as ChannelHeader, ChannelListView_default as ChannelList, ChannelListItem_default as ChannelListItem, Chat, ChatAlertsProvider, ChatAvatar_default as ChatAvatar, ChatCustomizationProvider, ChatLayout_default as ChatLayout, ChatLocaleProvider, ChatMain_default as ChatMain, ChatThemeProvider, ChatViewport, DefaultChannelListItem, DefaultChatAvatar, DefaultChatLayout_default as DefaultChatLayout, ForwardModalView as ForwardModal, HeaderCallActions_default as HeaderCallActions, LoggedUserDetails_default as LoggedUserDetails, ChannelMessageBoxView_default as MessageInput, MessageItemView as MessageItem, ActiveChannelMessagesView_default as MessageList, capitalizeFirst, index_default as default, defaultChatClassNames, defaultChatComponents, defaultChatFeatures, defaultChatLayoutConfig, downloadFile, getChatBaseUrl, getChatSocketUrl, getFirstAndLastNameOneCharacter, getResponsiveWidth, getSocketConfig, isEmpty, mergeChatCustomization, mergeChatLayoutConfig, packageDefaultComponents, resolveApiUrl, resolveSocketUrl, setChatAccessToken, setChatBaseURL, setChatClientId, setChatSocketUrl, showNotification, socket_service_default as socketService, uniqueList, useChatAlerts, useChatContext, useChatController, useChatCustomization, useChatCustomizationOptional, useChatFeatures, useChatFeaturesOptional, useChatLocale, useStore as useChatStore, useChatTheme };
|
|
17059
|
+
export { CHAT_API_KEYS, CHAT_GET_API_KEYS, Channel, ChannelHeaderView_default as ChannelHeader, ChannelListView_default as ChannelList, ChannelListItem_default as ChannelListItem, Chat, ChatAlertsProvider, ChatAvatar_default as ChatAvatar, ChatCustomizationProvider, ChatLayout_default as ChatLayout, ChatLocaleProvider, ChatMain_default as ChatMain, ChatThemeProvider, ChatViewport, DefaultChannelListItem, DefaultChatAvatar, DefaultChatLayout_default as DefaultChatLayout, ForwardModalView as ForwardModal, HeaderCallActions_default as HeaderCallActions, LoggedUserDetails_default as LoggedUserDetails, ChannelMessageBoxView_default as MessageInput, MessageItemView as MessageItem, ActiveChannelMessagesView_default as MessageList, capitalizeFirst, index_default as default, defaultChatClassNames, defaultChatComponents, defaultChatFeatures, defaultChatLayoutConfig, downloadFile, getChatBaseUrl, getChatQueryParamApis, getChatQueryParams, getChatQueryParamsByApi, getChatSocketUrl, getFirstAndLastNameOneCharacter, getResponsiveWidth, getSocketConfig, isEmpty, mergeChatCustomization, mergeChatLayoutConfig, packageDefaultComponents, resolveApiUrl, resolveChatApiKey, resolveSocketUrl, setChatAccessToken, setChatBaseURL, setChatClientId, setChatQueryParamApis, setChatQueryParams, setChatQueryParamsByApi, setChatSocketUrl, showNotification, socket_service_default as socketService, uniqueList, useChatAlerts, useChatContext, useChatController, useChatCustomization, useChatCustomizationOptional, useChatFeatures, useChatFeaturesOptional, useChatLocale, useStore as useChatStore, useChatTheme };
|
|
16896
17060
|
//# sourceMappingURL=index.mjs.map
|
|
16897
17061
|
//# sourceMappingURL=index.mjs.map
|