2020-04-20 21:26:39 +02:00
|
|
|
import {GapTile} from "./tiles/GapTile.js";
|
|
|
|
import {TextTile} from "./tiles/TextTile.js";
|
|
|
|
import {LocationTile} from "./tiles/LocationTile.js";
|
|
|
|
import {RoomNameTile} from "./tiles/RoomNameTile.js";
|
|
|
|
import {RoomMemberTile} from "./tiles/RoomMemberTile.js";
|
2019-03-08 20:04:56 +01:00
|
|
|
|
2020-04-20 21:26:39 +02:00
|
|
|
export function tilesCreator({room, ownUserId}) {
|
2019-06-12 21:57:13 +02:00
|
|
|
return function tilesCreator(entry, emitUpdate) {
|
2019-06-16 10:53:23 +02:00
|
|
|
const options = {entry, emitUpdate, ownUserId};
|
2019-06-01 18:29:02 +02:00
|
|
|
if (entry.isGap) {
|
2020-03-21 23:40:40 +01:00
|
|
|
return new GapTile(options, room);
|
2019-07-29 10:27:12 +02:00
|
|
|
} else if (entry.eventType) {
|
|
|
|
switch (entry.eventType) {
|
2019-03-08 20:04:56 +01:00
|
|
|
case "m.room.message": {
|
2019-07-29 10:27:12 +02:00
|
|
|
const content = entry.content;
|
2019-03-08 20:04:56 +01:00
|
|
|
const msgtype = content && content.msgtype;
|
|
|
|
switch (msgtype) {
|
|
|
|
case "m.text":
|
2019-03-09 00:40:03 +01:00
|
|
|
case "m.notice":
|
2019-06-01 18:32:17 +02:00
|
|
|
case "m.emote":
|
2019-03-09 00:40:03 +01:00
|
|
|
return new TextTile(options);
|
2019-03-08 20:04:56 +01:00
|
|
|
case "m.image":
|
2019-06-16 10:52:02 +02:00
|
|
|
return null; // not supported yet
|
|
|
|
// return new ImageTile(options);
|
2019-03-09 00:40:03 +01:00
|
|
|
case "m.location":
|
|
|
|
return new LocationTile(options);
|
2019-03-08 20:04:56 +01:00
|
|
|
default:
|
2019-03-09 00:40:03 +01:00
|
|
|
// unknown msgtype not rendered
|
|
|
|
return null;
|
2019-03-08 20:04:56 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
case "m.room.name":
|
2019-03-09 00:40:03 +01:00
|
|
|
return new RoomNameTile(options);
|
2019-03-08 20:04:56 +01:00
|
|
|
case "m.room.member":
|
2019-03-09 00:40:03 +01:00
|
|
|
return new RoomMemberTile(options);
|
2019-03-08 20:04:56 +01:00
|
|
|
default:
|
2019-03-09 00:40:03 +01:00
|
|
|
// unknown type not rendered
|
2019-03-08 20:04:56 +01:00
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|