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;
};
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 @@
});
</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} />
{#if loaded}

View File

@ -89,7 +89,7 @@
});
</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">
{#if $temporaryChatEnabled}
<Tooltip
@ -227,4 +227,4 @@
</div>
</div>
</div>
{/key}
{/if}