Skip to content

Commit

Permalink
Resolve issues related to response status messages
Browse files Browse the repository at this point in the history
  • Loading branch information
annmirosh committed Nov 29, 2024
1 parent 6b8bd3a commit be1e9ec
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 18 deletions.
34 changes: 18 additions & 16 deletions dist/alan_lib.js
Original file line number Diff line number Diff line change
Expand Up @@ -89698,7 +89698,7 @@
messages[msgInd] = {
...msg,
queryProgress: [
...messages[msgInd].queryProgress || [],
...messages[msgInd]?.queryProgress || [],
...msg.queryProgress
]
};
Expand Down Expand Up @@ -93926,7 +93926,7 @@ code.hljs {

// alan_btn/alan_btn.ts
(function(ns) {
uiState.lib.version = "alan-version.1.8.71".replace("alan-version.", "");
uiState.lib.version = "alan-version.1.8.72".replace("alan-version.", "");
if (window.alanBtn) {
console.warn("Alan: the Alan Button source code has already added (v." + uiState.lib.version + ")");
}
Expand Down Expand Up @@ -96168,6 +96168,7 @@ ${LEARN_MORE_LABEL}
let innerMsgPart = "";
let msgHtml = "";
const msgHolder = document.getElementById("chatMessages");
const msgsScrollableContainer = document.getElementById("chatMessagesWrapper");
if (msg.type === "response" && msg.name === "text") {
if (window.fakeMsg) {
msg.text = window.fakeMsg?.text || msg.text;
Expand Down Expand Up @@ -96239,9 +96240,9 @@ ${LEARN_MORE_LABEL}
unreadChatMsgCount++;
}
if (immidiateScroll !== true) {
scrollTextChat(msgHolder, "smooth");
scrollTextChat(msgsScrollableContainer, "smooth");
} else {
scrollTextChat(msgHolder);
scrollTextChat(msgsScrollableContainer);
}
if (msg.ctx?.final !== false) {
processFormulas(getMsgElForMathJax(msgInd));
Expand Down Expand Up @@ -96269,7 +96270,7 @@ ${LEARN_MORE_LABEL}
if (msg.type === "response" && isMsgContainsIFrame(innerEl?.innerHTML)) {
innerEl.classList.add("with-table");
}
scrollTextChat(msgHolder, "smooth");
scrollTextChat(msgsScrollableContainer, "smooth");
}
} else if (updateResponse && msg.type !== "chat") {
let innerEl = msgEl.querySelector(".alan-btn__chat-inner-msg");
Expand Down Expand Up @@ -96305,7 +96306,7 @@ ${LEARN_MORE_LABEL}
innerEl.classList.add("with-table");
}
setTimeout(() => {
scrollTextChat(msgHolder, "smooth");
scrollTextChat(msgsScrollableContainer, "smooth");
});
}
} else {
Expand All @@ -96320,6 +96321,9 @@ ${LEARN_MORE_LABEL}
} else {
msgEl.innerHTML = msgHtml;
}
setTimeout(() => {
scrollTextChat(msgsScrollableContainer);
});
}
}
if (msg.ctx?.final !== false) {
Expand All @@ -96344,7 +96348,7 @@ ${LEARN_MORE_LABEL}
}
function updateMessageProgressStatus(msgInd, loaderContentEl) {
return setInterval(() => {
if (loaderContentEl) {
if (loaderContentEl && textChatMessages[msgInd]) {
const index = (0, import_lodash2.findIndex)(textChatMessages[msgInd].queryProgress, { isShown: false });
if (index >= 0) {
textChatMessages[msgInd].queryProgress[index].isShown = true;
Expand All @@ -96353,25 +96357,25 @@ ${LEARN_MORE_LABEL}
}
}, 500);
}
function scrollTextChat(msgHolder, behavior) {
function scrollTextChat(scrollableEl, behavior) {
const scrollOptions = {
top: msgHolder.scrollHeight + 500,
top: scrollableEl.scrollHeight + 500,
left: 0
};
if (textChatScrollPosition !== null)
return;
if (behavior) {
scrollOptions.behavior = "smooth";
}
msgHolder.scroll(scrollOptions);
scrollableEl.scroll(scrollOptions);
}
function onTextChatScroll(e) {
const chatMessagesEl = document.getElementById("chatMessages");
if (chatMessagesEl) {
if (chatMessagesEl.scrollTop + chatMessagesEl.clientHeight >= chatMessagesEl.scrollHeight) {
const el = e.currentTarget;
if (el) {
if (el.scrollTop + el.clientHeight >= el.scrollHeight) {
textChatScrollPosition = null;
} else {
textChatScrollPosition = chatMessagesEl.scrollTop;
textChatScrollPosition = el.scrollTop;
}
}
}
Expand Down Expand Up @@ -96433,7 +96437,6 @@ ${LEARN_MORE_LABEL}
}
tabActive = true;
saveTabId();
console.info("syncChatHistoryBetweenTabs");
restoreMessageList(false);
}
function saveTabId() {
Expand All @@ -96449,7 +96452,6 @@ ${LEARN_MORE_LABEL}
if (isLocalStorageAvailable) {
if (curDialogId) {
savedMsgs = localStorage.getItem(getKeyForSavingTextChatMessages());
console.info("restoreMessageList", savedMsgs, curDialogId, getKeyForSavingTextChatMessages());
try {
if (savedMsgs === JSON.stringify(textChatMessages)) {
return;
Expand Down
2 changes: 1 addition & 1 deletion dist/alan_lib.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@alan-ai/alan-sdk-web",
"version": "1.8.71",
"version": "1.8.72",
"description": "Alan Web SDK: a lightweight JavaScript library for adding a voice experience to your website or web application",
"keywords": [
"alan sdk web",
Expand Down

0 comments on commit be1e9ec

Please sign in to comment.