l-min-components 1.6.1245 → 1.6.1247
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/package.json
CHANGED
|
@@ -279,6 +279,7 @@ const useMessageKit = (/*affiliatesActive*/) => {
|
|
|
279
279
|
const [state, setState] = useState({
|
|
280
280
|
roomsByCourses: [],
|
|
281
281
|
chats: {},
|
|
282
|
+
loadingRoomIds: new Set(), // Track which rooms are currently loading
|
|
282
283
|
});
|
|
283
284
|
// State for rooms that should be automatically marked as read
|
|
284
285
|
const [autoReadRoomIds, setAutoReadRoomIds] = useState(() => new Set());
|
|
@@ -370,7 +371,14 @@ const useMessageKit = (/*affiliatesActive*/) => {
|
|
|
370
371
|
const getIndividualChats = async (nextPage, roomId, limit = 1000) => {
|
|
371
372
|
if (!selectedAccount) return;
|
|
372
373
|
|
|
373
|
-
|
|
374
|
+
// Add roomId to loading state
|
|
375
|
+
setState((prevState) => ({
|
|
376
|
+
...prevState,
|
|
377
|
+
loadingRoomIds: new Set([...prevState.loadingRoomIds, roomId])
|
|
378
|
+
}));
|
|
379
|
+
|
|
380
|
+
try {
|
|
381
|
+
let response;
|
|
374
382
|
if (String(selectedAccount.type).toLowerCase() === "enterprise") {
|
|
375
383
|
response = await request({
|
|
376
384
|
url: nextPage || "/notify/v1/enterprise/chats/",
|
|
@@ -480,10 +488,34 @@ const useMessageKit = (/*affiliatesActive*/) => {
|
|
|
480
488
|
});
|
|
481
489
|
}
|
|
482
490
|
|
|
491
|
+
// Only remove from loading state if this is the last page or there was an error
|
|
492
|
+
if (!responseData.next) {
|
|
493
|
+
setState((prevState) => {
|
|
494
|
+
const updatedLoadingRoomIds = new Set(prevState.loadingRoomIds);
|
|
495
|
+
updatedLoadingRoomIds.delete(roomId);
|
|
496
|
+
return {
|
|
497
|
+
...prevState,
|
|
498
|
+
loadingRoomIds: updatedLoadingRoomIds
|
|
499
|
+
};
|
|
500
|
+
});
|
|
501
|
+
}
|
|
502
|
+
|
|
483
503
|
// Pass roomId correctly in the recursive call
|
|
484
504
|
if (responseData.next) getIndividualChats(responseData.next, roomId);
|
|
485
505
|
return responseData;
|
|
486
|
-
}
|
|
506
|
+
} catch (error) {
|
|
507
|
+
// Remove from loading state in case of error
|
|
508
|
+
setState((prevState) => {
|
|
509
|
+
const updatedLoadingRoomIds = new Set(prevState.loadingRoomIds);
|
|
510
|
+
updatedLoadingRoomIds.delete(roomId);
|
|
511
|
+
return {
|
|
512
|
+
...prevState,
|
|
513
|
+
loadingRoomIds: updatedLoadingRoomIds
|
|
514
|
+
};
|
|
515
|
+
});
|
|
516
|
+
throw error; // Re-throw to allow error handling upstream
|
|
517
|
+
}
|
|
518
|
+
};
|
|
487
519
|
|
|
488
520
|
// read messages (using the latest message ID passed) and update counts
|
|
489
521
|
const readRoomMessages = async ({ latestMessageId, roomId }) => {
|
|
@@ -963,6 +995,12 @@ const useMessageKit = (/*affiliatesActive*/) => {
|
|
|
963
995
|
useEffect(() => {
|
|
964
996
|
(async () => {
|
|
965
997
|
await getMessageRoomsByCourses();
|
|
998
|
+
// reportChat({
|
|
999
|
+
// reasons: ["Verbal harassment"],
|
|
1000
|
+
// accountId: "24dbaeede1",
|
|
1001
|
+
// messageIds: ["438745c081564ee9aeb76ed29052bd4b"],
|
|
1002
|
+
// // others: "",
|
|
1003
|
+
// });
|
|
966
1004
|
// await deleteRoom("5be9b48281ac4c2885d3b719654ed59d");
|
|
967
1005
|
// await pinRoom("5be9b48281ac4c2885d3b719654ed59d");
|
|
968
1006
|
// Example: Fetch initial chat for a specific room if needed on load
|
|
@@ -1186,6 +1224,8 @@ const useMessageKit = (/*affiliatesActive*/) => {
|
|
|
1186
1224
|
pinRoom,
|
|
1187
1225
|
deleteRoom,
|
|
1188
1226
|
reportChat,
|
|
1227
|
+
// Helper method to check if a specific room is loading
|
|
1228
|
+
isRoomLoading: (roomId) => state.loadingRoomIds.has(roomId),
|
|
1189
1229
|
};
|
|
1190
1230
|
};
|
|
1191
1231
|
|