From b0d88a0a376e85efd45679eef8c3d89c0d661ee7 Mon Sep 17 00:00:00 2001 From: chylex <info@chylex.com> Date: Thu, 9 Mar 2017 00:52:12 +0100 Subject: [PATCH] Add a safeguard to updater to open browser if the update installer is missing --- Resources/Scripts/update.js | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/Resources/Scripts/update.js b/Resources/Scripts/update.js index e24cb14c..1f1ae803 100644 --- a/Resources/Scripts/update.js +++ b/Resources/Scripts/update.js @@ -19,6 +19,11 @@ // const updateCheckUrlAll = "https://api.github.com/repos/chylex/TweetDuck/releases"; + // + // Constant: Fallback url in case the update installer file is missing. + // + const updateDownloadFallback = "https://tweetduck.chylex.com/#download"; + // // Function: Creates the update notification element. Removes the old one if already exists. // @@ -28,7 +33,7 @@ var ele = $("#tweetduck-update"); var existed = ele.length > 0; - if (existed > 0){ + if (existed){ ele.remove(); } @@ -106,7 +111,13 @@ buttonDiv.children(".tdu-btn-download").click(function(){ ele.remove(); - $TDU.onUpdateAccepted(version, download); + + if (download){ + $TDU.onUpdateAccepted(version, download); + } + else{ + $TDU.openBrowser(updateDownloadFallback); + } }); buttonDiv.children(".tdu-btn-unsupported").click(function(){ @@ -139,7 +150,7 @@ var hasUpdate = tagName !== versionTag && tagName !== dismissedVersionTag && release.assets.length > 0; if (hasUpdate){ - var obj = release.assets.find(asset => asset.name === updateFileName) || release.assets[0]; + var obj = release.assets.find(asset => asset.name === updateFileName) || { browser_download_url: "" }; displayNotification(tagName, obj.browser_download_url); }