Support redactions

This commit is contained in:
Cadence Ember 2020-10-21 01:32:25 +13:00
parent 6b88ede18e
commit 3535d87b8a
Signed by untrusted user: cadence
GPG key ID: BC1C2C61CF521B17

View file

@ -180,6 +180,7 @@ class ReactiveTimeline extends ElemJS {
const group = new EventGroup(this, [event]) const group = new EventGroup(this, [event])
this.list.splice(i, 0, group) this.list.splice(i, 0, group)
this.childAt(i, group) this.childAt(i, group)
event.setGroup(group)
return true return true
} else if (this.list[i] && this.list[i].data.sender === event.data.sender) { } else if (this.list[i] && this.list[i].data.sender === event.data.sender) {
// if (printed++ < 100) console.log("tryadd success, using existing group") // if (printed++ < 100) console.log("tryadd success, using existing group")
@ -246,7 +247,9 @@ class Timeline extends Subscribable {
let id = eventData.event_id let id = eventData.event_id
// handle local echoes // handle local echoes
if (eventData.sender === lsm.get("mx_user_id") && eventData.content && this.pending.has(eventData.content["chat.carbon.message.pending_id"])) { if (eventData.sender === lsm.get("mx_user_id") && eventData.content && this.pending.has(eventData.content["chat.carbon.message.pending_id"])) {
id = eventData.content["chat.carbon.message.pending_id"] const target = this.map.get(eventData.content["chat.carbon.message.pending_id"])
this.map.set(id, target)
this.map.delete(eventData.content["chat.carbon.message.pending_id"])
} }
// handle timeline events // handle timeline events
if (this.map.has(id)) { if (this.map.has(id)) {
@ -257,6 +260,15 @@ class Timeline extends Subscribable {
if (eventData.type === "m.reaction") { if (eventData.type === "m.reaction") {
continue continue
} }
// skip redacted events
if (eventData.unsigned && eventData.unsigned.redacted_by) {
continue
}
// handle redactions
if (eventData.type === "m.room.redaction") {
if (this.map.has(eventData.redacts)) this.map.get(eventData.redacts).removeEvent()
continue
}
// add new event // add new event
const event = new Event(eventData) const event = new Event(eventData)
this.map.set(id, event) this.map.set(id, event)