Skip to content
Snippets Groups Projects
Unverified Commit 56cb5c87 authored by R Midhun Suresh's avatar R Midhun Suresh Committed by GitHub
Browse files

Merge pull request #39 from vector-im/local-me

Override tiles to show "me" as display name
parents c69ba140 a59c141f
No related branches found
No related tags found
No related merge requests found
import { RoomViewModel, ViewModel, RoomStatus, tileClassForEntry} from "hydrogen-view-sdk";
function createCustomTileClassForEntry(ownUserId: string) {
return function customTileClassForEntry(entry) {
if (entry.content?.membership === "join" && entry.sender !== ownUserId ||
entry.eventType !== "m.room.member") {
return tileClassForEntry(entry);
}
return undefined;
}
}
import { RoomViewModel, ViewModel, RoomStatus } from "hydrogen-view-sdk";
import { createCustomTileClassForEntry } from "./tiles";
export class ChatterboxViewModel extends ViewModel {
private _roomViewModel?: typeof RoomViewModel;
......
import { TextTile, ImageTile, VideoTile, FileTile, LocationTile, RedactedTile, tileClassForEntry } from "hydrogen-view-sdk";
class ChatterboxTextTile extends TextTile {
get displayName() {
return this.isOwn? "me" : super.displayName;
}
}
class ChatterboxImageTile extends ImageTile {
get displayName() {
return this.isOwn? "me" : super.displayName;
}
}
class ChatterboxVideoTile extends VideoTile {
get displayName() {
return this.isOwn? "me" : super.displayName;
}
}
class ChatterboxFileTile extends FileTile {
get displayName() {
return this.isOwn? "me" : super.displayName;
}
}
class ChatterboxLocationTile extends LocationTile {
get displayName() {
return this.isOwn? "me" : super.displayName;
}
}
class ChatterboxRedactedTile extends RedactedTile {
get displayName() {
return this.isOwn? "me" : super.displayName;
}
}
export function createCustomTileClassForEntry(ownUserId: string) {
return function customTileClassForEntry(entry) {
switch (entry.eventType) {
case "m.room.message":
if (entry.isRedacted) {
return ChatterboxRedactedTile;
}
const content = entry.content;
const msgtype = content && content.msgtype;
switch (msgtype) {
case "m.text":
case "m.notice":
case "m.emote":
return ChatterboxTextTile;
case "m.image":
return ChatterboxImageTile;
case "m.video":
return ChatterboxVideoTile;
case "m.file":
return ChatterboxFileTile;
case "m.location":
return ChatterboxLocationTile;
default:
// unknown msgtype not rendered
return undefined;
}
case "m.room.member":
if (entry.content?.membership === "join" && entry.sender !== ownUserId) {
return tileClassForEntry(entry);
}
else {
return undefined;
}
default:
return tileClassForEntry(entry);
}
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment