Skip to content
Snippets Groups Projects
RootView.ts 1023 B
Newer Older
David Langley's avatar
David Langley committed
Copyright 2025 New Vector Ltd.
Copyright 2022 The Matrix.org Foundation C.I.C.

David Langley's avatar
David Langley committed
SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial
Please see LICENSE files in the repository root for full details.
Midhun Suresh's avatar
Midhun Suresh committed
import { TemplateView } from "hydrogen-view-sdk";
import { RootViewModel } from "../../viewmodels/RootViewModel";
import { AccountSetupView } from "./AccountSetupView";
import { ChatterboxView } from "./ChatterboxView";

export class RootView extends TemplateView<RootViewModel> {
Midhun Suresh's avatar
Midhun Suresh committed
    constructor(value) {
        super(value);
    }

    render(t, vm: RootViewModel) {
Midhun Suresh's avatar
Midhun Suresh committed
        return t.mapView(vm => vm.activeSection, section => {
Midhun Suresh's avatar
Midhun Suresh committed
            (window as any).sendViewChangeToParent(section);
Midhun Suresh's avatar
Midhun Suresh committed
            switch(section) {
                case "account-setup":
                    return new AccountSetupView(vm.accountSetupViewModel);
                case "timeline":
                    return new ChatterboxView(vm.chatterboxViewModel);
            }
            return null;
        })
    }
}