fix: file drop

This commit is contained in:
Timothy Jaeryang Baek 2024-11-17 22:06:58 -08:00
parent 0faa39ace9
commit ecf21de28f
2 changed files with 11 additions and 15 deletions

View File

@ -236,11 +236,7 @@
dragged = false; dragged = false;
}; };
let dropzoneElement;
onMount(async () => { onMount(async () => {
console.log('hi');
if (!$tools) { if (!$tools) {
await tools.set(await getTools(localStorage.token)); await tools.set(await getTools(localStorage.token));
} }
@ -254,17 +250,21 @@
window.addEventListener('keydown', handleKeyDown); window.addEventListener('keydown', handleKeyDown);
if (dropzoneElement) { await tick();
dropzoneElement?.addEventListener('dragover', onDragOver);
dropzoneElement?.addEventListener('drop', onDrop); const dropzoneElement = document.getElementById('chat-container');
dropzoneElement?.addEventListener('dragleave', onDragLeave);
} dropzoneElement?.addEventListener('dragover', onDragOver);
dropzoneElement?.addEventListener('drop', onDrop);
dropzoneElement?.addEventListener('dragleave', onDragLeave);
}); });
onDestroy(() => { onDestroy(() => {
console.log('destroy'); console.log('destroy');
window.removeEventListener('keydown', handleKeyDown); window.removeEventListener('keydown', handleKeyDown);
const dropzoneElement = document.getElementById('chat-container');
if (dropzoneElement) { if (dropzoneElement) {
dropzoneElement?.removeEventListener('dragover', onDragOver); dropzoneElement?.removeEventListener('dragover', onDragOver);
dropzoneElement?.removeEventListener('drop', onDrop); dropzoneElement?.removeEventListener('drop', onDrop);
@ -273,10 +273,6 @@
}); });
</script> </script>
<div
class="absolute top-0 bottom-0 left-0 right-0 w-full h-full touch-none pointer-events-none"
bind:this={dropzoneElement}
></div>
<FilesOverlay show={dragged} /> <FilesOverlay show={dragged} />
{#if loaded} {#if loaded}

View File

@ -89,7 +89,7 @@
}); });
</script> </script>
{#key mounted} {#if mounted}
<div class="m-auto w-full max-w-6xl px-2 xl:px-20 translate-y-6 py-24 text-center"> <div class="m-auto w-full max-w-6xl px-2 xl:px-20 translate-y-6 py-24 text-center">
{#if $temporaryChatEnabled} {#if $temporaryChatEnabled}
<Tooltip <Tooltip
@ -227,4 +227,4 @@
</div> </div>
</div> </div>
</div> </div>
{/key} {/if}