diff --git a/src/lib/components/chat/MessageInput.svelte b/src/lib/components/chat/MessageInput.svelte index 89d7c0c09..84bdd6b20 100644 --- a/src/lib/components/chat/MessageInput.svelte +++ b/src/lib/components/chat/MessageInput.svelte @@ -236,11 +236,7 @@ dragged = false; }; - let dropzoneElement; - onMount(async () => { - console.log('hi'); - if (!$tools) { await tools.set(await getTools(localStorage.token)); } @@ -254,17 +250,21 @@ window.addEventListener('keydown', handleKeyDown); - if (dropzoneElement) { - dropzoneElement?.addEventListener('dragover', onDragOver); - dropzoneElement?.addEventListener('drop', onDrop); - dropzoneElement?.addEventListener('dragleave', onDragLeave); - } + await tick(); + + const dropzoneElement = document.getElementById('chat-container'); + + dropzoneElement?.addEventListener('dragover', onDragOver); + dropzoneElement?.addEventListener('drop', onDrop); + dropzoneElement?.addEventListener('dragleave', onDragLeave); }); onDestroy(() => { console.log('destroy'); window.removeEventListener('keydown', handleKeyDown); + const dropzoneElement = document.getElementById('chat-container'); + if (dropzoneElement) { dropzoneElement?.removeEventListener('dragover', onDragOver); dropzoneElement?.removeEventListener('drop', onDrop); @@ -273,10 +273,6 @@ }); -