fix: 迁移的消息解析错误

dev/timezone
Lei OT 1 year ago
parent 9da9854564
commit 209a79bbcf

@ -169,7 +169,7 @@ export function merge(...objects) {
* - 相当于 lodash _.groupBy
* @see https://www.lodashjs.com/docs/lodash.groupBy#_groupbycollection-iteratee_identity
*/
export function groupBy(array, callback) {
export function groupBy(array = [], callback) {
return array.reduce((groups, item) => {
const key = typeof callback === 'function' ? callback(item) : item[callback];

@ -4,7 +4,7 @@ import { LoadingOutlined } from '@ant-design/icons';
import { MessageBox } from 'react-chat-elements';
import { MESSAGE_PAGE_SIZE, fetchMessagesHistory } from '@/actions/ConversationActions';
import useFormStore from '@/stores/FormStore';
import { isEmpty, stringToColour, groupBy } from '@/utils/commons';
import { isEmpty, stringToColour, groupBy, isNotEmpty } from '@/utils/commons';
import { useShallow } from 'zustand/react/shallow';
const BIG_PAGE_SIZE = MESSAGE_PAGE_SIZE * 100;
@ -134,7 +134,7 @@ const MessagesList = ({ ...props }) => {
const RenderText = memo(function renderText({ str, className, template }) {
let headerObj, footerObj, buttonsArr;
if (!isEmpty(template)) {
if (!isEmpty(template) && !isEmpty(template.components)) {
const componentsObj = groupBy(template.components, (item) => item.type);
headerObj = componentsObj?.header?.[0];
footerObj = componentsObj?.footer?.[0];

@ -43,7 +43,7 @@ const MessagesList = ({ messages, handlePreview, reference, longListLoading, get
const RenderText = memo(function renderText({ str, className, template }) {
let headerObj, footerObj, buttonsArr;
if (!isEmpty(template)) {
if (!isEmpty(template) && !isEmpty(template.components)) {
const componentsObj = groupBy(template.components, (item) => item.type);
headerObj = componentsObj?.header?.[0];
footerObj = componentsObj?.footer?.[0];

Loading…
Cancel
Save