diff --git a/src/domain/session/leftpanel/BaseTileViewModel.js b/src/domain/session/leftpanel/BaseTileViewModel.js index 360f2b39..684bbf1f 100644 --- a/src/domain/session/leftpanel/BaseTileViewModel.js +++ b/src/domain/session/leftpanel/BaseTileViewModel.js @@ -25,9 +25,6 @@ export class BaseTileViewModel extends ViewModel { super(options); this._isOpen = false; this._hidden = false; - if (options.isOpen) { - this.open(); - } } get hidden() { @@ -52,7 +49,9 @@ export class BaseTileViewModel extends ViewModel { if (!this._isOpen) { this._isOpen = true; this.emitChange("isOpen"); + return true; } + return false; } get isOpen() { diff --git a/src/domain/session/leftpanel/LeftPanelViewModel.js b/src/domain/session/leftpanel/LeftPanelViewModel.js index a1a577a9..6503c124 100644 --- a/src/domain/session/leftpanel/LeftPanelViewModel.js +++ b/src/domain/session/leftpanel/LeftPanelViewModel.js @@ -37,14 +37,15 @@ export class LeftPanelViewModel extends ViewModel { _mapTileViewModels(rooms, invites) { // join is not commutative, invites will take precedence over rooms return invites.join(rooms).mapValues((roomOrInvite, emitChange) => { - const isOpen = this.navigation.path.get("room")?.value === roomOrInvite.id; let vm; if (roomOrInvite.isInvite) { - vm = new InviteTileViewModel(this.childOptions({isOpen, invite: roomOrInvite, emitChange})); + vm = new InviteTileViewModel(this.childOptions({invite: roomOrInvite, emitChange})); } else { - vm = new RoomTileViewModel(this.childOptions({isOpen, room: roomOrInvite, emitChange})); + vm = new RoomTileViewModel(this.childOptions({room: roomOrInvite, emitChange})); } + const isOpen = this.navigation.path.get("room")?.value === roomOrInvite.id; if (isOpen) { + vm.open(); this._updateCurrentVM(vm); } return vm; diff --git a/src/domain/session/leftpanel/RoomTileViewModel.js b/src/domain/session/leftpanel/RoomTileViewModel.js index 50164b18..fe199ff1 100644 --- a/src/domain/session/leftpanel/RoomTileViewModel.js +++ b/src/domain/session/leftpanel/RoomTileViewModel.js @@ -105,4 +105,10 @@ export class RoomTileViewModel extends BaseTileViewModel { get _avatarSource() { return this._room; } + + open() { + if (super.open()) { + this._wasUnreadWhenOpening = this._room.isUnread; + } + } }