mirror of
https://github.com/vector-im/hydrogen-web.git
synced 2024-12-23 19:45:05 +01:00
provide redact method on tile and room
also add some logging
This commit is contained in:
parent
9721432a8c
commit
8a8c5569dc
@ -97,4 +97,8 @@ export class BaseMessageTile extends SimpleTile {
|
|||||||
this.emitChange("isContinuation");
|
this.emitChange("isContinuation");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
redact(reason) {
|
||||||
|
this._room.sendRedaction(this._entry.id, reason);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -24,10 +24,6 @@ export class GapTile extends SimpleTile {
|
|||||||
this._error = null;
|
this._error = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
get _room() {
|
|
||||||
return this.getOption("room");
|
|
||||||
}
|
|
||||||
|
|
||||||
async fill() {
|
async fill() {
|
||||||
// prevent doing this twice
|
// prevent doing this twice
|
||||||
if (!this._loading) {
|
if (!this._loading) {
|
||||||
|
@ -118,4 +118,8 @@ export class SimpleTile extends ViewModel {
|
|||||||
super.dispose();
|
super.dispose();
|
||||||
}
|
}
|
||||||
// TilesCollection contract above
|
// TilesCollection contract above
|
||||||
|
|
||||||
|
get _room() {
|
||||||
|
return this.getOption("room");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -297,6 +297,14 @@ export class Room extends BaseRoom {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @public */
|
||||||
|
sendRedaction(eventIdOrTxnId, reason, log = null) {
|
||||||
|
this._platform.logger.wrapOrRun(log, "redact", log => {
|
||||||
|
log.set("id", this.id);
|
||||||
|
return this._sendQueue.enqueueRedaction(eventIdOrTxnId, reason, log);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
/** @public */
|
/** @public */
|
||||||
async ensureMessageKeyIsShared(log = null) {
|
async ensureMessageKeyIsShared(log = null) {
|
||||||
if (!this._roomEncryption) {
|
if (!this._roomEncryption) {
|
||||||
|
@ -201,6 +201,7 @@ export class SendQueue {
|
|||||||
|
|
||||||
async enqueueRedaction(eventIdOrTxnId, reason, log) {
|
async enqueueRedaction(eventIdOrTxnId, reason, log) {
|
||||||
if (isTxnId(eventIdOrTxnId)) {
|
if (isTxnId(eventIdOrTxnId)) {
|
||||||
|
log.set("txnIdToRedact", eventIdOrTxnId);
|
||||||
const txnId = eventIdOrTxnId;
|
const txnId = eventIdOrTxnId;
|
||||||
const pe = this._pendingEvents.array.find(pe => pe.txnId === txnId);
|
const pe = this._pendingEvents.array.find(pe => pe.txnId === txnId);
|
||||||
if (pe && !pe.remoteId && pe.status !== SendStatus.Sending) {
|
if (pe && !pe.remoteId && pe.status !== SendStatus.Sending) {
|
||||||
@ -216,6 +217,8 @@ export class SendQueue {
|
|||||||
// and a bit complicated to fix.
|
// and a bit complicated to fix.
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
log.set("eventIdToRedact", eventIdOrTxnId);
|
||||||
}
|
}
|
||||||
await this._enqueueEvent(REDACTION_TYPE, {reason}, null, eventIdOrTxnId, log);
|
await this._enqueueEvent(REDACTION_TYPE, {reason}, null, eventIdOrTxnId, log);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user