Bugfix/Share Chatbot Config (#3742)

fix chatbot config
This commit is contained in:
Henry Heng
2024-12-19 13:36:32 +00:00
committed by GitHub
parent 2df129f91b
commit d6b35465e5
2 changed files with 10 additions and 12 deletions
+4 -4
View File
@@ -88,12 +88,12 @@ const ChatbotFull = () => {
parsedConfig = { ...parsedConfig, ...JSON.parse(chatflowData.chatbotConfig) } parsedConfig = { ...parsedConfig, ...JSON.parse(chatflowData.chatbotConfig) }
setChatbotTheme(parsedConfig) setChatbotTheme(parsedConfig)
if (parsedConfig.overrideConfig) { if (parsedConfig.overrideConfig) {
// Generate new sessionId
if (parsedConfig.overrideConfig.generateNewSession) {
parsedConfig.overrideConfig.sessionId = Date.now().toString()
}
setChatbotOverrideConfig(parsedConfig.overrideConfig) setChatbotOverrideConfig(parsedConfig.overrideConfig)
} }
if (parsedConfig.generateNewSession) {
localStorage.removeItem(`${chatflowData.id}_EXTERNAL`)
}
} catch (e) { } catch (e) {
console.error(e) console.error(e)
setChatbotTheme(parsedConfig) setChatbotTheme(parsedConfig)
@@ -111,8 +111,7 @@ const ShareChatbot = ({ isSessionMemory, isAgentCanvas }) => {
userMessage: { userMessage: {
showAvatar: false showAvatar: false
}, },
textInput: {}, textInput: {}
overrideConfig: {}
} }
if (title) obj.title = title if (title) obj.title = title
if (titleAvatarSrc) obj.titleAvatarSrc = titleAvatarSrc if (titleAvatarSrc) obj.titleAvatarSrc = titleAvatarSrc
@@ -137,7 +136,7 @@ const ShareChatbot = ({ isSessionMemory, isAgentCanvas }) => {
if (textInputPlaceholder) obj.textInput.placeholder = textInputPlaceholder if (textInputPlaceholder) obj.textInput.placeholder = textInputPlaceholder
if (textInputSendButtonColor) obj.textInput.sendButtonColor = textInputSendButtonColor if (textInputSendButtonColor) obj.textInput.sendButtonColor = textInputSendButtonColor
if (isSessionMemory) obj.overrideConfig.generateNewSession = generateNewSession if (isSessionMemory) obj.generateNewSession = generateNewSession
if (renderHTML) { if (renderHTML) {
obj.renderHTML = true obj.renderHTML = true
@@ -145,8 +144,6 @@ const ShareChatbot = ({ isSessionMemory, isAgentCanvas }) => {
obj.renderHTML = false obj.renderHTML = false
} }
if (chatbotConfig?.starterPrompts) obj.starterPrompts = chatbotConfig.starterPrompts
if (isAgentCanvas) { if (isAgentCanvas) {
// if showAgentMessages is undefined, default to true // if showAgentMessages is undefined, default to true
if (showAgentMessages === undefined || showAgentMessages === null) { if (showAgentMessages === undefined || showAgentMessages === null) {
@@ -156,9 +153,10 @@ const ShareChatbot = ({ isSessionMemory, isAgentCanvas }) => {
} }
} }
if (chatbotConfig?.fullFileUpload) obj.fullFileUpload = chatbotConfig?.fullFileUpload return {
...chatbotConfig,
return obj ...obj
}
} }
const onSave = async () => { const onSave = async () => {