This repository has been archived on 2022-08-19. You can view files and clone it, but cannot push or open issues or pull requests.
hydrogen-web/src/domain/session/rightpanel/RoomDetailsViewModel.js

52 lines
1.1 KiB
JavaScript
Raw Normal View History

import {ViewModel} from "../../ViewModel.js";
import {avatarInitials, getIdentifierColorNumber, getAvatarHttpUrl} from "../../avatar.js";
export class RoomDetailsViewModel extends ViewModel {
constructor(options) {
super(options);
this._room = options.room;
this._room.on("change", () => this.emitChange());
}
get roomId() {
return this._room.id;
}
get canonicalAlias() {
return this._room.canonicalAlias;
}
get name() {
return this._room.name;
}
get isEncrypted() {
return !!this._room.isEncrypted;
}
get memberCount() {
return this._room.joinedMemberCount;
}
get avatarLetter() {
return avatarInitials(this.name);
}
get avatarColorNumber() {
return getIdentifierColorNumber(this.roomId)
}
avatarUrl(size) {
return getAvatarHttpUrl(this._room.avatarUrl, size, this.platform, this._room.mediaRepository);
}
get avatarTitle() {
return this.name;
}
closePanel() {
const path = this.navigation.path.until("room");
this.navigation.applyPath(path);
}
}