Skip to content

Commit 1a7368d

Browse files
committed
refine chat flow
1 parent ee4928b commit 1a7368d

File tree

2 files changed

+12
-27
lines changed

2 files changed

+12
-27
lines changed

src/lib/common/LiveChatEntry.svelte

Lines changed: 9 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -29,30 +29,19 @@
2929
</script>
3030

3131
<div class="fixed-bottom float-bottom-right">
32-
{#if $chatBotStore.showChatBox}
33-
<div transition:fade={{ delay: 250, duration: 300 }}>
34-
<iframe
35-
src={chatUrl}
36-
width="380px"
37-
height="650px"
38-
class={`border border-2 rounded-3 m-3 float-end chat-iframe`}
39-
title="live chat"
40-
id={CHAT_FRAME_ID}
41-
/>
42-
</div>
43-
{/if}
32+
<iframe
33+
src={chatUrl}
34+
width={`${$chatBotStore.showChatBox ? '380px' : '0px'}`}
35+
height={`${$chatBotStore.showChatBox ? '650px' : '0px'}`}
36+
class={`border border-2 rounded-3 m-3 float-end ${$chatBotStore.showChatBox ? 'chat-iframe' : ''}`}
37+
title="live chat"
38+
id={CHAT_FRAME_ID}
39+
/>
4440

4541
{#if !$chatBotStore.showChatBox}
46-
<div class="mb-3 float-end wave-effect" transition:fade={{ delay: 100, duration: 500 }}>
42+
<div class="mb-3 float-end wave-effect" transition:fade={{ delay: 50, duration: 200 }}>
4743
<button class="btn btn-transparent" on:click={() => openChatBox()}>
4844
<img alt="live chat" class="avatar-md rounded-circle" src={PUBLIC_LIVECHAT_ENTRY_ICON} />
49-
<iframe
50-
src={chatUrl}
51-
width="0px"
52-
height="0px"
53-
title="live chat"
54-
id={CHAT_FRAME_ID}
55-
/>
5645
</button>
5746
</div>
5847
{/if}

src/routes/chat/[agentId]/[conversationId]/chat-box.svelte

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -221,13 +221,12 @@
221221
isCreatingNewConv = false;
222222
if (conv && !!e.data.text) {
223223
isLoading = true;
224+
openFrame();
224225
sendChatMessage(e.data.text, e.data.data || null, conv.id).then(() => {
225226
isLoading = false;
226-
openFrame();
227227
redirectToNewConversation(conv);
228228
}).catch(() => {
229229
isLoading = false;
230-
openFrame();
231230
});
232231
} else {
233232
openFrame();
@@ -241,11 +240,8 @@
241240
/** @param {any} e */
242241
function handleChatAction(e) {
243242
if (!!e.data.text && !isThinking && !isSendingMsg) {
244-
sendChatMessage(e.data.text, e.data.data || null).then(() => {
245-
openFrame();
246-
}).catch(() => {
247-
openFrame();
248-
});
243+
openFrame();
244+
sendChatMessage(e.data.text, e.data.data || null);
249245
}
250246
}
251247

0 commit comments

Comments
 (0)