Skip to content

Commit 2573be5

Browse files
ashfamepsrpinto
authored andcommitted
override UnknownRoomViewModel class to define a different closeUrl() for single room mode
1 parent 689c324 commit 2573be5

File tree

2 files changed

+40
-0
lines changed

2 files changed

+40
-0
lines changed

frontend/iframe/viewmodels/SessionViewModel.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { SessionViewModel as BaseSessionViewModel } from "hydrogen-web/src/domain/session/SessionViewModel";
22
import { RoomViewModel } from "./RoomViewModel";
3+
import { UnknownRoomViewModel } from "./UnknownRoomVideoModel";
34
import { SettingsViewModel } from "./SettingsViewModel";
45

56
export class SessionViewModel extends BaseSessionViewModel {
@@ -110,4 +111,14 @@ export class SessionViewModel extends BaseSessionViewModel {
110111
}
111112
return null;
112113
}
114+
115+
async _createUnknownRoomViewModel(roomIdOrAlias, isWorldReadablePromise) {
116+
return new UnknownRoomViewModel(super.childOptions({
117+
roomIdOrAlias,
118+
session: this.client.session,
119+
isWorldReadablePromise: isWorldReadablePromise,
120+
guestJoinAllowed: false,
121+
singleRoomId: this._singleRoomId,
122+
}));
123+
}
113124
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import {UnknownRoomViewModel as BaseUnknownRoomViewModel} from "hydrogen-web/src/domain/session/room/UnknownRoomViewModel";
2+
import {SegmentType} from "hydrogen-web/src/domain/navigation";
3+
import {Segment} from "hydrogen-web/src/domain/navigation/Navigation";
4+
5+
export class UnknownRoomViewModel extends BaseUnknownRoomViewModel {
6+
private readonly _singleRoomId: any;
7+
8+
constructor(options) {
9+
super(options);
10+
this._singleRoomId = options.singleRoomId;
11+
}
12+
13+
get navigation() {
14+
return super.navigation;
15+
}
16+
17+
get urlRouter() {
18+
return super.urlRouter;
19+
}
20+
21+
get closeUrl() {
22+
if (this._singleRoomId) {
23+
const path = this.navigation.path.with(new Segment<SegmentType>("session"));
24+
return this.urlRouter.urlForPath(path);
25+
}
26+
27+
return super.closeUrl;
28+
}
29+
}

0 commit comments

Comments
 (0)