2021-06-03 21:03:02 +05:30
|
|
|
import {ViewModel} from "../../ViewModel.js";
|
|
|
|
import {avatarInitials, getIdentifierColorNumber, getAvatarHttpUrl} from "../../avatar.js";
|
2021-05-23 15:49:31 +05:30
|
|
|
|
2021-06-07 00:19:31 +05:30
|
|
|
export class RoomDetailsViewModel extends ViewModel {
|
2021-05-23 15:49:31 +05:30
|
|
|
constructor(options) {
|
|
|
|
super(options);
|
|
|
|
this._room = options.room;
|
2021-06-06 23:18:16 +05:30
|
|
|
this._room.on("change", () => this.emitChange());
|
2021-05-23 15:49:31 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
get roomId() {
|
2021-06-01 21:08:07 +05:30
|
|
|
return this._room.id;
|
|
|
|
}
|
|
|
|
|
|
|
|
get canonicalAlias() {
|
2021-06-04 16:42:39 +05:30
|
|
|
return this._room.canonicalAlias;
|
2021-05-23 15:49:31 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
get name() {
|
2021-06-04 16:42:39 +05:30
|
|
|
return this._room.name;
|
2021-05-23 15:49:31 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
get isEncrypted() {
|
2021-06-04 16:42:39 +05:30
|
|
|
return !!this._room.isEncrypted;
|
2021-05-23 15:49:31 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
get memberCount() {
|
2021-06-04 16:42:39 +05:30
|
|
|
return this._room.joinedMemberCount;
|
2021-05-23 15:49:31 +05:30
|
|
|
}
|
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
|
|
|
|
2021-06-04 13:21:49 +05:30
|
|
|
closePanel() {
|
|
|
|
const path = this.navigation.path.until("room");
|
|
|
|
this.navigation.applyPath(path);
|
2021-05-26 16:11:49 +05:30
|
|
|
}
|
2021-05-23 15:49:31 +05:30
|
|
|
}
|