From 20f9d764a737a7db7474c8718906a30cea189651 Mon Sep 17 00:00:00 2001
From: Henrik Askjer <henrik.askjer@uib.no>
Date: Tue, 16 Nov 2021 16:48:27 +0100
Subject: [PATCH] fix language switching bug

---
 src/components/DictionaryView.vue | 15 +++++++--------
 1 file changed, 7 insertions(+), 8 deletions(-)

diff --git a/src/components/DictionaryView.vue b/src/components/DictionaryView.vue
index 22410b20..5124f34f 100644
--- a/src/components/DictionaryView.vue
+++ b/src/components/DictionaryView.vue
@@ -159,18 +159,17 @@ function navigate_to_search(self, query) {
 function load_articles(self, query, offset, n, dict) {
 
   let article_IDs = self.article_info.articles[dict]
+  if (article_IDs)
+  {
   if (offset > article_IDs.length) {
     n = 0
   }
   else if (offset + n > article_IDs.length) {
     n = n + (article_IDs.length - n)
   }
-  console.log("n, offset", n, offset)
 
   if (n > 0 && (self.lang == dict || self.lang == "bm,nn")) {
     article_IDs = article_IDs.slice(offset, offset + n)
-    console.log("ARTICLES",dict, article_IDs)
-    console.log("OFFSET offset+N", offset, offset+n)
     return Promise.all(article_IDs.map((article_id) => {
       return axios.get(`${ARTICLE_ENDPOINT}${dict}/article/${article_id}.json`)
 
@@ -217,11 +216,8 @@ function load_articles(self, query, offset, n, dict) {
       self.connection_error(error)
     })
   }
-  else {
-    return Promise.resolve()
   }
-  
-  
+    return Promise.resolve()
 }
 
 
@@ -251,7 +247,10 @@ function navigate_to_query(self, word) {
             })
           
         }).catch(error =>{
+          console.log(error)
+          self.waiting_for_articles = false
           self.connection_error(error)
+          
 
         })
 }
@@ -436,7 +435,7 @@ export default {
       console.log("MAX", this.max_scroll)
       let offset = 10 * this.page
       this.page += 1
-      if (!this.waiting_for_articles) {
+      if (!self.waiting_for_articles) {
         self.waiting_for_articles = true
         console.log("PARAMS", this.query.q, offset, 10)     
         Promise.all([
-- 
GitLab