mirror of
https://github.com/thelounge/thelounge.git
synced 2024-06-02 13:52:17 +02:00
Add confirm dialog for uploading long lines as a file
This commit is contained in:
parent
b6819b6dfc
commit
2b0beac1d9
|
@ -267,22 +267,7 @@ export default {
|
|||
this.setInputSize();
|
||||
};
|
||||
|
||||
if (this.$store.state.serverConfiguration.fileUpload) {
|
||||
const lines = 1 + (text.match(/\n/g) || "").length;
|
||||
|
||||
// TODO: Offer a confirmation to user whether they want to upload
|
||||
if (lines > 3 || text.length > 700) {
|
||||
resetInput();
|
||||
|
||||
const file = new File([text], "paste.txt", {
|
||||
type: "text/plain",
|
||||
});
|
||||
upload.triggerUpload([file]);
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
const sendMessage = () => {
|
||||
resetInput();
|
||||
|
||||
// Store new message in history if last message isn't already equal
|
||||
|
@ -308,6 +293,39 @@ export default {
|
|||
}
|
||||
|
||||
socket.emit("input", {target, text});
|
||||
};
|
||||
|
||||
if (this.$store.state.serverConfiguration.fileUpload) {
|
||||
const lines = 1 + (text.match(/\n/g) || "").length;
|
||||
|
||||
if (lines > 3 || text.length > 700) {
|
||||
eventbus.emit(
|
||||
"confirm-dialog",
|
||||
{
|
||||
title: "Upload as file?",
|
||||
text: `You're trying to send a lot of text. Would you like to upload it?`,
|
||||
button: "Upload",
|
||||
},
|
||||
(result) => {
|
||||
if (!result) {
|
||||
sendMessage();
|
||||
return;
|
||||
}
|
||||
|
||||
resetInput();
|
||||
|
||||
const file = new File([text], "paste.txt", {
|
||||
type: "text/plain",
|
||||
});
|
||||
upload.triggerUpload([file]);
|
||||
}
|
||||
);
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
sendMessage();
|
||||
},
|
||||
onUploadInputChange() {
|
||||
const files = Array.from(this.$refs.uploadInput.files);
|
||||
|
|
Loading…
Reference in a new issue