From 6d67677d6f8fe98acc87283e4f5c916222a5c5d1 Mon Sep 17 00:00:00 2001
From: RMidhunSuresh <hi@midhun.dev>
Date: Tue, 5 Jul 2022 12:52:39 +0530
Subject: [PATCH] Create and pass footer vm to everywhere needed

---
 src/viewmodels/AccountSetupViewModel.ts | 4 ++++
 src/viewmodels/ChatterboxViewModel.ts   | 4 ++++
 src/viewmodels/RootViewModel.ts         | 5 +++++
 3 files changed, 13 insertions(+)

diff --git a/src/viewmodels/AccountSetupViewModel.ts b/src/viewmodels/AccountSetupViewModel.ts
index aa76de7..3e83fa8 100644
--- a/src/viewmodels/AccountSetupViewModel.ts
+++ b/src/viewmodels/AccountSetupViewModel.ts
@@ -109,4 +109,8 @@ export class AccountSetupViewModel extends ViewModel {
     get privacyPolicyLink() {
         return this._privacyPolicyLink;
     }
+
+    get footerViewModel() {
+        return this.options.footerVM;
+    }
 }
diff --git a/src/viewmodels/ChatterboxViewModel.ts b/src/viewmodels/ChatterboxViewModel.ts
index 05844c7..2698e74 100644
--- a/src/viewmodels/ChatterboxViewModel.ts
+++ b/src/viewmodels/ChatterboxViewModel.ts
@@ -119,4 +119,8 @@ export class ChatterboxViewModel extends ViewModel {
     private get _session() {
         return this._client.session;
     }
+
+    get footerViewModel() {
+        return this.options.footerVM;
+    }
 }
diff --git a/src/viewmodels/RootViewModel.ts b/src/viewmodels/RootViewModel.ts
index 82e515c..a904c33 100644
--- a/src/viewmodels/RootViewModel.ts
+++ b/src/viewmodels/RootViewModel.ts
@@ -3,6 +3,7 @@ import { IChatterboxConfig } from "../types/IChatterboxConfig";
 import { ChatterboxViewModel } from "./ChatterboxViewModel";
 import "hydrogen-view-sdk/style.css";
 import { AccountSetupViewModel } from "./AccountSetupViewModel";
+import { FooterViewModel } from "./FooterViewModel";
 import { MessageFromParent } from "../observables/MessageFromParent";
 
 type Options = { platform: typeof Platform, navigation: typeof Navigation, urlCreator: ReturnType<typeof createRouter>, startMinimized: boolean };
@@ -16,12 +17,14 @@ export class RootViewModel extends ViewModel {
     private _messageFromParent: MessageFromParent = new MessageFromParent();
     private _startMinimized: boolean;
     private _isWatchingNotificationCount: boolean;
+    private _footerViewModel: FooterViewModel;
 
     constructor(config: IChatterboxConfig, options: Options) {
         super(options);
         this._startMinimized = options.startMinimized;
         this._config = config;
         this._client = new Client(this.platform);
+        this._footerViewModel = new FooterViewModel(this.childOptions({ config: this._config }));
         this._setupNavigation();
         this._messageFromParent.on("maximize", () => this.start());
         // Chatterbox can be minimized via the start button on the parent page!
@@ -60,6 +63,7 @@ export class RootViewModel extends ViewModel {
                     client: this._client,
                     config: this._config,
                     state: this._state,
+                    footerVM: this._footerViewModel,
                     loginPromise,
                 })
             ));
@@ -79,6 +83,7 @@ export class RootViewModel extends ViewModel {
                 client: this._client,
                 config: this._config,
                 state: this._state,
+                footerVM: this._footerViewModel,
             })
         ));
         this.emitChange("activeSection");
-- 
GitLab