Skip to content

Commit

Permalink
make join functional + fix room id being passed to delete during dispose
Browse files Browse the repository at this point in the history
  • Loading branch information
ashfame committed Feb 23, 2023
1 parent e9261e5 commit 10415d1
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 2 deletions.
28 changes: 27 additions & 1 deletion src/domain/session/room/WorldReadableRoomViewModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,41 @@ export class WorldReadableRoomViewModel extends RoomViewModel {
constructor(options) {
options.room.isWorldReadable = true;
super(options);
this._room = options.room;
this._session = options.session;
this._error = null;
this._busy = false;
}

get kind() {
return "preview";
}

get busy() {
return this._busy;
}

async join() {
this._busy = true;
this.emitChange("busy");
try {
const roomId = await this._session.joinRoom(this._room.id);
await this._session.deleteWorldReadableRoomData(this._room.id);
// navigate to roomId if we were at the alias
// so we're subscribed to the right room status
// and we'll switch to the room view model once
// the join is synced
this.navigation.push("room", roomId);
// keep busy on true while waiting for the join to sync
} catch (err) {
this._error = err;
this._busy = false;
this.emitChange("error");
}
}

dispose() {
super.dispose();
void this._session.deleteWorldReadableRoomData(this.roomIdOrAlias);
void this._session.deleteWorldReadableRoomData(this._room.id);
}
}
6 changes: 5 additions & 1 deletion src/platform/web/ui/session/room/WorldReadableRoomView.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,11 @@ export class WorldReadableRoomView extends TemplateView {
}),
t.div({className: "WorldReadableRoomComposerView"}, [
t.h3(vm => vm.i18n`Join the room to participate`),
t.button({className: "joinRoomButton", onClick: () => vm.join()}, vm.i18n`Join Room`)
t.button({
className: "joinRoomButton",
onClick: () => vm.join(),
disabled: vm => vm.busy,
}, vm.i18n`Join Room`)
])
])
]);
Expand Down

0 comments on commit 10415d1

Please sign in to comment.