Small refactors
- "event" -> "eventData" - create renderText method - italics
This commit is contained in:
parent
9cf0952d3a
commit
8ba9d73b33
5 changed files with 40 additions and 22 deletions
|
@ -1,13 +1,17 @@
|
||||||
const {MatrixEvent} = require("./event")
|
const {MatrixEvent} = require("./event")
|
||||||
|
const {ejs} = require("../basic")
|
||||||
|
|
||||||
class EncryptedMessage extends MatrixEvent {
|
class EncryptedMessage extends MatrixEvent {
|
||||||
render() {
|
render() {
|
||||||
|
this.clearChildren()
|
||||||
|
this.child(
|
||||||
|
ejs("i").text("Carbon cannot render encrypted messages yet")
|
||||||
|
)
|
||||||
super.render()
|
super.render()
|
||||||
return this.text("Carbon cannot render encrypted messages yet")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static canRender(event) {
|
static canRender(eventData) {
|
||||||
return event.type == "m.room.encrypted"
|
return eventData.type === "m.room.encrypted"
|
||||||
}
|
}
|
||||||
|
|
||||||
canGroup() {
|
canGroup() {
|
||||||
|
|
|
@ -46,7 +46,7 @@ class MatrixEvent extends ElemJS {
|
||||||
return this
|
return this
|
||||||
}
|
}
|
||||||
|
|
||||||
static canRender(_event) {
|
static canRender(eventData) {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,46 +1,54 @@
|
||||||
const {MatrixEvent} = require("./event")
|
const {MatrixEvent} = require("./event")
|
||||||
|
const {ejs} = require("../basic")
|
||||||
|
|
||||||
class MembershipEvent extends MatrixEvent {
|
class MembershipEvent extends MatrixEvent {
|
||||||
static canRender(event) {
|
static canRender(eventData) {
|
||||||
return event.type == "m.room.member"
|
return eventData.type === "m.room.member"
|
||||||
|
}
|
||||||
|
|
||||||
|
renderText(text) {
|
||||||
|
this.clearChildren()
|
||||||
|
this.child(
|
||||||
|
ejs("i").text(text)
|
||||||
|
)
|
||||||
|
super.render()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
class JoinedEvent extends MembershipEvent {
|
class JoinedEvent extends MembershipEvent {
|
||||||
static canRender(event) {
|
static canRender(eventData) {
|
||||||
return super.canRender(event) && event.content.membership === "join"
|
return super.canRender(eventData) && eventData.content.membership === "join"
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
super.render()
|
this.renderText("joined the room")
|
||||||
return this.text("joined the room")
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class InvitedEvent extends MembershipEvent {
|
class InvitedEvent extends MembershipEvent {
|
||||||
static canRender(event) {
|
static canRender(eventData) {
|
||||||
return super.canRender(event) && event.content.membership === "invite"
|
return super.canRender(eventData) && eventData.content.membership === "invite"
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
super.render()
|
this.renderText(`invited ${this.data.content.displayname}`)
|
||||||
return this.text(`invited ${this.data.content.displayname}`)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class LeaveEvent extends MembershipEvent {
|
class LeaveEvent extends MembershipEvent {
|
||||||
static canRender(event) {
|
static canRender(eventData) {
|
||||||
return super.canRender(event) && event.content.membership === "leave"
|
return super.canRender(eventData) && eventData.content.membership === "leave"
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
super.render()
|
this.renderText("left the room")
|
||||||
return this.text(`left the room`)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class UnknownMembership extends MembershipEvent {
|
class UnknownMembership extends MembershipEvent {
|
||||||
render() {
|
render() {
|
||||||
super.render()
|
this.renderText("unknown membership event")
|
||||||
return this.text("unknown membership event")
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,13 +1,19 @@
|
||||||
const {MatrixEvent} = require("./event")
|
const {MatrixEvent} = require("./event")
|
||||||
|
const {ejs} = require("../basic")
|
||||||
|
|
||||||
class UnknownEvent extends MatrixEvent {
|
class UnknownEvent extends MatrixEvent {
|
||||||
static canRender() {
|
static canRender() {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
|
this.clearChildren()
|
||||||
|
this.child(
|
||||||
|
ejs("i").text(`Unknown event of type ${this.data.type}`)
|
||||||
|
)
|
||||||
super.render()
|
super.render()
|
||||||
return this.text(`cannot render event`)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = [UnknownEvent]
|
module.exports = [UnknownEvent]
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@ const {Anchor} = require("./anchor.js")
|
||||||
const {Sender} = require("./sender.js")
|
const {Sender} = require("./sender.js")
|
||||||
const lsm = require("./lsm.js")
|
const lsm = require("./lsm.js")
|
||||||
const {resolveMxc} = require("./functions.js")
|
const {resolveMxc} = require("./functions.js")
|
||||||
const {renderEvent} = require("./events/renderEvent")
|
const {renderEvent} = require("./events/render-event")
|
||||||
const {dateFormatter} = require("./date-formatter")
|
const {dateFormatter} = require("./date-formatter")
|
||||||
|
|
||||||
let debug = false
|
let debug = false
|
||||||
|
|
Loading…
Reference in a new issue