diff --git a/public/config.json b/public/config.json index 38a792efa84a4292b91e4a9950d79940f0b13ba6..fad29ef06331f1bdeef1daaea5f44ea4d5e39465 100644 --- a/public/config.json +++ b/public/config.json @@ -8,5 +8,6 @@ }, "token": "k9SL1R~GcdbjiFjC", "invite_user": "@botuser:matrix.midhun.dev", - "encrypt_room": true + "encrypt_room": true, + "avatar": "https://i.imgur.com/FD1z37K.png" } diff --git a/src/types/IChatterboxConfig.ts b/src/types/IChatterboxConfig.ts index 6fab8eeb4f382a8e90f2a3c7f540db121dd09c05..c555e79db1c01bf8e01ca78a12ea543a183ed3f2 100644 --- a/src/types/IChatterboxConfig.ts +++ b/src/types/IChatterboxConfig.ts @@ -13,6 +13,8 @@ export interface IChatterboxConfig { header: IHeader; // Token needed for token-authenticated registration token: string; + // URL of the image that should be used as the users avatar + avatar: string; } interface IHeader { diff --git a/src/viewmodels/ChatterboxViewModel.ts b/src/viewmodels/ChatterboxViewModel.ts index f225dbcf79987edbde8d15639dc7fbf6a8e799dc..05844c7e74671146bac4ac4b946455bcf031bd6c 100644 --- a/src/viewmodels/ChatterboxViewModel.ts +++ b/src/viewmodels/ChatterboxViewModel.ts @@ -23,14 +23,14 @@ export class ChatterboxViewModel extends ViewModel { else { throw new Error("ConfigError: You must either specify 'invite_user' or 'auto_join_room'"); } - this._roomViewModel = this.track(new RoomViewModel({ + this._roomViewModel = this.track(new RoomViewModel(this.childOptions({ room, ownUserId: this._session.userId, platform: this.platform, urlCreator: this.urlCreator, navigation: this.navigation, tileClassForEntry: createCustomTileClassForEntry(this._session.userId), - })); + }))); await this._roomViewModel.load(); this.emitChange("roomViewModel"); } diff --git a/src/viewmodels/tiles.ts b/src/viewmodels/tiles.ts index b91ae0222db2b298798b5adc7d7a4c856990b3e8..ec627354812b7c3e3c8822285dd4eae10f0b6978 100644 --- a/src/viewmodels/tiles.ts +++ b/src/viewmodels/tiles.ts @@ -5,36 +5,84 @@ class ChatterboxTextTile extends TextTile { get displayName() { return this.isOwn? "me" : super.displayName; } + + get avatarLetter() { + return ""; + } + + avatarUrl() { + return this.isOwn? this._options.config["avatar"]: null; + } } class ChatterboxImageTile extends ImageTile { get displayName() { return this.isOwn? "me" : super.displayName; } + + get avatarLetter() { + return ""; + } + + avatarUrl() { + return this.isOwn? this._options.config["avatar"]: null; + } } class ChatterboxVideoTile extends VideoTile { get displayName() { return this.isOwn? "me" : super.displayName; } + + get avatarLetter() { + return ""; + } + + avatarUrl() { + return this.isOwn? this._options.config["avatar"]: null; + } } class ChatterboxFileTile extends FileTile { get displayName() { return this.isOwn? "me" : super.displayName; } + + get avatarLetter() { + return ""; + } + + avatarUrl() { + return this.isOwn? this._options.config["avatar"]: null; + } } class ChatterboxLocationTile extends LocationTile { get displayName() { return this.isOwn? "me" : super.displayName; } + + get avatarLetter() { + return ""; + } + + avatarUrl() { + return this.isOwn? this._options.config["avatar"]: null; + } } class ChatterboxRedactedTile extends RedactedTile { get displayName() { return this.isOwn? "me" : super.displayName; } + + get avatarLetter() { + return ""; + } + + avatarUrl() { + return this._options.config["avatar"]; + } } // We don't want to show the (long and random) user-id in this announcement!