mirror of
https://github.com/dataelement/bisheng.git
synced 2026-09-01 04:47:53 +08:00
fix(workflow-chat): stop the history mapper from dropping attachment fields
History rebuilt each attachment as just a name and a url, so the id an image is resolved by — and the object name behind it — never reached the bubble: a refreshed conversation showed the picture stuck loading forever. It now spreads the stored entry instead of listing fields, which also keeps whatever the backend adds next.
This commit is contained in:
@@ -149,6 +149,7 @@ export async function getChatHistoryApi({ flowId, chatId, flowType, id, shareTok
|
||||
const _category = _isSend ? 'question' : category
|
||||
const _files = (files ? JSON.parse(files) : []).map(file => {
|
||||
return {
|
||||
...file,
|
||||
file_name: file.file_name || file.name,
|
||||
file_url: file.file_url || file.path,
|
||||
}
|
||||
|
||||
@@ -21,21 +21,7 @@ export default function MessageUser({ useName, data, showButton, disabledSearch
|
||||
const [config] = useRecoilState(bishengConfState)
|
||||
const localize = useLocalize()
|
||||
|
||||
// History returns the attachments as the raw JSON string held in the
|
||||
// message row, while a live send hands over an array — normalise both.
|
||||
const files = useMemo(() => {
|
||||
const raw = data.files
|
||||
if (Array.isArray(raw)) return raw
|
||||
if (typeof raw === 'string' && raw) {
|
||||
try {
|
||||
const parsed = JSON.parse(raw)
|
||||
return Array.isArray(parsed) ? parsed : []
|
||||
} catch {
|
||||
return []
|
||||
}
|
||||
}
|
||||
return []
|
||||
}, [data.files])
|
||||
const files = useMemo(() => (Array.isArray(data.files) ? data.files : []), [data.files])
|
||||
|
||||
const msg = useMemo(() => {
|
||||
const res = typeof data.message === 'string' ? data.message : data.message[data.chatKey]
|
||||
|
||||
Reference in New Issue
Block a user