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

View file

@ -262,10 +262,6 @@ class Timeline extends Subscribable {
// update existing event
this.map.get(id).update(eventData)
} else {
// skip displaying events that we don't know how to
if (["m.reaction", "m.call.candidates"].includes(eventData.type)) {
continue
}
// skip redacted events
if (eventData.unsigned && eventData.unsigned.redacted_by) {
continue
@ -321,12 +317,11 @@ class Timeline extends Subscribable {
}
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
const prev = this.userReads.get(user)
if (prev.exists()) {
const prevID = prev.value()
if (this.map.has(prevID)) {
if (this.map.has(prevID) && this.map.has(eventID)) {
// ensure new message came later
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)