mirror of
https://github.com/vector-im/hydrogen-web.git
synced 2025-01-10 20:17:32 +01:00
57 lines
1.4 KiB
JavaScript
57 lines
1.4 KiB
JavaScript
import * as html from "./html.js";
|
|
|
|
function tileText(event) {
|
|
const content = event.content;
|
|
switch (event.type) {
|
|
case "m.room.message": {
|
|
const msgtype = content.msgtype;
|
|
switch (msgtype) {
|
|
case "m.text":
|
|
return content.body;
|
|
default:
|
|
return `unsupported msgtype: ${msgtype}`;
|
|
}
|
|
}
|
|
case "m.room.name":
|
|
return `changed the room name to "${content.name}"`;
|
|
case "m.room.member":
|
|
return `changed membership to ${content.membership}`;
|
|
default:
|
|
return `unsupported event type: ${event.type}`;
|
|
}
|
|
}
|
|
|
|
export default class TimelineTile {
|
|
constructor(entry) {
|
|
this._entry = entry;
|
|
this._root = null;
|
|
}
|
|
|
|
root() {
|
|
return this._root;
|
|
}
|
|
|
|
mount() {
|
|
let children;
|
|
if (this._entry.gap) {
|
|
children = [
|
|
html.strong(null, "Gap"),
|
|
" with prev_batch ",
|
|
html.strong(null, this._entry.gap.prev_batch)
|
|
];
|
|
} else if (this._entry.event) {
|
|
const event = this._entry.event;
|
|
children = [
|
|
html.strong(null, event.sender),
|
|
`: ${tileText(event)}`,
|
|
];
|
|
}
|
|
this._root = html.li(null, children);
|
|
return this._root;
|
|
}
|
|
|
|
unmount() {}
|
|
|
|
update() {}
|
|
}
|