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); super(options);
this._isOpen = false; this._isOpen = false;
this._hidden = false; this._hidden = false;
if (options.isOpen) {
this.open();
}
} }
get hidden() { get hidden() {
@ -52,7 +49,9 @@ export class BaseTileViewModel extends ViewModel {
if (!this._isOpen) { if (!this._isOpen) {
this._isOpen = true; this._isOpen = true;
this.emitChange("isOpen"); this.emitChange("isOpen");
return true;
} }
return false;
} }
get isOpen() { get isOpen() {

View file

@ -37,14 +37,15 @@ export class LeftPanelViewModel extends ViewModel {
_mapTileViewModels(rooms, invites) { _mapTileViewModels(rooms, invites) {
// join is not commutative, invites will take precedence over rooms // join is not commutative, invites will take precedence over rooms
return invites.join(rooms).mapValues((roomOrInvite, emitChange) => { return invites.join(rooms).mapValues((roomOrInvite, emitChange) => {
const isOpen = this.navigation.path.get("room")?.value === roomOrInvite.id;
let vm; let vm;
if (roomOrInvite.isInvite) { if (roomOrInvite.isInvite) {
vm = new InviteTileViewModel(this.childOptions({isOpen, invite: roomOrInvite, emitChange})); vm = new InviteTileViewModel(this.childOptions({invite: roomOrInvite, emitChange}));
} else { } 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) { if (isOpen) {
vm.open();
this._updateCurrentVM(vm); this._updateCurrentVM(vm);
} }
return vm; return vm;

View file

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