different room view models don't need to initiate switching now
as this is triggered by observing the room status
This commit is contained in:
parent
6c58c61da9
commit
a8d4ee0dd6
2 changed files with 4 additions and 22 deletions
|
@ -21,10 +21,9 @@ import {ViewModel} from "../../ViewModel.js";
|
||||||
export class InviteViewModel extends ViewModel {
|
export class InviteViewModel extends ViewModel {
|
||||||
constructor(options) {
|
constructor(options) {
|
||||||
super(options);
|
super(options);
|
||||||
const {invite, mediaRepository, refreshRoomViewModel} = options;
|
const {invite, mediaRepository} = options;
|
||||||
this._invite = invite;
|
this._invite = invite;
|
||||||
this._mediaRepository = mediaRepository;
|
this._mediaRepository = mediaRepository;
|
||||||
this._refreshRoomViewModel = refreshRoomViewModel;
|
|
||||||
this._onInviteChange = this._onInviteChange.bind(this);
|
this._onInviteChange = this._onInviteChange.bind(this);
|
||||||
this._error = null;
|
this._error = null;
|
||||||
this._closeUrl = this.urlCreator.urlUntilSegment("session");
|
this._closeUrl = this.urlCreator.urlUntilSegment("session");
|
||||||
|
@ -107,17 +106,7 @@ export class InviteViewModel extends ViewModel {
|
||||||
}
|
}
|
||||||
|
|
||||||
_onInviteChange() {
|
_onInviteChange() {
|
||||||
if (this._invite.accepted || this._invite.rejected) {
|
this.emitChange();
|
||||||
// close invite if rejected, or open room if accepted.
|
|
||||||
// Done with a callback rather than manipulating the nav,
|
|
||||||
// as closing the invite changes the nav path depending whether
|
|
||||||
// we're in a grid view, and opening the room doesn't change
|
|
||||||
// the nav path because the url is the same for an
|
|
||||||
// invite and the room.
|
|
||||||
this._refreshRoomViewModel(this.id);
|
|
||||||
} else {
|
|
||||||
this.emitChange();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
dispose() {
|
dispose() {
|
||||||
|
|
|
@ -22,10 +22,9 @@ import {ViewModel} from "../../ViewModel.js";
|
||||||
export class RoomViewModel extends ViewModel {
|
export class RoomViewModel extends ViewModel {
|
||||||
constructor(options) {
|
constructor(options) {
|
||||||
super(options);
|
super(options);
|
||||||
const {room, ownUserId, refreshRoomViewModel} = options;
|
const {room, ownUserId} = options;
|
||||||
this._room = room;
|
this._room = room;
|
||||||
this._ownUserId = ownUserId;
|
this._ownUserId = ownUserId;
|
||||||
this._refreshRoomViewModel = refreshRoomViewModel;
|
|
||||||
this._timelineVM = null;
|
this._timelineVM = null;
|
||||||
this._onRoomChange = this._onRoomChange.bind(this);
|
this._onRoomChange = this._onRoomChange.bind(this);
|
||||||
this._timelineError = null;
|
this._timelineError = null;
|
||||||
|
@ -86,13 +85,7 @@ export class RoomViewModel extends ViewModel {
|
||||||
// room doesn't tell us yet which fields changed,
|
// room doesn't tell us yet which fields changed,
|
||||||
// so emit all fields originating from summary
|
// so emit all fields originating from summary
|
||||||
_onRoomChange() {
|
_onRoomChange() {
|
||||||
// if there is now an invite on this (left) room,
|
this.emitChange();
|
||||||
// show the invite view by refreshing the view model
|
|
||||||
if (this._room.invite) {
|
|
||||||
this._refreshRoomViewModel(this.id);
|
|
||||||
} else {
|
|
||||||
this.emitChange("name");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
get kind() { return "room"; }
|
get kind() { return "room"; }
|
||||||
|
|
Reference in a new issue