Merge branch 'master' of github.com:vector-im/hydrogen-web

This commit is contained in:
Bruno Windels 2021-05-12 18:33:25 +02:00
commit 59a74dbd9f
3 changed files with 4 additions and 17 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() {

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

@ -17,16 +17,11 @@ limitations under the License.
import {BaseTileViewModel} from "./BaseTileViewModel.js"; import {BaseTileViewModel} from "./BaseTileViewModel.js";
function isSortedAsUnread(vm) {
return vm.isUnread || (vm.isOpen && vm._wasUnreadWhenOpening);
}
export class RoomTileViewModel extends BaseTileViewModel { export class RoomTileViewModel extends BaseTileViewModel {
constructor(options) { constructor(options) {
super(options); super(options);
const {room} = options; const {room} = options;
this._room = room; this._room = room;
this._wasUnreadWhenOpening = false;
this._url = this.urlCreator.openRoomActionUrl(this._room.id); this._url = this.urlCreator.openRoomActionUrl(this._room.id);
} }
@ -57,12 +52,6 @@ export class RoomTileViewModel extends BaseTileViewModel {
} }
return -1; return -1;
} }
if (isSortedAsUnread(this) !== isSortedAsUnread(other)) {
if (isSortedAsUnread(this)) {
return -1;
}
return 1;
}
const myTimestamp = myRoom.lastMessageTimestamp; const myTimestamp = myRoom.lastMessageTimestamp;
const theirTimestamp = theirRoom.lastMessageTimestamp; const theirTimestamp = theirRoom.lastMessageTimestamp;
const myTimestampValid = Number.isSafeInteger(myTimestamp); const myTimestampValid = Number.isSafeInteger(myTimestamp);