Merge pull request #347 from vector-im/bwindels/roomlistsorting

Don't move rooms to lower sorting position once marked as read
This commit is contained in:
Bruno Windels 2021-05-12 16:32:14 +00:00 committed by GitHub
commit 0e270f4cb9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 4 additions and 17 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() {

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

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