2021-05-23 15:49:31 +05:30
|
|
|
import { ViewModel } from "../../ViewModel.js";
|
2021-05-25 12:06:09 +05:30
|
|
|
import { avatarInitials, getIdentifierColorNumber, getAvatarHttpUrl } from "../../avatar.js";
|
2021-05-23 15:49:31 +05:30
|
|
|
|
|
|
|
export class RoomInfoViewModel extends ViewModel {
|
|
|
|
constructor(options) {
|
|
|
|
super(options);
|
|
|
|
this._room = options.room;
|
|
|
|
this._roomSummary = this._room._summary._data;
|
|
|
|
}
|
|
|
|
|
|
|
|
get roomId() {
|
2021-06-01 21:08:07 +05:30
|
|
|
return this._room.id;
|
|
|
|
}
|
|
|
|
|
|
|
|
get canonicalAlias() {
|
|
|
|
return this._roomSummary.canonicalAlias;
|
2021-05-23 15:49:31 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
get name() {
|
2021-05-24 22:50:17 +05:30
|
|
|
return this._roomSummary.name || this._room._heroes?._roomName || this._roomSummary.canonicalAlias;
|
2021-05-23 15:49:31 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
get isEncrypted() {
|
|
|
|
return !!this._roomSummary.encryption;
|
|
|
|
}
|
|
|
|
|
|
|
|
get memberCount() {
|
|
|
|
return this._roomSummary.joinCount;
|
|
|
|
}
|
2021-05-25 12:06:09 +05:30
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
2021-05-26 16:11:49 +05:30
|
|
|
|
|
|
|
get closeLink() {
|
|
|
|
return this.urlCreator.urlUntilSegment("room");
|
|
|
|
}
|
2021-05-23 15:49:31 +05:30
|
|
|
}
|