From 46dda62e20cf45614ece8e79a1e965cf256ce6f4 Mon Sep 17 00:00:00 2001 From: Midhun Suresh <midhunr@element.io> Date: Thu, 27 Jan 2022 16:56:22 +0530 Subject: [PATCH] Refactor resize code --- src/main.ts | 5 ++--- src/ui/views/RootView.ts | 4 +--- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/src/main.ts b/src/main.ts index 0d634d4..bbdb19d 100644 --- a/src/main.ts +++ b/src/main.ts @@ -55,9 +55,8 @@ function allowsChild(parent, child) { } } -function sendFrameResizeEventToParent(view: string) { +(window as any).sendViewChangeToParent = function (view: "timeline" | "start" | "account-setup") { window.parent?.postMessage(view); -} +}; -(window as any).sendFrameResizeEventToParent = sendFrameResizeEventToParent; main(); diff --git a/src/ui/views/RootView.ts b/src/ui/views/RootView.ts index 434b9e9..1d101a2 100644 --- a/src/ui/views/RootView.ts +++ b/src/ui/views/RootView.ts @@ -10,15 +10,13 @@ export class RootView extends TemplateView<RootViewModel> { render(t, vm: RootViewModel) { return t.mapView(vm => vm.activeSection, section => { + (window as any).sendViewChangeToParent(section); switch(section) { case "start": - window.sendFrameResizeEventToParent("start"); return new StartView(vm); case "account-setup": - window.sendFrameResizeEventToParent("account-setup"); return new AccountSetupView(vm.accountSetupViewModel); case "timeline": - window.sendFrameResizeEventToParent("timeline"); return new ChatterboxView(vm.chatterboxViewModel); } return null; -- GitLab