Skip to content

Commit 46f11ba

Browse files
authored
Merge pull request #160 from iceljc/features/refine-chat-window
fix option payload
2 parents 2bd15e5 + 35fa381 commit 46f11ba

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

src/routes/chat/[agentId]/[conversationId]/rich-content/rc-complex-options.svelte

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
function collectOptions(options) {
2929
cards = options?.filter(op => !!op.title || !!op.subtitle)?.map(op => {
3030
// @ts-ignore
31-
const options = op.buttons?.filter(x => !!x.title && !!x.payload)?.map(x => {
31+
const options = op.buttons?.filter(x => !!x.title)?.map(x => {
3232
return {
3333
title: x.title,
3434
payload: x.payload,
@@ -46,7 +46,7 @@
4646
4747
buttons = options?.filter(op => !!!op.title && !!!op.subtitle)?.flatMap(op => {
4848
// @ts-ignore
49-
return op.buttons?.filter(x => !!x.title && !!x.payload)?.map(x => {
49+
return op.buttons?.filter(x => !!x.title)?.map(x => {
5050
return {
5151
title: x.title,
5252
payload: x.payload,

src/routes/chat/[agentId]/[conversationId]/rich-content/rc-plain-options.svelte

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
4848
/** @param {any[]} options */
4949
function collectOptions(options) {
50-
const innerOptions = options?.filter(op => !!op.title && !!op.payload) || [];
50+
const innerOptions = options?.filter(op => !!op.title) || [];
5151
5252
videoOptions = innerOptions?.filter(op => op.type == ElementType.Video);
5353
fileOption = innerOptions?.find(op => op.type == ElementType.File);
@@ -78,7 +78,9 @@
7878
op.isClicked = !op.isClicked;
7979
if (op.isClicked) {
8080
titleAnswers = [...titleAnswers, op.title];
81-
payloadAnswers = [...payloadAnswers, op.payload];
81+
if (!!op.payload) {
82+
payloadAnswers = [...payloadAnswers, op.payload];
83+
}
8284
} else {
8385
const targetIdx = titleAnswers.findIndex(a => a == op.title);
8486
titleAnswers = titleAnswers.filter((x, index) => index != targetIdx);

0 commit comments

Comments
 (0)