-
file: {{ currentImageInputPath.name }}
-
({{ formatBytes(currentImageInputPath.size) }})
+
+
+ {{ $t('message.file') }}: {{ currentImageInputPath.name }}
+ ({{ formatBytes(currentImageInputPath.size) }})
+
-
- {{ currentSendError }}
- {{ currentSendProgress }}
-
-
- {{
- $t("menu.cancel")
- }}
+
+ {{ currentSendError }}
+ {{ currentSendProgress }}
+
+
+ {{ $t("menu.cancel") }}
+
{{ $t("menu.send") }}
@@ -355,7 +360,7 @@ export default {
scrollPosition: null,
currentImageInputs: null,
- currentImageInputsPath: null,
+ currentFileInputs: null,
currentSendOperation: null,
currentSendProgress: null,
currentSendShowSendButton: true,
@@ -439,15 +444,18 @@ export default {
},
computed: {
- isCurrentImageInputsPath() {
- return Array.isArray(this.currentImageInputsPath)
+ nonImageFiles() {
+ return this.isCurrentFileInputsAnArray && this.currentFileInputs.filter(file => !file.type.includes("image/"))
},
- isCurrentImageInputsPathDialog: {
+ isCurrentFileInputsAnArray() {
+ return Array.isArray(this.currentFileInputs)
+ },
+ currentFileInputsDialog: {
get() {
- return this.isCurrentImageInputsPath
+ return this.isCurrentFileInputsAnArray
},
set() {
- this.currentImageInputsPath = null
+ this.currentFileInputs = null
}
},
chatContainer() {
@@ -1003,15 +1011,12 @@ export default {
if (file) {
var reader = new FileReader();
reader.onload = (e) => {
- const file = event.target.files[0];
if (file.type.startsWith("image/")) {
const currentImageInput = this.optimizeImage(e, event, file)
this.currentImageInputs = Array.isArray(this.currentImageInputs) ? [...this.currentImageInputs, currentImageInput] : [currentImageInput]
}
- this.currentImageInputsPath = Array.isArray(this.currentImageInputsPath) ? [...this.currentImageInputsPath, file] : [file];
- console.log(this.currentImageInput);
this.$matrix.matrixClient.getMediaConfig().then((config) => {
- this.currentImageInputPath = file;
+ this.currentFileInputs = Array.isArray(this.currentFileInputs) ? [...this.currentFileInputs, file] : [file];
if (config["m.upload.size"] && file.size > config["m.upload.size"]) {
this.currentSendError = this.$t("message.upload_file_too_large");
this.currentSendShowSendButton = false;
@@ -1046,43 +1051,35 @@ export default {
});
}
},
- sendImage(withText, inputFile) {
- this.currentSendProgress = null;
- this.currentSendOperation = util.sendImage(
- this.$matrix.matrixClient,
- this.roomId,
- inputFile,
- this.onUploadProgress
- );
- this.currentSendOperation
- .then(() => {
- this.currentSendOperation = null;
- this.currentImageInputs = null;
- this.currentImageInputsPath = null;
- this.currentSendProgress = null;
- if (withText) {
- this.sendMessage(withText);
- }
- })
- .catch((err) => {
- if (err.name === "AbortError" || err === "Abort") {
- this.currentSendError = null;
- } else {
- this.currentSendError = err.LocaleString();
- }
- this.currentSendOperation = null;
- this.currentSendProgress = null;
- });
- },
sendAttachment(withText) {
this.$refs.attachment.value = null;
- if (this.isCurrentImageInputsPath) {
- let inputFiles = this.currentImageInputsPath;
+ if (this.isCurrentFileInputsAnArray) {
+ let inputFiles = this.currentFileInputs;
if (Array.isArray(this.currentImageInputs) && this.currentImageInputs.scaled && this.currentImageInputs.useScaled) {
// Send scaled version of image instead!
inputFiles = this.currentImageInputs.map(({scaled}) => scaled)
}
- inputFiles.forEach((inputFile) => this.sendImage(withText, inputFile))
+
+ const promises = inputFiles.map(inputFile => util.sendImage(this.$matrix.matrixClient, this.roomId, inputFile, this.onUploadProgress));
+
+ Promise.all(promises).then(() => {
+ this.currentSendOperation = null;
+ this.currentImageInputs = null;
+ this.currentFileInputs = null;
+ this.currentSendProgress = null;
+ if (withText) {
+ this.sendMessage(withText);
+ }
+ })
+ .catch((err) => {
+ if (err.name === "AbortError" || err === "Abort") {
+ this.currentSendError = null;
+ } else {
+ this.currentSendError = err.LocaleString();
+ }
+ this.currentSendOperation = null;
+ this.currentSendProgress = null;
+ });
}
},
@@ -1093,7 +1090,7 @@ export default {
}
this.currentSendOperation = null;
this.currentImageInputs = null;
- this.currentImageInputsPath = null;
+ this.currentFileInputs = null;
this.currentSendProgress = null;
this.currentSendError = null;
},
@@ -1473,7 +1470,7 @@ export default {
onVoiceRecording(event) {
this.currentSendShowSendButton = false;
- this.currentImageInputsPath = Array.isArray(this.currentImageInputsPath) ? [...this.currentImageInputsPath, event.file] : [event.file];
+ this.currentFileInputs = Array.isArray(this.currentFileInputs) ? [...this.currentFileInputs, event.file] : [event.file];
var text = undefined;
if (this.currentInput && this.currentInput.length > 0) {
text = this.currentInput;