Skip to content

Commit

Permalink
Merge pull request #347 from vector-im/bwindels/roomlistsorting
Browse files Browse the repository at this point in the history
Don't move rooms to lower sorting position once marked as read
  • Loading branch information
bwindels authored May 12, 2021
2 parents 93c08c1 + 56699ba commit 0e270f4
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 17 deletions.
3 changes: 0 additions & 3 deletions src/domain/session/leftpanel/BaseTileViewModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,6 @@ export class BaseTileViewModel extends ViewModel {
super(options);
this._isOpen = false;
this._hidden = false;
if (options.isOpen) {
this.open();
}
}

get hidden() {
Expand Down
7 changes: 4 additions & 3 deletions src/domain/session/leftpanel/LeftPanelViewModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
11 changes: 0 additions & 11 deletions src/domain/session/leftpanel/RoomTileViewModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,11 @@ limitations under the License.

import {BaseTileViewModel} from "./BaseTileViewModel.js";

function isSortedAsUnread(vm) {
return vm.isUnread || (vm.isOpen && vm._wasUnreadWhenOpening);
}

export class RoomTileViewModel extends BaseTileViewModel {
constructor(options) {
super(options);
const {room} = options;
this._room = room;
this._wasUnreadWhenOpening = false;
this._url = this.urlCreator.openRoomActionUrl(this._room.id);
}

Expand Down Expand Up @@ -57,12 +52,6 @@ export class RoomTileViewModel extends BaseTileViewModel {
}
return -1;
}
if (isSortedAsUnread(this) !== isSortedAsUnread(other)) {
if (isSortedAsUnread(this)) {
return -1;
}
return 1;
}
const myTimestamp = myRoom.lastMessageTimestamp;
const theirTimestamp = theirRoom.lastMessageTimestamp;
const myTimestampValid = Number.isSafeInteger(myTimestamp);
Expand Down

0 comments on commit 0e270f4

Please sign in to comment.