refine unknown room view

This commit is contained in:
Bruno Windels 2021-05-18 11:46:55 +02:00
parent c04a8140a3
commit 2cf100efaa
3 changed files with 30 additions and 11 deletions

View file

@ -22,7 +22,7 @@ export class UnknownRoomViewModel extends ViewModel {
super(options); super(options);
const {roomIdOrAlias, session} = options; const {roomIdOrAlias, session} = options;
this._session = session; this._session = session;
this._roomIdOrAlias = roomIdOrAlias; this.roomIdOrAlias = roomIdOrAlias;
this._error = null; this._error = null;
this._busy = false; this._busy = false;
} }
@ -31,15 +31,11 @@ export class UnknownRoomViewModel extends ViewModel {
return this._error?.message; return this._error?.message;
} }
get description() {
return this.i18n`You are currently not in ${this._roomIdOrAlias}. Want to join it?`;
}
async join() { async join() {
this._busy = true; this._busy = true;
this.emitChange("busy"); this.emitChange("busy");
try { try {
const roomId = await this._session.joinRoom(this._roomIdOrAlias); const roomId = await this._session.joinRoom(this.roomIdOrAlias);
// navigate to roomId if we were at the alias // navigate to roomId if we were at the alias
this.navigation.push("room", roomId); this.navigation.push("room", roomId);
} catch (err) { } catch (err) {

View file

@ -911,3 +911,21 @@ button.link {
.RoomArchivedView h3 { .RoomArchivedView h3 {
margin: 0; margin: 0;
} }
.UnknownRoomView {
align-items: center;
justify-content: center;
text-align: center;
padding: 16px;
box-sizing: border-box;
}
.UnknownRoomView h2 {
word-break: break-all;
word-break: break-word;
}
.UnknownRoomView button {
max-width: 200px;
width: 100%;
}

View file

@ -26,13 +26,18 @@ import {AvatarView} from "../../avatar.js";
export class UnknownRoomView extends TemplateView { export class UnknownRoomView extends TemplateView {
render(t, vm) { render(t, vm) {
return t.main({className: "UnknownRoomView middle"}, [ return t.main({className: "UnknownRoomView middle"}, t.div([
t.h2(vm.description), t.h2([
t.div(t.button({ vm.i18n`You are currently not in ${vm.roomIdOrAlias}.`,
t.br(),
vm.i18n`Want to join it?`
]),
t.button({
className: "button-action primary", className: "button-action primary",
onClick: () => vm.join(), onClick: () => vm.join(),
disabled: vm => vm.busy, disabled: vm => vm.busy,
}, vm.i18n`Join room`)) }, vm.i18n`Join room`),
]); t.if(vm => vm.error, t => t.p({className: "error"}, vm.error))
]));
} }
} }