Skip to content

Commit

Permalink
Merge pull request #213 from Automattic/allow_navigating_away_from_un…
Browse files Browse the repository at this point in the history
…known_room_view

Allow navigating away from unknown room view
  • Loading branch information
psrpinto authored Apr 14, 2023
2 parents 689c324 + 2573be5 commit 019588e
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 0 deletions.
11 changes: 11 additions & 0 deletions frontend/iframe/viewmodels/SessionViewModel.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { SessionViewModel as BaseSessionViewModel } from "hydrogen-web/src/domain/session/SessionViewModel";
import { RoomViewModel } from "./RoomViewModel";
import { UnknownRoomViewModel } from "./UnknownRoomVideoModel";
import { SettingsViewModel } from "./SettingsViewModel";

export class SessionViewModel extends BaseSessionViewModel {
Expand Down Expand Up @@ -110,4 +111,14 @@ export class SessionViewModel extends BaseSessionViewModel {
}
return null;
}

async _createUnknownRoomViewModel(roomIdOrAlias, isWorldReadablePromise) {
return new UnknownRoomViewModel(super.childOptions({
roomIdOrAlias,
session: this.client.session,
isWorldReadablePromise: isWorldReadablePromise,
guestJoinAllowed: false,
singleRoomId: this._singleRoomId,
}));
}
}
29 changes: 29 additions & 0 deletions frontend/iframe/viewmodels/UnknownRoomVideoModel.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import {UnknownRoomViewModel as BaseUnknownRoomViewModel} from "hydrogen-web/src/domain/session/room/UnknownRoomViewModel";
import {SegmentType} from "hydrogen-web/src/domain/navigation";
import {Segment} from "hydrogen-web/src/domain/navigation/Navigation";

export class UnknownRoomViewModel extends BaseUnknownRoomViewModel {
private readonly _singleRoomId: any;

constructor(options) {
super(options);
this._singleRoomId = options.singleRoomId;
}

get navigation() {
return super.navigation;
}

get urlRouter() {
return super.urlRouter;
}

get closeUrl() {
if (this._singleRoomId) {
const path = this.navigation.path.with(new Segment<SegmentType>("session"));
return this.urlRouter.urlForPath(path);
}

return super.closeUrl;
}
}

0 comments on commit 019588e

Please sign in to comment.