From 12650448543fc3d3ebf6dc63754b68b6090e81e5 Mon Sep 17 00:00:00 2001
From: Kavin <20838718+FireMasterK@users.noreply.github.com>
Date: Mon, 20 Feb 2023 12:01:28 +0000
Subject: [PATCH] Move frontend config loading to App.vue.

---
 src/App.vue                        | 11 ++++++++++-
 src/components/FooterComponent.vue | 29 ++++++++++++++++++++---------
 2 files changed, 30 insertions(+), 10 deletions(-)

diff --git a/src/App.vue b/src/App.vue
index 551267a5..49004ade 100644
--- a/src/App.vue
+++ b/src/App.vue
@@ -9,7 +9,7 @@
             </router-view>
         </div>
 
-        <FooterComponent />
+        <FooterComponent :config="config" />
     </div>
 </template>
 
@@ -27,6 +27,7 @@ export default {
     data() {
         return {
             theme: "dark",
+            config: null,
         };
     },
     mounted() {
@@ -35,6 +36,14 @@ export default {
             this.setTheme();
         });
 
+        this.fetchJson(this.authApiUrl() + "/config")
+            .then(config => {
+                this.config = config;
+            })
+            .then(() => {
+                this.onConfigLoaded();
+            });
+
         if ("indexedDB" in window) {
             const request = indexedDB.open("piped-db", 5);
             request.onupgradeneeded = ev => {
diff --git a/src/components/FooterComponent.vue b/src/components/FooterComponent.vue
index 38212347..c267b440 100644
--- a/src/components/FooterComponent.vue
+++ b/src/components/FooterComponent.vue
@@ -29,6 +29,15 @@
 
 <script>
 export default {
+<<<<<<< Updated upstream
+=======
+    props: {
+        config: {
+            type: Object,
+            required: true,
+        },
+    },
+>>>>>>> Stashed changes
     data() {
         return {
             donationHref: null,
@@ -36,16 +45,18 @@ export default {
             privacyPolicyHref: null,
         };
     },
-    mounted() {
-        this.fetchConfig();
+    props: {
+        config: {
+            type: Object,
+        },
     },
-    methods: {
-        async fetchConfig() {
-            this.fetchJson(this.apiUrl() + "/config").then(config => {
-                this.donationHref = config?.donationUrl;
-                this.statusPageHref = config?.statusPageUrl;
-                this.privacyPolicyHref = config?.privacyPolicyUrl;
-            });
+    watch: {
+        config: {
+            handler() {
+                this.donationHref = this.config?.donationUrl;
+                this.statusPageHref = this.config?.statusPageUrl;
+                this.privacyPolicyHref = this.config?.privacyPolicyUrl;
+            },
         },
     },
 };