Merge branch '606-cancel-button-doesn-t-wok' into 'dev'
Fix "cancel" when sending attachments See merge request keanuapp/keanuapp-weblite!304
This commit is contained in:
commit
6a00a334b5
1 changed files with 15 additions and 10 deletions
|
|
@ -51,6 +51,7 @@ export default {
|
||||||
id: attachment.name,
|
id: attachment.name,
|
||||||
status: this.sendStatuses.INITIAL,
|
status: this.sendStatuses.INITIAL,
|
||||||
statusDate: Date.now,
|
statusDate: Date.now,
|
||||||
|
mediaEventId: undefined,
|
||||||
attachment: file,
|
attachment: file,
|
||||||
preview: attachment.image,
|
preview: attachment.image,
|
||||||
progress: 0,
|
progress: 0,
|
||||||
|
|
@ -74,6 +75,7 @@ export default {
|
||||||
if (item.status !== this.sendStatuses.INITIAL) {
|
if (item.status !== this.sendStatuses.INITIAL) {
|
||||||
return getItemPromise(++index);
|
return getItemPromise(++index);
|
||||||
}
|
}
|
||||||
|
item.status = this.sendStatuses.SENDING;
|
||||||
const itemPromise = util.sendFile(this.$matrix.matrixClient, this.room.roomId, item.attachment, ({ loaded, total }) => {
|
const itemPromise = util.sendFile(this.$matrix.matrixClient, this.room.roomId, item.attachment, ({ loaded, total }) => {
|
||||||
if (loaded == total) {
|
if (loaded == total) {
|
||||||
item.progress = 100;
|
item.progress = 100;
|
||||||
|
|
@ -81,7 +83,7 @@ export default {
|
||||||
item.progress = 100 * loaded / total;
|
item.progress = 100 * loaded / total;
|
||||||
}
|
}
|
||||||
}, eventId)
|
}, eventId)
|
||||||
.then(() => {
|
.then((mediaEventId) => {
|
||||||
// Look at last item rotation, flipping the sign on this, so looks more like a true stack
|
// Look at last item rotation, flipping the sign on this, so looks more like a true stack
|
||||||
let signR = 1;
|
let signR = 1;
|
||||||
let signX = 1;
|
let signX = 1;
|
||||||
|
|
@ -100,6 +102,7 @@ export default {
|
||||||
item.randomRotation = signR * (2 + Math.random() * 10);
|
item.randomRotation = signR * (2 + Math.random() * 10);
|
||||||
item.randomTranslationX = signX * Math.random() * 20;
|
item.randomTranslationX = signX * Math.random() * 20;
|
||||||
item.randomTranslationY = signY * Math.random() * 20;
|
item.randomTranslationY = signY * Math.random() * 20;
|
||||||
|
item.mediaEventId = mediaEventId;
|
||||||
item.status = this.sendStatuses.SENT;
|
item.status = this.sendStatuses.SENT;
|
||||||
item.statusDate = Date.now;
|
item.statusDate = Date.now;
|
||||||
}).catch(ignorederr => {
|
}).catch(ignorederr => {
|
||||||
|
|
@ -133,15 +136,17 @@ export default {
|
||||||
});
|
});
|
||||||
this.sendingStatus = this.sendStatuses.CANCELED;
|
this.sendingStatus = this.sendStatuses.CANCELED;
|
||||||
if (this.sendingRootEventId && this.room) {
|
if (this.sendingRootEventId && this.room) {
|
||||||
// Redact the root event.
|
|
||||||
this.$matrix.matrixClient
|
// Redact all media we already sent, plus the root event
|
||||||
.redactEvent(this.room.roomId, this.sendingRootEventId, undefined, { reason: "cancel" })
|
let promises = this.sendingAttachments.filter((item) => item.mediaEventId !== undefined).map((item) => this.$matrix.matrixClient.redactEvent(this.room.roomId, item.mediaEventId, undefined, { reason: "cancel" }));
|
||||||
.then(() => {
|
promises.push(this.$matrix.matrixClient.redactEvent(this.room.roomId, this.sendingRootEventId, undefined, { reason: "cancel" }));
|
||||||
console.log("Message redacted");
|
Promise.allSettled(promises)
|
||||||
})
|
.then(() => {
|
||||||
.catch((err) => {
|
console.log("Message redacted");
|
||||||
console.log("Redaction failed: ", err);
|
})
|
||||||
});
|
.catch((err) => {
|
||||||
|
console.log("Redaction failed: ", err);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue