Support read markers on invisible events
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Cadence Ember 2020-12-06 23:45:33 +13:00
parent 9dce348a4c
commit 879c09f70b
Signed by: cadence
GPG key ID: BC1C2C61CF521B17
3 changed files with 21 additions and 7 deletions

18
src/js/events/hidden.js Normal file
View file

@ -0,0 +1,18 @@
const {UngroupableEvent} = require("./event")
class HiddenEvent extends UngroupableEvent {
constructor(data) {
super(data)
this.class("c-hidden-event")
this.clearChildren()
}
static canRender(eventData) {
return ["m.reaction", "m.call.candidates"].includes(eventData.type)
}
render() {
}
}
module.exports = [HiddenEvent]

View file

@ -4,6 +4,7 @@ const encryptedEvent = require("./encrypted")
const membershipEvent = require("./membership") const membershipEvent = require("./membership")
const unknownEvent = require("./unknown") const unknownEvent = require("./unknown")
const callEvent = require("./call") const callEvent = require("./call")
const hiddenEvent = require("./hidden")
const events = [ const events = [
...imageEvent, ...imageEvent,
@ -11,10 +12,10 @@ const events = [
...encryptedEvent, ...encryptedEvent,
...membershipEvent, ...membershipEvent,
...callEvent, ...callEvent,
...hiddenEvent,
...unknownEvent, ...unknownEvent,
] ]
function renderEvent(eventData) { function renderEvent(eventData) {
const constructor = events.find(e => e.canRender(eventData)) const constructor = events.find(e => e.canRender(eventData))
return new constructor(eventData) return new constructor(eventData)

View file

@ -262,10 +262,6 @@ class Timeline extends Subscribable {
// update existing event // update existing event
this.map.get(id).update(eventData) this.map.get(id).update(eventData)
} else { } else {
// skip displaying events that we don't know how to
if (["m.reaction", "m.call.candidates"].includes(eventData.type)) {
continue
}
// skip redacted events // skip redacted events
if (eventData.unsigned && eventData.unsigned.redacted_by) { if (eventData.unsigned && eventData.unsigned.redacted_by) {
continue continue
@ -321,12 +317,11 @@ class Timeline extends Subscribable {
} }
moveReadReceipt(user, eventID) { moveReadReceipt(user, eventID) {
if (!this.map.has(eventID)) return // ignore receipts we don't have events for
// check for a previous event to move from // check for a previous event to move from
const prev = this.userReads.get(user) const prev = this.userReads.get(user)
if (prev.exists()) { if (prev.exists()) {
const prevID = prev.value() const prevID = prev.value()
if (this.map.has(prevID)) { if (this.map.has(prevID) && this.map.has(eventID)) {
// ensure new message came later // ensure new message came later
if (this.map.get(eventID).data.origin_server_ts < this.map.get(prevID).data.origin_server_ts) return if (this.map.get(eventID).data.origin_server_ts < this.map.get(prevID).data.origin_server_ts) return
this.map.get(prevID).readBy.delete(user) this.map.get(prevID).readBy.delete(user)