From f5ddcf2ce42a7b79461d2faf24768702d89af864 Mon Sep 17 00:00:00 2001 From: tjtanjin Date: Sun, 24 Nov 2024 01:57:42 -0800 Subject: [PATCH] fix: Fix message sender capitalization and update changelog and version --- CHANGELOG.md | 9 +++++++++ package-lock.json | 4 ++-- package.json | 2 +- src/hooks/internal/useBotEffectsInternal.tsx | 2 +- src/hooks/internal/useMessagesInternal.ts | 2 +- src/services/ChatHistoryService.tsx | 6 +++--- 6 files changed, 17 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3a5f079..1fe57dc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,14 @@ # CHANGELOG.md +## v2.0.0-beta.25 (25-11-2024) + +**Fixed:** +- Fixed an issue with z-index causing display issues in embedded chatbots +- Fixed and improved stream logic for messages + +**Note:** +The message `sender` field now defaults to being fully capitalized (i.e. `bot` -> `BOT`). However, it is also no longer case sensitive so **no action is required**. + ## v2.0.0-beta.24 (13-11-2024) **Fixed:** diff --git a/package-lock.json b/package-lock.json index b9d3af7..fe7a936 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "react-chatbotify", - "version": "2.0.0-beta.24", + "version": "2.0.0-beta.25", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "react-chatbotify", - "version": "2.0.0-beta.24", + "version": "2.0.0-beta.25", "license": "MIT", "devDependencies": { "@testing-library/jest-dom": "^6.6.2", diff --git a/package.json b/package.json index 18f5561..0410007 100644 --- a/package.json +++ b/package.json @@ -12,7 +12,7 @@ "files": [ "./dist" ], - "version": "2.0.0-beta.24", + "version": "2.0.0-beta.25", "description": "A modern React library for creating flexible and extensible chatbots.", "type": "module", "main": "./dist/index.cjs", diff --git a/src/hooks/internal/useBotEffectsInternal.tsx b/src/hooks/internal/useBotEffectsInternal.tsx index 04bb14e..516d70f 100644 --- a/src/hooks/internal/useBotEffectsInternal.tsx +++ b/src/hooks/internal/useBotEffectsInternal.tsx @@ -133,7 +133,7 @@ export const useBotEffectsInternal = () => { const historyMessages = getHistoryMessages(); if (historyMessages.length > 0) { // note: must always render this button even if autoload (chat history logic relies on system message) - const messageContent = createMessage(, "system"); + const messageContent = createMessage(, "SYSTEM"); replaceMessages([messageContent]); if (settings.chatHistory?.autoLoad) { showChatHistory(); diff --git a/src/hooks/internal/useMessagesInternal.ts b/src/hooks/internal/useMessagesInternal.ts index 5cb6dc5..50c6293 100644 --- a/src/hooks/internal/useMessagesInternal.ts +++ b/src/hooks/internal/useMessagesInternal.ts @@ -311,7 +311,7 @@ export const useMessagesInternal = () => { const lastMessage = updatedMessages[updatedMessages.length - 1]; // if message is sent by user or is bot typing or bot is embedded, return - if (!lastMessage || lastMessage.sender === "USER") { + if (!lastMessage || lastMessage.sender.toUpperCase() === "USER") { shouldNotify = false; } diff --git a/src/services/ChatHistoryService.tsx b/src/services/ChatHistoryService.tsx index e78d741..4edb816 100644 --- a/src/services/ChatHistoryService.tsx +++ b/src/services/ChatHistoryService.tsx @@ -155,7 +155,7 @@ const loadChatHistory = (settings: Settings, styles: Styles, chatHistory: Messag if (chatHistory != null) { try { setMessages((prevMessages) => { - const loaderMessage = createMessage(, "system"); + const loaderMessage = createMessage(, "SYSTEM"); prevMessages.shift(); return [loaderMessage, ...prevMessages]; }); @@ -174,9 +174,9 @@ const loadChatHistory = (settings: Settings, styles: Styles, chatHistory: Messag // if autoload, line break is invisible let lineBreakMessage; if (settings.chatHistory?.autoLoad) { - lineBreakMessage = createMessage(<>, "system") + lineBreakMessage = createMessage(<>, "SYSTEM") } else { - lineBreakMessage = createMessage(, "system") + lineBreakMessage = createMessage(, "SYSTEM") } return [...parsedMessages, lineBreakMessage, ...prevMessages]; });