Skip to content
Snippets Groups Projects
Commit 2072f9c1 authored by Midhun Suresh's avatar Midhun Suresh
Browse files

Move start button to parent

parent 22aa79bd
No related branches found
No related tags found
No related merge requests found
...@@ -41,6 +41,7 @@ async function main() { ...@@ -41,6 +41,7 @@ async function main() {
platform.setNavigation(navigation); platform.setNavigation(navigation);
const urlRouter = createRouter({ navigation, history: platform.history }); const urlRouter = createRouter({ navigation, history: platform.history });
const rootViewModel = new RootViewModel(config, {platform, navigation, urlCreator: urlRouter}); const rootViewModel = new RootViewModel(config, {platform, navigation, urlCreator: urlRouter});
rootViewModel.start();
const rootView = new RootView(rootViewModel); const rootView = new RootView(rootViewModel);
root.appendChild(rootView.mount()); root.appendChild(rootView.mount());
} }
...@@ -55,8 +56,15 @@ function allowsChild(parent, child) { ...@@ -55,8 +56,15 @@ function allowsChild(parent, child) {
} }
} }
(window as any).sendViewChangeToParent = function (view: "timeline" | "start" | "account-setup") { (window as any).sendViewChangeToParent = function (view: "timeline" | "account-setup") {
window.parent?.postMessage(view); window.parent?.postMessage({
action: "resize-iframe",
view
});
};
(window as any).sendMinimizeToParent = function () {
window.parent?.postMessage({ action: "minimize" });
}; };
main(); main();
...@@ -29,7 +29,7 @@ class PolicyAgreementView extends TemplateView<AccountSetupViewModel> { ...@@ -29,7 +29,7 @@ class PolicyAgreementView extends TemplateView<AccountSetupViewModel> {
t.div( t.div(
{ className: "PolicyAgreementView-btn-collection" }, { className: "PolicyAgreementView-btn-collection" },
[ [
t.button( { onClick: () => vm.dismiss(), className: "button-action secondary PolicyAgreementView-cancel", }, "Cancel"), t.button( { onClick: () => (window as any).sendMinimizeToParent(), className: "button-action secondary PolicyAgreementView-cancel", }, "Cancel"),
t.button( { onClick: () => vm.completeRegistration(), className: "PolicyAgreementView-next button-action primary", }, "Next") t.button( { onClick: () => vm.completeRegistration(), className: "PolicyAgreementView-next button-action primary", }, "Next")
]), ]),
]); ]);
......
...@@ -39,7 +39,7 @@ class RoomHeaderView extends TemplateView<ChatterboxViewModel> { ...@@ -39,7 +39,7 @@ class RoomHeaderView extends TemplateView<ChatterboxViewModel> {
t.view(new AvatarView(vm.roomViewModel, 30)), t.view(new AvatarView(vm.roomViewModel, 30)),
t.div({ className: "RoomHeaderView_name" }, vm => vm.roomViewModel.name), t.div({ className: "RoomHeaderView_name" }, vm => vm.roomViewModel.name),
t.div({ className: "RoomHeaderView_menu" }, [ t.div({ className: "RoomHeaderView_menu" }, [
t.button({ className: "RoomHeaderView_menu_minimize", onClick: () => vm.minimize() }) t.button({ className: "RoomHeaderView_menu_minimize", onClick: () => (window as any).sendMinimizeToParent() })
]), ]),
]); ]);
} }
......
...@@ -64,10 +64,6 @@ export class AccountSetupViewModel extends ViewModel { ...@@ -64,10 +64,6 @@ export class AccountSetupViewModel extends ViewModel {
} }
} }
dismiss() {
this.navigation.push("start");
}
private get _homeserver(): string { private get _homeserver(): string {
return this._config.homeserver; return this._config.homeserver;
} }
......
...@@ -51,10 +51,6 @@ export class ChatterboxViewModel extends ViewModel { ...@@ -51,10 +51,6 @@ export class ChatterboxViewModel extends ViewModel {
return promise; return promise;
} }
minimize() {
this.navigation.push("start");
}
get timelineViewModel() { get timelineViewModel() {
return this._roomViewModel?.timelineViewModel; return this._roomViewModel?.timelineViewModel;
} }
......
...@@ -11,7 +11,7 @@ export class RootViewModel extends ViewModel { ...@@ -11,7 +11,7 @@ export class RootViewModel extends ViewModel {
private _client: typeof Client; private _client: typeof Client;
private _chatterBoxViewModel?: ChatterboxViewModel; private _chatterBoxViewModel?: ChatterboxViewModel;
private _accountSetupViewModel?: AccountSetupViewModel; private _accountSetupViewModel?: AccountSetupViewModel;
private _activeSection: string = "start"; private _activeSection?: string;
constructor(config: IChatterboxConfig, options: Options) { constructor(config: IChatterboxConfig, options: Options) {
super(options); super(options);
...@@ -23,7 +23,6 @@ export class RootViewModel extends ViewModel { ...@@ -23,7 +23,6 @@ export class RootViewModel extends ViewModel {
private _setupNavigation() { private _setupNavigation() {
this.navigation.observe("account-setup").subscribe(() => this._showAccountSetup()); this.navigation.observe("account-setup").subscribe(() => this._showAccountSetup());
this.navigation.observe("timeline").subscribe((loginPromise) => this._showTimeline(loginPromise)); this.navigation.observe("timeline").subscribe((loginPromise) => this._showTimeline(loginPromise));
this.navigation.observe("start").subscribe(() => this._showStartButton());
} }
async start() { async start() {
...@@ -63,11 +62,6 @@ export class RootViewModel extends ViewModel { ...@@ -63,11 +62,6 @@ export class RootViewModel extends ViewModel {
this.emitChange("activeSection"); this.emitChange("activeSection");
} }
private _showStartButton() {
this._activeSection = "start";
this.emitChange("activeSection");
}
/** /**
* Try to start Hydrogen based on an existing hydrogen session. * Try to start Hydrogen based on an existing hydrogen session.
* If multiple sessions exist, this method chooses the most recent one. * If multiple sessions exist, this method chooses the most recent one.
......
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