fix sending actual file when not scaled

This commit is contained in:
10G Meow 2023-08-07 08:48:34 +03:00
parent da704f84d9
commit 160ca1067c

View file

@ -1113,6 +1113,7 @@ export default {
fileObj.dimensions = null; fileObj.dimensions = null;
fileObj.type = file.type; fileObj.type = file.type;
fileObj.actualSize = file.size; fileObj.actualSize = file.size;
fileObj.actualFile = file
try { try {
fileObj.dimensions = sizeOf(dataUriToBuffer(evt.target.result)); fileObj.dimensions = sizeOf(dataUriToBuffer(evt.target.result));
@ -1218,33 +1219,41 @@ export default {
this.$refs.attachment.value = null; this.$refs.attachment.value = null;
if (this.isCurrentFileInputsAnArray) { if (this.isCurrentFileInputsAnArray) {
let inputFiles = this.currentFileInputs.map(entry => { let inputFiles = this.currentFileInputs.map(entry => {
// other than file type image
if(entry instanceof File) {
return entry;
} else {
if (entry.scaled && entry.useScaled) { if (entry.scaled && entry.useScaled) {
// Send scaled version of image instead! // Send scaled version of image instead!
return entry.scaled; return entry.scaled;
} else {
// Send actual file image when not scaled!
return entry.actualFile;
} }
return entry; }
}) })
const promises = inputFiles.map(inputFile => util.sendImage(this.$matrix.matrixClient, this.roomId, inputFile, this.onUploadProgress));
Promise.all(promises).then(() => { const promises = inputFiles.map(inputFile => util.sendImage(this.$matrix.matrixClient, this.roomId, inputFile, this.onUploadProgress));
this.currentSendOperation = null;
this.currentFileInputs = null; Promise.all(promises).then(() => {
this.currentSendProgress = null; this.currentSendOperation = null;
if (withText) { this.currentFileInputs = null;
this.sendMessage(withText); this.currentSendProgress = null;
} if (withText) {
}) this.sendMessage(withText);
.catch((err) => { }
if (err.name === "AbortError" || err === "Abort") { })
this.currentSendError = null; .catch((err) => {
this.currentSendErrorExceededFile = null; if (err.name === "AbortError" || err === "Abort") {
} else { this.currentSendError = null;
this.currentSendError = err.LocaleString(); this.currentSendErrorExceededFile = null;
this.currentSendErrorExceededFile = err.LocaleString(); } else {
} this.currentSendError = err.LocaleString();
this.currentSendOperation = null; this.currentSendErrorExceededFile = err.LocaleString();
this.currentSendProgress = null; }
}); this.currentSendOperation = null;
this.currentSendProgress = null;
});
} }
}, },