Skip to content
Snippets Groups Projects
Commit f97a4849 authored by RMidhunSuresh's avatar RMidhunSuresh
Browse files

Show a disabled view

parent 42f846d1
No related branches found
No related tags found
No related merge requests found
...@@ -38,7 +38,7 @@ export class ChatterboxView extends TemplateView<ChatterboxViewModel> { ...@@ -38,7 +38,7 @@ export class ChatterboxView extends TemplateView<ChatterboxViewModel> {
), ),
t.mapView( t.mapView(
(vm) => vm.messageComposerViewModel, (vm) => vm.messageComposerViewModel,
(vm) => (vm ? new MessageComposer(vm) : null) (vm) => (vm.kind === "composer" ? new MessageComposer(vm) : new WaitingForOperatorJoinView())
), ),
t.view(new FooterView(vm.footerViewModel)), t.view(new FooterView(vm.footerViewModel)),
]); ]);
...@@ -65,3 +65,14 @@ class RoomHeaderView extends TemplateView<ChatterboxViewModel> { ...@@ -65,3 +65,14 @@ class RoomHeaderView extends TemplateView<ChatterboxViewModel> {
]); ]);
} }
} }
class WaitingForOperatorJoinView extends TemplateView {
render(t) {
return t.div({ className: "WaitingForOperatorJoinView" }, [
t.div({ className: "FakeComposerContainer" }, [
t.span("Waiting for operator to join "),
t.div({ className: "loader" })]
)]
);
}
}
...@@ -25,6 +25,7 @@ export class ChatterboxViewModel extends ViewModel { ...@@ -25,6 +25,7 @@ export class ChatterboxViewModel extends ViewModel {
super(options); super(options);
this._client = options.client; this._client = options.client;
this._loginPromise = options.loginPromise; this._loginPromise = options.loginPromise;
this.emitOnRoomViewModelChange = this.emitOnRoomViewModelChange.bind(this);
} }
async load() { async load() {
...@@ -48,11 +49,17 @@ export class ChatterboxViewModel extends ViewModel { ...@@ -48,11 +49,17 @@ export class ChatterboxViewModel extends ViewModel {
tileClassForEntry: createCustomTileClassForEntry(this._session.userId), tileClassForEntry: createCustomTileClassForEntry(this._session.userId),
}))); })));
await this._roomViewModel.load(); await this._roomViewModel.load();
this._roomViewModel.on("change", this.emitOnRoomViewModelChange);
this.emitChange("roomViewModel");
}
private emitOnRoomViewModelChange() {
this.emitChange("roomViewModel"); this.emitChange("roomViewModel");
} }
private async createRoomWithUserSpecifiedInConfig() { private async createRoomWithUserSpecifiedInConfig() {
const userId = this._options.config["invite_user"]; const userId = this._options.config["invite_user"];
const ownUserId = this._session.userId;
let room = await this.findPreviouslyCreatedRoom(); let room = await this.findPreviouslyCreatedRoom();
if (room) { if (room) {
// we already have a room with this user // we already have a room with this user
...@@ -67,6 +74,15 @@ export class ChatterboxViewModel extends ViewModel { ...@@ -67,6 +74,15 @@ export class ChatterboxViewModel extends ViewModel {
alias: undefined, alias: undefined,
avatar: undefined, avatar: undefined,
invites: [userId], invites: [userId],
powerLevelContentOverride: {
users: {
[userId]: 100,
[ownUserId]: 60
},
events: {
"m.room.message": 80,
}
},
}); });
const roomStatusObservable = await this._session.observeRoomStatus(roomBeingCreated.id); const roomStatusObservable = await this._session.observeRoomStatus(roomBeingCreated.id);
await roomStatusObservable.waitFor(status => status === (RoomStatus.BeingCreated | RoomStatus.Replaced)).promise; await roomStatusObservable.waitFor(status => status === (RoomStatus.BeingCreated | RoomStatus.Replaced)).promise;
...@@ -107,7 +123,7 @@ export class ChatterboxViewModel extends ViewModel { ...@@ -107,7 +123,7 @@ export class ChatterboxViewModel extends ViewModel {
return promise; return promise;
} }
private async findPreviouslyCreatedRoom(): Promise<string | null> { private async findPreviouslyCreatedRoom(): Promise<any | null> {
const createdRoomId = await this.platform.settingsStorage.getString("created-room-id"); const createdRoomId = await this.platform.settingsStorage.getString("created-room-id");
const lastKnownInviteUserId = await this.platform.settingsStorage.getString("invite-user"); const lastKnownInviteUserId = await this.platform.settingsStorage.getString("invite-user");
const currentInviteUserId = this._options.config["invite_user"]; const currentInviteUserId = this._options.config["invite_user"];
...@@ -117,6 +133,11 @@ export class ChatterboxViewModel extends ViewModel { ...@@ -117,6 +133,11 @@ export class ChatterboxViewModel extends ViewModel {
return null; return null;
} }
dispose() {
super.dispose();
this._roomViewModel.off("change", this.emitOnRoomViewModelChange);
}
minimize() { minimize() {
(window as any).sendMinimizeToParent(); (window as any).sendMinimizeToParent();
this.navigation.push("minimize"); this.navigation.push("minimize");
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment