From a6e0c6f2e5a3d91912f71d6258ae4a12f139dfc5 Mon Sep 17 00:00:00 2001 From: Pieter Verschaffelt Date: Wed, 9 Dec 2020 09:23:55 +0100 Subject: [PATCH] Fix error handling on HomePage when internet unavailable --- src/components/pages/HomePage.vue | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/src/components/pages/HomePage.vue b/src/components/pages/HomePage.vue index 82133b4c..f3955076 100644 --- a/src/components/pages/HomePage.vue +++ b/src/components/pages/HomePage.vue @@ -143,12 +143,7 @@ export default class HomePage extends Vue { if (!HomePage.downloadCheckPerformed) { HomePage.downloadCheckPerformed = true; shouldUpdate = await this.checkStaticDatabaseUpdate(); - - const githubCommunicator = new GitHubCommunicator(); - this.updateAvailable = Utils.isVersionLargerThan( - await githubCommunicator.getMostRecentVersion(), - this.version - ); + this.updateAvailable = await this.checkApplicationUpdateAvailable(); } this.loadingApplication = false; @@ -171,6 +166,24 @@ export default class HomePage extends Vue { "The application will work without these files, but will be slower or less accurate than usual." ); } + return false; + } + + private async checkApplicationUpdateAvailable(): Promise { + try { + const githubCommunicator = new GitHubCommunicator(); + return Utils.isVersionLargerThan( + await githubCommunicator.getMostRecentVersion(), + this.version + ); + } catch (err) { + console.warn(err); + this.showError( + "Could not connect to GitHub and check for new updates. Make sure you're connected to the internet " + + "and retry." + ); + } + return false; } private async updateStaticDatabase(): Promise {