@buerokratt-ria/common-gui-components 0.0.21 → 0.0.22

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/CHANGELOG.md CHANGED
@@ -4,6 +4,10 @@ All changes to this project will be documented in this file.
4
4
 
5
5
  ## Template [MajorVersion.MediterraneanVersion.MinorVersion] - DD-MM-YYYY
6
6
 
7
+ ## [0.0.22] - 01-07-2025
8
+
9
+ - Handled Previous Messages Edge Case in Buttons
10
+
7
11
  ## [0.0.21] - 30-06-2025
8
12
 
9
13
  - Fix Message With Buttons View.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@buerokratt-ria/common-gui-components",
3
- "version": "0.0.21",
3
+ "version": "0.0.22",
4
4
  "description": "Common GUI components and pre defined templates.",
5
5
  "main": "index.ts",
6
6
  "author": "ExiRai",
@@ -105,8 +105,10 @@ const HistoricalChat: FC<ChatProps> = ({
105
105
  const content = currentMessage.content?.trim() ?? "";
106
106
 
107
107
  if (content.startsWith("#service,") || content.startsWith("#common_service,")) {
108
- let buttons = messagesList[i - 1]?.buttons ? JSON.parse(messagesList[i - 1].buttons!) : [];
109
- currentMessage.content = buttons.find((b: any) => b.payload.includes(content))?.title ?? content;
108
+ const allPreviousButtons = messagesList
109
+ .slice(0, i)
110
+ .flatMap((msg) => (msg.buttons ? JSON.parse(msg.buttons) : []));
111
+ currentMessage.content = allPreviousButtons.find((b: any) => b.payload.includes(content))?.title ?? content;
110
112
  }
111
113
 
112
114
  const lastGroup = groupedMessages[groupedMessages.length - 1];
@@ -122,7 +124,7 @@ const HistoricalChat: FC<ChatProps> = ({
122
124
  content:
123
125
  currentMessage.event === CHAT_EVENTS.WAITING_VALIDATION
124
126
  ? t("chat.waiting_validation").toString()
125
- : content,
127
+ : currentMessage.content,
126
128
  });
127
129
  } else {
128
130
  groupedMessages.push({