diff --git a/src/main.ts b/src/main.ts index bbdb19d58d2bd78d0b2bda8af490a4f7d7577e7d..8bb132635d01195056c3f08e6fe8fa3115ac3185 100644 --- a/src/main.ts +++ b/src/main.ts @@ -41,6 +41,7 @@ async function main() { platform.setNavigation(navigation); const urlRouter = createRouter({ navigation, history: platform.history }); const rootViewModel = new RootViewModel(config, {platform, navigation, urlCreator: urlRouter}); + rootViewModel.start(); const rootView = new RootView(rootViewModel); root.appendChild(rootView.mount()); } @@ -55,8 +56,15 @@ function allowsChild(parent, child) { } } -(window as any).sendViewChangeToParent = function (view: "timeline" | "start" | "account-setup") { - window.parent?.postMessage(view); +(window as any).sendViewChangeToParent = function (view: "timeline" | "account-setup") { + window.parent?.postMessage({ + action: "resize-iframe", + view + }); +}; + +(window as any).sendMinimizeToParent = function () { + window.parent?.postMessage({ action: "minimize" }); }; main(); diff --git a/src/ui/views/AccountSetupView.ts b/src/ui/views/AccountSetupView.ts index 4b76ccb56dcf838dcc168926d06d358b81b6079f..9586fa4eeaa76071ca1b7a804bac41ebfa2c7eb3 100644 --- a/src/ui/views/AccountSetupView.ts +++ b/src/ui/views/AccountSetupView.ts @@ -29,7 +29,7 @@ class PolicyAgreementView extends TemplateView<AccountSetupViewModel> { t.div( { 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") ]), ]); diff --git a/src/ui/views/ChatterboxView.ts b/src/ui/views/ChatterboxView.ts index 584b09e6e085ab6426aeb402d602b45b082fdb17..b188ef1d5e0490b40f0511b123aad1b23b30da9d 100644 --- a/src/ui/views/ChatterboxView.ts +++ b/src/ui/views/ChatterboxView.ts @@ -39,7 +39,7 @@ class RoomHeaderView extends TemplateView<ChatterboxViewModel> { t.view(new AvatarView(vm.roomViewModel, 30)), t.div({ className: "RoomHeaderView_name" }, vm => vm.roomViewModel.name), 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() }) ]), ]); } diff --git a/src/viewmodels/AccountSetupViewModel.ts b/src/viewmodels/AccountSetupViewModel.ts index c43b47bbc69f51f854575a0b286b1749d1a50cd0..a774c1f63953f1bfb923e9521ca1f02ac7b55a43 100644 --- a/src/viewmodels/AccountSetupViewModel.ts +++ b/src/viewmodels/AccountSetupViewModel.ts @@ -64,10 +64,6 @@ export class AccountSetupViewModel extends ViewModel { } } - dismiss() { - this.navigation.push("start"); - } - private get _homeserver(): string { return this._config.homeserver; } diff --git a/src/viewmodels/ChatterboxViewModel.ts b/src/viewmodels/ChatterboxViewModel.ts index 0241eb29738cd39f3a1aa84e55e2c91ade57b042..e1d52e870243d41e300b5a3a0427a08e4890c286 100644 --- a/src/viewmodels/ChatterboxViewModel.ts +++ b/src/viewmodels/ChatterboxViewModel.ts @@ -51,10 +51,6 @@ export class ChatterboxViewModel extends ViewModel { return promise; } - minimize() { - this.navigation.push("start"); - } - get timelineViewModel() { return this._roomViewModel?.timelineViewModel; } diff --git a/src/viewmodels/RootViewModel.ts b/src/viewmodels/RootViewModel.ts index 5f63909b50423adf9570782b3dc64cfd921fd5ac..120714830478aee8eeb1541591c4a88ae208f906 100644 --- a/src/viewmodels/RootViewModel.ts +++ b/src/viewmodels/RootViewModel.ts @@ -11,7 +11,7 @@ export class RootViewModel extends ViewModel { private _client: typeof Client; private _chatterBoxViewModel?: ChatterboxViewModel; private _accountSetupViewModel?: AccountSetupViewModel; - private _activeSection: string = "start"; + private _activeSection?: string; constructor(config: IChatterboxConfig, options: Options) { super(options); @@ -23,7 +23,6 @@ export class RootViewModel extends ViewModel { private _setupNavigation() { this.navigation.observe("account-setup").subscribe(() => this._showAccountSetup()); this.navigation.observe("timeline").subscribe((loginPromise) => this._showTimeline(loginPromise)); - this.navigation.observe("start").subscribe(() => this._showStartButton()); } async start() { @@ -63,11 +62,6 @@ export class RootViewModel extends ViewModel { this.emitChange("activeSection"); } - private _showStartButton() { - this._activeSection = "start"; - this.emitChange("activeSection"); - } - /** * Try to start Hydrogen based on an existing hydrogen session. * If multiple sessions exist, this method chooses the most recent one.