Add code to toggle RoomInformation panel

Signed-off-by: RMidhunSuresh <rmidhunsuresh@gmail.com>
This commit is contained in:
RMidhunSuresh 2021-05-23 17:17:24 +05:30
parent c7fd0fac07
commit 986271d02a

View file

@ -16,7 +16,8 @@ limitations under the License.
*/
import {LeftPanelViewModel} from "./leftpanel/LeftPanelViewModel.js";
import {RoomViewModel} from "./room/RoomViewModel.js";
import { RoomViewModel } from "./room/RoomViewModel.js";
import { RoomInfoViewModel } from "./rightpanel/RoomInfoViewModel.js";
import {UnknownRoomViewModel} from "./room/UnknownRoomViewModel.js";
import {InviteViewModel} from "./room/InviteViewModel.js";
import {LightboxViewModel} from "./room/LightboxViewModel.js";
@ -78,6 +79,10 @@ export class SessionViewModel extends ViewModel {
this._updateLightbox(eventId);
}));
this._updateLightbox(lightbox.get());
const details = this.navigation.observe("details");
this.track(details.subscribe(() => this._toggleRoomInformationPanel()));
}
get id() {
@ -112,6 +117,10 @@ export class SessionViewModel extends ViewModel {
return this._roomViewModelObservable?.get();
}
get roomInfoViewModel() {
return this._roomInfoViewModel;
}
_updateGrid(roomIds) {
const changed = !(this._gridViewModel && roomIds);
const currentRoomId = this.navigation.path.get("room");
@ -240,4 +249,18 @@ export class SessionViewModel extends ViewModel {
get lightboxViewModel() {
return this._lightboxViewModel;
}
_toggleRoomInformationPanel() {
const roomId = this.navigation.path.get("room").value;
const room = this._sessionContainer.session.rooms.get(roomId);
const enable = !!this.navigation.path.get("details");
if (!room) {
return;
}
this._roomInfoViewModel = enable ?
this.track(new RoomInfoViewModel(this.childOptions({ room }))) :
this.disposeTracked(this._roomInfoViewModel);
this.emitChange();
}
}