Skip to content

Commit bf19a53

Browse files
authored
Merge pull request #116 from iceljc/features/refine-chat-window
refine chat attachment option
2 parents dc4ebc6 + 5db3a12 commit bf19a53

File tree

1 file changed

+19
-7
lines changed

1 file changed

+19
-7
lines changed

src/routes/chat/[agentId]/[conversationId]/chatImage/chat-attachment.svelte

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,22 @@
3030
3131
/** @param {any[]} options */
3232
function collectOptions(options) {
33-
cancelOption = options?.find(op => op.title?.toLowerCase() === 'no');
34-
confirmOption = {
35-
title: 'Yes, I have uploaded attachments.',
36-
payload: 'I have uploaded attachments.'
37-
};
33+
confirmOption = options?.find(op => op.title?.toLowerCase()?.startsWith("yes"));
34+
cancelOption = options?.find(op => op.title?.toLowerCase()?.startsWith("no"));
35+
36+
if (!confirmOption) {
37+
confirmOption = {
38+
title: 'Yes, I have uploaded attachments.',
39+
payload: 'I have uploaded attachments.'
40+
};
41+
}
42+
43+
if (!cancelOption) {
44+
cancelOption = {
45+
title: 'No, I do not have attachments to upload.',
46+
payload: 'No, I do not have attachments to upload.'
47+
};
48+
}
3849
}
3950
4051
/**
@@ -82,15 +93,16 @@
8293
</div>
8394
8495
<div class="plain-option-container">
85-
{#if files?.length > 0}
96+
{#if files?.length > 0 && confirmOption}
8697
<button
8798
class={`btn btn-sm m-1 ${confirmOption?.is_secondary ? 'btn-outline-secondary': 'btn-outline-primary'}`}
8899
disabled={disabled}
89100
on:click={(e) => handleClickOption(e, confirmOption)}
90101
>
91102
{confirmOption?.title}
92103
</button>
93-
{:else}
104+
{/if}
105+
{#if files?.length <= 0 && cancelOption}
94106
<button
95107
class={`btn btn-sm m-1 ${cancelOption?.is_secondary ? 'btn-outline-secondary': 'btn-outline-primary'}`}
96108
disabled={disabled}

0 commit comments

Comments
 (0)