l-min-components 1.0.1216 → 1.6.1222

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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "l-min-components",
3
- "version": "1.0.1216",
3
+ "version": "1.6.1222",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "src/assets",
@@ -26,6 +26,7 @@ export const MainLayout = styled.div`
26
26
  justify-content: space-between;
27
27
  width: 100%;
28
28
  padding: 84px 20px 20px 0;
29
+ max-height: 100vh;
29
30
  `;
30
31
 
31
32
  export const LeftLayout = styled.div`
@@ -231,15 +231,6 @@ const useMessageKit = (affiliatesActive, selectedAccount, affiliateAccount) => {
231
231
  );
232
232
  }, [selectedAccount?.id]);
233
233
 
234
- // handle socket connection
235
- // const { sendJsonMessage, lastJsonMessage, readyState } = useWebSocket(
236
- // buildSocketUrl(),
237
- // {
238
- // share: false,
239
- // shouldReconnect: () => true,
240
- // }
241
- // );
242
-
243
234
  // get account type
244
235
  const [, request] = useAxios(
245
236
  {
@@ -528,7 +519,7 @@ const useMessageKit = (affiliatesActive, selectedAccount, affiliateAccount) => {
528
519
  // --- 2a. Update chats state ---
529
520
  const currentChatHistory = prevState.chats[roomId] || [];
530
521
  let updatedChatHistory = [...currentChatHistory];
531
- const todayDateString = "today"; // Or derive actual date string if needed
522
+ const todayDateString = "today"; // Assume API uses "today" for current day
532
523
 
533
524
  const todayGroupIndex = updatedChatHistory.findIndex(
534
525
  (group) => group.date === todayDateString
@@ -537,12 +528,15 @@ const useMessageKit = (affiliatesActive, selectedAccount, affiliateAccount) => {
537
528
  if (todayGroupIndex !== -1) {
538
529
  // "today" group exists, add message to it
539
530
  const todayGroup = updatedChatHistory[todayGroupIndex];
540
- const updatedTodayGroup = {
541
- ...todayGroup,
542
- messages: [...todayGroup.messages, newChatMessage], // Add new message
543
- };
544
- // Replace the old group with the updated one
545
- updatedChatHistory.splice(todayGroupIndex, 1, updatedTodayGroup);
531
+ // Avoid adding duplicates if WS sends the same message back
532
+ if (!todayGroup.messages.some((msg) => msg.id === newChatMessage.id)) {
533
+ const updatedTodayGroup = {
534
+ ...todayGroup,
535
+ messages: [...todayGroup.messages, newChatMessage], // Add new message
536
+ };
537
+ // Replace the old group with the updated one
538
+ updatedChatHistory.splice(todayGroupIndex, 1, updatedTodayGroup);
539
+ }
546
540
  } else {
547
541
  // "today" group doesn't exist, create it and add to the beginning
548
542
  const newTodayGroup = {
@@ -645,7 +639,10 @@ const useMessageKit = (affiliatesActive, selectedAccount, affiliateAccount) => {
645
639
  `Room ${roomId} not found in state, refetching room list.`
646
640
  );
647
641
  getMessageRoomsByCourses(null, true); // Refetch rooms once
648
- return; // Stop processing this message until room list is updated
642
+ // Room not found, trigger refetch but DO NOT return early.
643
+ // Allow the message to be processed for the 'chats' state at least.
644
+ getMessageRoomsByCourses(null, true); // Refetch rooms once
645
+ // Continue processing the message...
649
646
  }
650
647
 
651
648
  // --- Format WebSocket data into ChatMessage ---
@@ -672,13 +669,14 @@ const useMessageKit = (affiliatesActive, selectedAccount, affiliateAccount) => {
672
669
  // --- Update chats state ---
673
670
  const currentChatHistory = prevState.chats[roomId] || [];
674
671
  let updatedChatHistory = [...currentChatHistory];
675
- const todayDateString = "today"; // Or derive actual date string
672
+ const todayDateString = "today"; // Assume API uses "today" for current day
676
673
 
677
674
  const todayGroupIndex = updatedChatHistory.findIndex(
678
675
  (group) => group.date === todayDateString
679
676
  );
680
677
 
681
678
  if (todayGroupIndex !== -1) {
679
+ // "today" group exists
682
680
  const todayGroup = updatedChatHistory[todayGroupIndex];
683
681
  // Avoid adding duplicate messages if WS sends what we already added via sendMessage response
684
682
  if (
@@ -686,15 +684,17 @@ const useMessageKit = (affiliatesActive, selectedAccount, affiliateAccount) => {
686
684
  ) {
687
685
  const updatedTodayGroup = {
688
686
  ...todayGroup,
689
- messages: [...todayGroup.messages, newChatMessage],
687
+ messages: [...todayGroup.messages, newChatMessage], // Add message
690
688
  };
691
- updatedChatHistory.splice(todayGroupIndex, 1, updatedTodayGroup);
689
+ updatedChatHistory.splice(todayGroupIndex, 1, updatedTodayGroup); // Replace group
692
690
  }
693
691
  } else {
692
+ // "today" group doesn't exist, create it and prepend
694
693
  const newTodayGroup = {
695
694
  date: todayDateString,
696
695
  messages: [newChatMessage],
697
696
  };
697
+ // Prepend to maintain reverse chronological order of groups
698
698
  updatedChatHistory = [newTodayGroup, ...updatedChatHistory];
699
699
  }
700
700