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