fix room list sorting not keeping sorting position after clearing unread

This commit is contained in:
Bruno Windels 2021-05-12 18:26:55 +02:00
parent 93c08c16c1
commit 402a5e5d54
3 changed files with 12 additions and 6 deletions

View File

@ -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() {

View File

@ -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;

View File

@ -105,4 +105,10 @@ export class RoomTileViewModel extends BaseTileViewModel {
get _avatarSource() {
return this._room;
}
open() {
if (super.open()) {
this._wasUnreadWhenOpening = this._room.isUnread;
}
}
}