From f1e9798d91b10b7d30265305f5c26e3985669ef9 Mon Sep 17 00:00:00 2001
From: Benjamin Auder <benjamin.auder@somewhere>
Date: Sun, 15 Mar 2020 16:50:39 +0100
Subject: [PATCH] Attempt to show something on Hall page when no live
 challenges or games

---
 client/src/views/Hall.vue | 27 +++++++++++++++++++++++++--
 1 file changed, 25 insertions(+), 2 deletions(-)

diff --git a/client/src/views/Hall.vue b/client/src/views/Hall.vue
index 4c73df22..fa42e836 100644
--- a/client/src/views/Hall.vue
+++ b/client/src/views/Hall.vue
@@ -394,8 +394,31 @@ export default {
       dispCorr || localStorage.getItem("type-challenges") || "live";
     const showGtype =
       dispCorr || localStorage.getItem("type-games") || "live";
-    this.setDisplay("c", showCtype);
-    this.setDisplay("g", showGtype);
+    this.setDisplay('c', showCtype);
+    this.setDisplay('g', showGtype);
+    // Attempt to show something (at least a few correspondance challenges):
+    setTimeout(
+      () => {
+        const types = ["corr", "live"];
+        for (let i of [0,1]) {
+          if (
+            this.gdisplay == types[i] &&
+            this.games.length > 0 &&
+            this.games.every(g => g.type == types[1-i])
+          ) {
+            this.setDisplay('g', types[1-i]);
+          }
+          if (
+            this.cdisplay == types[i] &&
+            this.challenges.length > 0 &&
+            this.challenges.every(c => c.type == types[1-i])
+          ) {
+            this.setDisplay('c', types[1-i]);
+          }
+        }
+      },
+      1500
+    );
   },
   beforeDestroy: function() {
     document.removeEventListener('visibilitychange', this.visibilityChange);
-- 
2.44.0