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-14 21:04:44 +05:30
|
|
|
this._onRoomChange = this._onRoomChange.bind(this);
|
|
|
|
this._room.on("change", this._onRoomChange);
|
2021-05-23 15:49:31 +05:30
|
|
|
}
|
|
|
|
|
2021-06-27 15:05:35 +05:30
|
|
|
get type() {
|
|
|
|
return "room-details";
|
|
|
|
}
|
|
|
|
|
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() {
|
2021-06-29 00:14:27 +05:30
|
|
|
return getIdentifierColorNumber(this._room.avatarColorId)
|
2021-05-25 12:06:09 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
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-14 21:04:44 +05:30
|
|
|
_onRoomChange() {
|
|
|
|
this.emitChange();
|
|
|
|
}
|
|
|
|
|
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-06-14 21:04:44 +05:30
|
|
|
|
|
|
|
dispose() {
|
|
|
|
super.dispose();
|
|
|
|
this._room.off("change", this._onRoomChange);
|
|
|
|
}
|
2021-07-14 20:53:45 +05:30
|
|
|
|
|
|
|
openPanel(segment) {
|
|
|
|
let path = this.navigation.path.until("room");
|
|
|
|
path = path.with(this.navigation.segment("right-panel", true));
|
|
|
|
path = path.with(this.navigation.segment(segment, true));
|
|
|
|
this.navigation.applyPath(path);
|
|
|
|
}
|
2021-05-23 15:49:31 +05:30
|
|
|
}
|