From: Benjamin Auder Date: Sun, 15 Mar 2020 15:50:39 +0000 (+0100) Subject: Attempt to show something on Hall page when no live challenges or games X-Git-Url: https://git.auder.net/variants/img/current/assets/DESCRIPTION?a=commitdiff_plain;h=f1e9798d91b10b7d30265305f5c26e3985669ef9;p=vchess.git Attempt to show something on Hall page when no live challenges or games --- 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);