mirror of
https://github.com/vector-im/hydrogen-web.git
synced 2024-12-23 11:35:04 +01:00
ask to join when room id is unknown
This commit is contained in:
parent
3acb3bb48c
commit
03be63572d
@ -65,6 +65,8 @@ export class RoomViewModelObservable extends ObservableValue {
|
|||||||
return this._sessionViewModel._createRoomViewModel(this.id);
|
return this._sessionViewModel._createRoomViewModel(this.id);
|
||||||
} else if (status.archived) {
|
} else if (status.archived) {
|
||||||
return await this._sessionViewModel._createArchivedRoomViewModel(this.id);
|
return await this._sessionViewModel._createArchivedRoomViewModel(this.id);
|
||||||
|
} else {
|
||||||
|
return this._sessionViewModel._createUnknownRoomViewModel(this.id);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -17,6 +17,7 @@ limitations under the License.
|
|||||||
|
|
||||||
import {LeftPanelViewModel} from "./leftpanel/LeftPanelViewModel.js";
|
import {LeftPanelViewModel} from "./leftpanel/LeftPanelViewModel.js";
|
||||||
import {RoomViewModel} from "./room/RoomViewModel.js";
|
import {RoomViewModel} from "./room/RoomViewModel.js";
|
||||||
|
import {UnknownRoomViewModel} from "./room/UnknownRoomViewModel.js";
|
||||||
import {InviteViewModel} from "./room/InviteViewModel.js";
|
import {InviteViewModel} from "./room/InviteViewModel.js";
|
||||||
import {LightboxViewModel} from "./room/LightboxViewModel.js";
|
import {LightboxViewModel} from "./room/LightboxViewModel.js";
|
||||||
import {SessionStatusViewModel} from "./SessionStatusViewModel.js";
|
import {SessionStatusViewModel} from "./SessionStatusViewModel.js";
|
||||||
@ -162,6 +163,13 @@ export class SessionViewModel extends ViewModel {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_createUnknownRoomViewModel(roomIdOrAlias) {
|
||||||
|
return new UnknownRoomViewModel(this.childOptions({
|
||||||
|
roomIdOrAlias,
|
||||||
|
session: this._sessionContainer.session,
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
async _createArchivedRoomViewModel(roomId) {
|
async _createArchivedRoomViewModel(roomId) {
|
||||||
const room = await this._sessionContainer.session.loadArchivedRoom(roomId);
|
const room = await this._sessionContainer.session.loadArchivedRoom(roomId);
|
||||||
if (room) {
|
if (room) {
|
||||||
|
59
src/domain/session/room/UnknownRoomViewModel.js
Normal file
59
src/domain/session/room/UnknownRoomViewModel.js
Normal file
@ -0,0 +1,59 @@
|
|||||||
|
/*
|
||||||
|
Copyright 2020 Bruno Windels <bruno@windels.cloud>
|
||||||
|
Copyright 2020 The Matrix.org Foundation C.I.C.
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import {ViewModel} from "../../ViewModel.js";
|
||||||
|
|
||||||
|
export class UnknownRoomViewModel extends ViewModel {
|
||||||
|
constructor(options) {
|
||||||
|
super(options);
|
||||||
|
const {roomIdOrAlias, session} = options;
|
||||||
|
this._session = session;
|
||||||
|
this._roomIdOrAlias = roomIdOrAlias;
|
||||||
|
this._error = null;
|
||||||
|
this._busy = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
get error() {
|
||||||
|
return this._error?.message;
|
||||||
|
}
|
||||||
|
|
||||||
|
get description() {
|
||||||
|
return this.i18n`You are currently not in ${this._roomIdOrAlias}. Want to join it?`;
|
||||||
|
}
|
||||||
|
|
||||||
|
async join() {
|
||||||
|
this._busy = true;
|
||||||
|
this.emitChange("busy");
|
||||||
|
try {
|
||||||
|
const roomId = await this._session.joinRoom(this._roomIdOrAlias);
|
||||||
|
// navigate to roomId if we were at the alias
|
||||||
|
this.navigation.push("room", roomId);
|
||||||
|
} catch (err) {
|
||||||
|
this._error = err;
|
||||||
|
this._busy = false;
|
||||||
|
this.emitChange("error");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
get busy() {
|
||||||
|
return this._busy;
|
||||||
|
}
|
||||||
|
|
||||||
|
get kind() {
|
||||||
|
return "unknown";
|
||||||
|
}
|
||||||
|
}
|
@ -17,6 +17,7 @@ limitations under the License.
|
|||||||
|
|
||||||
import {LeftPanelView} from "./leftpanel/LeftPanelView.js";
|
import {LeftPanelView} from "./leftpanel/LeftPanelView.js";
|
||||||
import {RoomView} from "./room/RoomView.js";
|
import {RoomView} from "./room/RoomView.js";
|
||||||
|
import {UnknownRoomView} from "./room/UnknownRoomView.js";
|
||||||
import {InviteView} from "./room/InviteView.js";
|
import {InviteView} from "./room/InviteView.js";
|
||||||
import {LightboxView} from "./room/LightboxView.js";
|
import {LightboxView} from "./room/LightboxView.js";
|
||||||
import {TemplateView} from "../general/TemplateView.js";
|
import {TemplateView} from "../general/TemplateView.js";
|
||||||
@ -43,8 +44,10 @@ export class SessionView extends TemplateView {
|
|||||||
} else if (vm.currentRoomViewModel) {
|
} else if (vm.currentRoomViewModel) {
|
||||||
if (vm.currentRoomViewModel.kind === "invite") {
|
if (vm.currentRoomViewModel.kind === "invite") {
|
||||||
return new InviteView(vm.currentRoomViewModel);
|
return new InviteView(vm.currentRoomViewModel);
|
||||||
} else {
|
} else if (vm.currentRoomViewModel.kind === "room") {
|
||||||
return new RoomView(vm.currentRoomViewModel);
|
return new RoomView(vm.currentRoomViewModel);
|
||||||
|
} else {
|
||||||
|
return new UnknownRoomView(vm.currentRoomViewModel);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
return new StaticView(t => t.div({className: "room-placeholder"}, t.h2(vm.i18n`Choose a room on the left side.`)));
|
return new StaticView(t => t.div({className: "room-placeholder"}, t.h2(vm.i18n`Choose a room on the left side.`)));
|
||||||
|
38
src/platform/web/ui/session/room/UnknownRoomView.js
Normal file
38
src/platform/web/ui/session/room/UnknownRoomView.js
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
/*
|
||||||
|
Copyright 2020 Bruno Windels <bruno@windels.cloud>
|
||||||
|
Copyright 2020 The Matrix.org Foundation C.I.C.
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import {TemplateView} from "../../general/TemplateView.js";
|
||||||
|
import {Popup} from "../../general/Popup.js";
|
||||||
|
import {Menu} from "../../general/Menu.js";
|
||||||
|
import {TimelineList} from "./TimelineList.js";
|
||||||
|
import {TimelineLoadingView} from "./TimelineLoadingView.js";
|
||||||
|
import {MessageComposer} from "./MessageComposer.js";
|
||||||
|
import {RoomArchivedView} from "./RoomArchivedView.js";
|
||||||
|
import {AvatarView} from "../../avatar.js";
|
||||||
|
|
||||||
|
export class UnknownRoomView extends TemplateView {
|
||||||
|
render(t, vm) {
|
||||||
|
return t.main({className: "UnknownRoomView middle"}, [
|
||||||
|
t.h2(vm.description),
|
||||||
|
t.div(t.button({
|
||||||
|
className: "button-action primary",
|
||||||
|
onClick: () => vm.join(),
|
||||||
|
disabled: vm => vm.busy,
|
||||||
|
}, vm.i18n`Join room`))
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user