Support cancel for sending operation.

This commit is contained in:
N-Pex 2023-01-09 21:12:17 +01:00 committed by n8fr8
parent 19f0c1c5a3
commit dc0f2d3504
2 changed files with 90 additions and 57 deletions

View file

@ -375,7 +375,7 @@
<script>
import Vue from "vue";
import { TimelineWindow, EventTimeline } from "matrix-js-sdk";
import { TimelineWindow, EventTimeline, AbortError } from "matrix-js-sdk";
import util from "../plugins/utils";
import MessageOperations from "./messages/MessageOperations.vue";
import AvatarOperations from "./messages/AvatarOperations.vue";
@ -1078,7 +1078,11 @@ export default {
}
})
.catch((err) => {
this.currentSendError = err.toLocaleString();
if (err instanceof AbortError || err === "Abort") {
this.currentSendError = null;
} else {
this.currentSendError = err.LocaleString();
}
this.currentSendOperation = null;
this.currentSendProgress = null;
});
@ -1088,7 +1092,7 @@ export default {
cancelSendAttachment() {
this.$refs.attachment.value = null;
if (this.currentSendOperation) {
this.currentSendOperation.reject("Canceled");
this.currentSendOperation.abort();
}
this.currentSendOperation = null;
this.currentImageInput = null;