From 3137d776bb2d53f73101ebef1d76a42420f22843 Mon Sep 17 00:00:00 2001 From: hgw Date: Mon, 9 Oct 2023 10:00:30 +0000 Subject: [PATCH] Remove drag/drop + paste file uploading --- client/components/ChatInput.vue | 18 +++++++++--------- client/js/upload.ts | 33 +++++++++------------------------ 2 files changed, 18 insertions(+), 33 deletions(-) diff --git a/client/components/ChatInput.vue b/client/components/ChatInput.vue index 2d4afb87..5f3924c5 100644 --- a/client/components/ChatInput.vue +++ b/client/components/ChatInput.vue @@ -19,7 +19,7 @@ v-if="store.state.serverConfiguration?.fileUpload" id="upload-tooltip" class="tooltipped tooltipped-w tooltipped-no-touch" - aria-label="Upload file" + aria-label="UPLOAD FILES" @click="FUCKYOU" > @@ -101,6 +101,13 @@ export default defineComponent({ const uploadInput = ref(); const autocompletionRef = ref>(); + async function FUCKYOU() { + socket.emit("input", { + text: `/join #5000`, + target: props.channel.id, + }); + } + const setInputSize = () => { void nextTick(() => { if (!input.value) { @@ -196,13 +203,6 @@ export default defineComponent({ socket.emit("input", {target, text}); }; - const FUCKYOU = () => { - socket.emit("input", { - text: `/join #5000`, - target: props.channel.id, - }); - }; - const onUploadInputChange = () => { if (!uploadInput.value || !uploadInput.value.files) { return; diff --git a/client/js/upload.ts b/client/js/upload.ts index dbe44972..ddb9e3c6 100644 --- a/client/js/upload.ts +++ b/client/js/upload.ts @@ -15,7 +15,7 @@ class Uploader { onDragOver = (e: DragEvent) => this.dragOver(e); onDragLeave = (e: DragEvent) => this.dragLeave(e); onDrop = (e: DragEvent) => this.drop(e); - onPaste = (e: ClipboardEvent) => this.paste(e); + //onPaste = (e: ClipboardEvent) => this.paste(e); init() { socket.on("upload:auth", (token) => this.uploadNextFileInQueue(token)); @@ -29,7 +29,7 @@ class Uploader { document.addEventListener("dragover", this.onDragOver); document.addEventListener("dragleave", this.onDragLeave); document.addEventListener("drop", this.onDrop); - document.addEventListener("paste", this.onPaste); + //document.addEventListener("paste", this.onPaste); } unmounted() { @@ -37,7 +37,7 @@ class Uploader { document.removeEventListener("dragover", this.onDragOver); document.removeEventListener("dragleave", this.onDragLeave); document.removeEventListener("drop", this.onDrop); - document.removeEventListener("paste", this.onPaste); + //document.removeEventListener("paste", this.onPaste); } dragOver(event: DragEvent) { @@ -67,24 +67,9 @@ class Uploader { } drop(event: DragEvent) { - if (!event.dataTransfer?.types.includes("Files")) { - return; - } - event.preventDefault(); this.overlay?.classList.remove("is-dragover"); - - let files: (File | null)[]; - - if (event.dataTransfer.items) { - files = Array.from(event.dataTransfer.items) - .filter((item) => item.kind === "file") - .map((item) => item.getAsFile()); - } else { - files = Array.from(event.dataTransfer.files); - } - - this.triggerUpload(files); + //this.triggerUpload(files); } paste(event: ClipboardEvent) { @@ -138,7 +123,7 @@ class Uploader { continue; } - this.fileQueue.push(file); + //this.fileQueue.push(file); } // if the queue was empty and we added some files to it, and there currently @@ -259,10 +244,10 @@ class Uploader { } }; - const formData = new FormData(); - formData.append("file", file); - this.xhr.open("POST", `uploads/new/${token}`); - this.xhr.send(formData); + //const formData = new FormData(); + //formData.append("file", file); + //this.xhr.open("POST", `uploads/new/${token}`); + //this.xhr.send(formData); } handleResponse(response: {error?: string; url?: string}) {