Skip to content

Commit

Permalink
rm dev consoles
Browse files Browse the repository at this point in the history
  • Loading branch information
mishig25 committed Sep 28, 2024
1 parent fb52674 commit 1e8f976
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions src/routes/api/assistant/[id]/embed-snippet/+server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ export async function GET({ params }) {
const chatContainerEl = iframe.contentWindow.document.getElementById('chat-container');
if(chatContainerEl){
const contentHeight = chatContainerEl.scrollHeight;
console.log('Resizing iframe. Content height:', contentHeight);
iframe.style.height = Math.max(400, Math.min(contentHeight, maxHeight)) + "px";
}
}
Expand Down Expand Up @@ -44,7 +43,6 @@ export async function GET({ params }) {
iframe.src = \`http://localhost:5173/chat/?embeddedAssistantId=${id}\`;
iframe.onload = function() {
console.log('Iframe loaded');
const iframeWindow = this.contentWindow;
const iframeDocument = iframeWindow.document;
Expand All @@ -55,7 +53,6 @@ export async function GET({ params }) {
if (chatContainer) {
const newHeight = chatContainer.scrollHeight;
if (newHeight !== lastHeight) {
console.log('Height changed from', lastHeight, 'to', newHeight);
resizeIframeToContentSize(iframe);
lastHeight = newHeight;
}
Expand All @@ -68,17 +65,16 @@ export async function GET({ params }) {
// Set up MutationObserver as a backup
const observer = new MutationObserver(() => {
console.log('Mutation detected');
resizeIframeToContentSize(iframe);
});
function initMutationObserver() {
const chatContainer = iframeDocument.getElementById('chat-container');
if (chatContainer) {
console.log('Chat container found, setting up MutationObserver');
console.error('Chat container found, setting up MutationObserver');
observer.observe(chatContainer, { childList: true, subtree: true, attributes: true, characterData: true });
} else {
console.log('Chat container not found, retrying...');
console.error('Chat container not found, retrying...');
setTimeout(initMutationObserver, 500); // Retry after 500ms
}
}
Expand Down

0 comments on commit 1e8f976

Please sign in to comment.