also clear pending reaction promise when an error is thrown

This commit is contained in:
Bruno Windels 2021-06-23 17:47:47 +02:00
parent 1a5a64864a
commit c585d76ce5

View File

@ -142,6 +142,7 @@ export class BaseMessageTile extends SimpleTile {
return; return;
} }
const redaction = this._entry.getAnnotationPendingRedaction(key); const redaction = this._entry.getAnnotationPendingRedaction(key);
try {
const updatePromise = new Promise(resolve => this._pendingReactionChangeCallback = resolve); const updatePromise = new Promise(resolve => this._pendingReactionChangeCallback = resolve);
if (redaction && !redaction.pendingEvent.hasStartedSending) { if (redaction && !redaction.pendingEvent.hasStartedSending) {
log.set("abort_redaction", true); log.set("abort_redaction", true);
@ -150,8 +151,10 @@ export class BaseMessageTile extends SimpleTile {
await this._room.sendEvent("m.reaction", this._entry.annotate(key), null, log); await this._room.sendEvent("m.reaction", this._entry.annotate(key), null, log);
} }
await updatePromise; await updatePromise;
} finally {
this._pendingReactionChangeCallback = null; this._pendingReactionChangeCallback = null;
} }
}
redactReaction(key, log = null) { redactReaction(key, log = null) {
return this.logger.wrapOrRun(log, "redactReaction", log => { return this.logger.wrapOrRun(log, "redactReaction", log => {
@ -173,10 +176,13 @@ export class BaseMessageTile extends SimpleTile {
} }
const entry = await this._entry.getOwnAnnotationEntry(this._timeline, key); const entry = await this._entry.getOwnAnnotationEntry(this._timeline, key);
if (entry) { if (entry) {
try {
const updatePromise = new Promise(resolve => this._pendingReactionChangeCallback = resolve); const updatePromise = new Promise(resolve => this._pendingReactionChangeCallback = resolve);
await this._room.sendRedaction(entry.id, null, log); await this._room.sendRedaction(entry.id, null, log);
await updatePromise; await updatePromise;
} finally {
this._pendingReactionChangeCallback = null; this._pendingReactionChangeCallback = null;
}
} else { } else {
log.set("no_reaction", true); log.set("no_reaction", true);
} }