|
69 | 69 | /** @type {{ [s: string]: any; }} */ |
70 | 70 | let groupedDialogs = []; |
71 | 71 | |
72 | | - /** @type {import('$types').ContentLogModel[]} */ |
| 72 | + /** @type {import('$types').ConversationContentLogModel[]} */ |
73 | 73 | let contentLogs = []; |
74 | 74 |
|
75 | 75 | /** @type {import('$types').ConversationStateLogModel[]} */ |
|
79 | 79 | let isLoadContentLog = false; |
80 | 80 | let isLoadStateLog = false; |
81 | 81 | let isOpenEditMsgModal = false; |
82 | | - let isOpenStateModal = false; |
| 82 | + let isOpenAddStateModal = false; |
83 | 83 | let isSendingMsg = false; |
84 | 84 | |
85 | 85 | onMount(async () => { |
|
137 | 137 | refresh(); |
138 | 138 | } |
139 | 139 |
|
140 | | - /** @param {import('$types').ContentLogModel} log */ |
| 140 | + /** @param {import('$types').ConversationContentLogModel} log */ |
141 | 141 | function onContentLogGenerated(log) { |
142 | | - contentLogs.push({ |
143 | | - ...log, |
144 | | - is_collapsed: true |
145 | | - }); |
| 142 | + if (!isLoadContentLog) return; |
| 143 | + contentLogs.push({ ...log }); |
146 | 144 | contentLogs = contentLogs.map(x => { return { ...x }; }); |
147 | 145 | } |
148 | 146 |
|
149 | 147 | /** @param {import('$types').ConversationStateLogModel} data */ |
150 | 148 | function onConversationStatesGenerated(data) { |
| 149 | + if (!isLoadStateLog) return; |
151 | 150 | stateLogs.push({ ...data }); |
152 | 151 | stateLogs = stateLogs.map(x => { return { ...x }; }); |
153 | 152 | } |
|
248 | 247 | return; |
249 | 248 | } |
250 | 249 |
|
| 250 | + if (e.key === 'Enter') { |
| 251 | + e.preventDefault(); |
| 252 | + } |
| 253 | +
|
251 | 254 | prevSentMsgs = [...prevSentMsgs, text]; |
252 | 255 | isSendingMsg = true; |
253 | 256 | sendMessageToHub(params.agentId, params.conversationId, text).then(() => { |
|
281 | 284 |
|
282 | 285 | function toggleContentLog() { |
283 | 286 | isLoadContentLog = !isLoadContentLog; |
| 287 | + if (!isLoadContentLog) { |
| 288 | + contentLogs = []; |
| 289 | + } |
284 | 290 | } |
285 | 291 |
|
286 | 292 | function toggleStateLog() { |
287 | 293 | isLoadStateLog = !isLoadStateLog; |
| 294 | + if (!isLoadStateLog) { |
| 295 | + stateLogs = []; |
| 296 | + } |
288 | 297 | } |
289 | 298 |
|
290 | | - function toggleStateModal() { |
291 | | - isOpenStateModal = !isOpenStateModal; |
| 299 | + function toggleAddStateModal() { |
| 300 | + isOpenAddStateModal = !isOpenAddStateModal; |
292 | 301 | } |
293 | 302 |
|
294 | 303 | function clearStates() { |
|
404 | 413 |
|
405 | 414 | <StateModal |
406 | 415 | className="custom-modal" |
407 | | - isOpen={isOpenStateModal} |
408 | | - toggleModal={toggleStateModal} |
409 | | - confirm={toggleStateModal} |
410 | | - cancel={toggleStateModal} |
| 416 | + isOpen={isOpenAddStateModal} |
| 417 | + toggleModal={toggleAddStateModal} |
| 418 | + confirm={toggleAddStateModal} |
| 419 | + cancel={toggleAddStateModal} |
411 | 420 | /> |
412 | 421 |
|
413 | 422 | <HeadTitle title="Chat" addOn='' /> |
|
442 | 451 | {#if !isLoadContentLog} |
443 | 452 | <DropdownItem on:click={() => toggleContentLog()}>View Log</DropdownItem> |
444 | 453 | {/if} |
445 | | - {#if !isLoadStateLog || !isOpenStateModal} |
| 454 | + {#if !isLoadStateLog || !isOpenAddStateModal} |
446 | 455 | <li> |
447 | 456 | <Dropdown direction="right" class="state-menu"> |
448 | 457 | <DropdownToggle caret class="dropdown-item"> |
|
452 | 461 | {#if !isLoadStateLog} |
453 | 462 | <DropdownItem on:click={() => toggleStateLog()}>View States</DropdownItem> |
454 | 463 | {/if} |
455 | | - {#if !isOpenStateModal} |
456 | | - <DropdownItem on:click={() => toggleStateModal()}>Add States</DropdownItem> |
| 464 | + {#if !isOpenAddStateModal} |
| 465 | + <DropdownItem on:click={() => toggleAddStateModal()}>Add States</DropdownItem> |
457 | 466 | {/if} |
458 | 467 | <DropdownItem on:click={() => clearStates()}>Clear States</DropdownItem> |
459 | 468 | </DropdownMenu> |
|
508 | 517 | {:else} |
509 | 518 | <img src={PUBLIC_LIVECHAT_ENTRY_ICON} class="rounded-circle avatar-xs" alt="avatar"> |
510 | 519 | {/if} |
511 | | - </div> |
| 520 | + </div> |
512 | 521 | {/if} |
513 | 522 |
|
514 | 523 | {#if message.sender.id === currentUser.id} |
|
564 | 573 | </div> |
565 | 574 | <div class="col"> |
566 | 575 | <div class="position-relative"> |
567 | | - <textarea rows={1} maxlength={500} class="form-control chat-input" bind:value={text} on:keydown={e => onSendMessage(e)} placeholder="Enter Message..." /> |
| 576 | + <textarea rows={1} maxlength={500} class="form-control chat-input" bind:value={text} on:keydown={e => onSendMessage(e)} disabled={isSendingMsg} placeholder="Enter Message..." /> |
568 | 577 | <div class="chat-input-links" id="tooltip-container"> |
569 | 578 | <ul class="list-inline mb-0"> |
570 | 579 | <li class="list-inline-item"> |
|
591 | 600 | </Pane> |
592 | 601 | {#if isLoadContentLog} |
593 | 602 | <Pane size={30} minSize={20} maxSize={50}> |
594 | | - <ContentLog logs={contentLogs} closeWindow={toggleContentLog} /> |
| 603 | + <ContentLog contentLogs={contentLogs} closeWindow={toggleContentLog} /> |
595 | 604 | </Pane> |
596 | 605 | {/if} |
597 | 606 | </Splitpanes> |
|
0 commit comments