From 099e37d646c040b3b76dd3025fae56fb8384f7cd Mon Sep 17 00:00:00 2001
From: Henrik Askjer <henrik.askjer@uib.no>
Date: Sat, 25 Dec 2021 14:22:35 +0100
Subject: [PATCH] fix welcome page routing bugs

---
 src/components/DictionaryView.vue | 37 ++++++++++++++++++++++---------
 1 file changed, 26 insertions(+), 11 deletions(-)

diff --git a/src/components/DictionaryView.vue b/src/components/DictionaryView.vue
index 2708dd7b..aa01d852 100644
--- a/src/components/DictionaryView.vue
+++ b/src/components/DictionaryView.vue
@@ -38,7 +38,7 @@
       <Article :key="article_key" :article="article" @article-click="article_link_click" />
 
     </div>
-    <div class="welcome" v-if="! (article || error || total_results() || waiting)">
+    <div class="welcome" v-if="!(article || error || $route.name || waiting)">
       <div class="monthly" :class="$vuetify.breakpoint.name">
         <div>
           <Article :article="monthly_bm" @article-click="article_link_click" />
@@ -307,7 +307,18 @@ export default {
         return total
       }
     },
-  
+    load_monthly_bm: function() {
+      let self = this
+      axios.get(ARTICLE_ENDPOINT + 'bm/article/5607.json').then(function(response){
+        self.monthly_bm = Object.assign(response.data, {dictionary: 'bm'})
+      })
+    },  
+    load_monthly_nn: function() {
+      let self = this
+      axios.get(ARTICLE_ENDPOINT + 'nn/article/78569.json').then(function(response){
+        self.monthly_nn = Object.assign(response.data, {dictionary: 'nn'})
+      })
+    },
     error_message: function(error) {    
       this.search_results = {}
       console.log(error)
@@ -520,15 +531,8 @@ export default {
                               selected: self.selected,
                               inflection_suggestions: self.inflection_suggestions}, '')
 
-
-      // words of the month
-      axios.get(ARTICLE_ENDPOINT + 'bm/article/5607.json').then(function(response){
-        self.monthly_bm = Object.assign(response.data, {dictionary: 'bm'})
-      })
-
-      axios.get(ARTICLE_ENDPOINT + 'nn/article/78569.json').then(function(response){
-        self.monthly_nn = Object.assign(response.data, {dictionary: 'nn'})
-      })
+        self.load_monthly_bm()
+        self.load_monthly_nn()
 
       }
     }).catch(function(error){
@@ -539,7 +543,18 @@ export default {
       self.waiting_for_articles = false
     })
   },
+  watch: {
+    $route(to, from) {
+      console.log("TO", to)
+      console.log("FROM", from)
+      if (!to.name) {
+        this.load_monthly_bm()
+        this.load_monthly_nn()
+      }
+    }
+  },
   created: function() {
+    console.log("CREATED")
     let self = this
     window.onpopstate = function (event) {
       if (event.state) {
-- 
GitLab