From e06667ead8f183440131ecdd6ddee0572d98a60b Mon Sep 17 00:00:00 2001 From: "Timothy J. Baek" Date: Mon, 23 Sep 2024 23:39:33 +0200 Subject: [PATCH] refac --- src/lib/components/chat/ChatControls.svelte | 1 - src/lib/components/chat/Messages/CodeBlock.svelte | 15 ++++++++++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/lib/components/chat/ChatControls.svelte b/src/lib/components/chat/ChatControls.svelte index 45c66f3e0..9cc44ce38 100644 --- a/src/lib/components/chat/ChatControls.svelte +++ b/src/lib/components/chat/ChatControls.svelte @@ -128,7 +128,6 @@ : 30 : 0} onResize={(size) => { - console.log(size); if (size === 0) { showControls.set(false); } else { diff --git a/src/lib/components/chat/Messages/CodeBlock.svelte b/src/lib/components/chat/Messages/CodeBlock.svelte index dbe49c232..15aea5e35 100644 --- a/src/lib/components/chat/Messages/CodeBlock.svelte +++ b/src/lib/components/chat/Messages/CodeBlock.svelte @@ -20,6 +20,8 @@ export let lang = ''; export let code = ''; + let _token = null; + let mermaidHtml = null; let highlightedCode = null; @@ -226,7 +228,7 @@ __builtins__.input = input`); } }; - $: if (token) { + const render = async () => { if (lang === 'mermaid' && (token?.raw ?? '').slice(-4).includes('```')) { (async () => { await drawMermaidDiagram(); @@ -242,6 +244,17 @@ __builtins__.input = input`); // Set a new timeout to debounce the code highlighting debounceTimeout = setTimeout(highlightCode, 10); } + }; + + $: if (token) { + if (JSON.stringify(token) !== JSON.stringify(_token)) { + console.log('hi'); + _token = token; + } + } + + $: if (_token) { + render(); } onMount(async () => {