2021-07-23 18:05:48 +05:30
|
|
|
/*
|
|
|
|
Copyright 2021 The Matrix.org Foundation C.I.C.
|
|
|
|
|
|
|
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
you may not use this file except in compliance with the License.
|
|
|
|
You may obtain a copy of the License at
|
|
|
|
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
See the License for the specific language governing permissions and
|
|
|
|
limitations under the License.
|
|
|
|
*/
|
|
|
|
|
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-07-15 13:08:05 +05:30
|
|
|
get shouldShowBackButton() {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
get previousSegmentName() {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
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();
|
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
}
|