From d22fafe9b5bf9aa23dbc05d2d984ae09a0f5ae65 Mon Sep 17 00:00:00 2001 From: Aleksandr Gornostal Date: Fri, 27 Aug 2021 19:48:11 +0300 Subject: [PATCH] Fixes #7: Hide dev release if it's the same version as stable --- assets/js/releases.js | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/assets/js/releases.js b/assets/js/releases.js index 4e949f9..5140126 100644 --- a/assets/js/releases.js +++ b/assets/js/releases.js @@ -22,6 +22,8 @@ jQuery(function($) { console.error('Releases not found'); return; } + const stableVer = stable.name || stable.tag_name; + const devVer = dev.name || dev.tag_name; var stableSelected = getDefaultReleaseOption() == 'stable'; @@ -36,10 +38,10 @@ jQuery(function($) { .addClass(!selectStable ? 'fa-dot-circle' : 'fa-circle'); $('#stable-release + .option-info') - .html('v' + (stable.name || stable.tag_name) + ' from ' + new Date(stable.published_at).toLocaleDateString() + + .html('v' + stableVer + ' from ' + new Date(stable.published_at).toLocaleDateString() + ' Release notes.'); $('#dev-release + .option-info') - .html('v' + (dev.name || dev.tag_name) + ' from ' + new Date(dev.published_at).toLocaleDateString() + + .html('v' + devVer + ' from ' + new Date(dev.published_at).toLocaleDateString() + ' Release notes.'); var aurLink = selectStable ? 'https://aur.archlinux.org/packages/ulauncher/' : @@ -75,6 +77,21 @@ jQuery(function($) { $('#dev-release').click(function(){ selectRelease(false); }); + + // hide dev release if it's the same as stable + const verRegex = /^(\d+)\.(\d+)\.(\d+)/ + const stableMatch = stableVer.match(verRegex) + const devMatch = devVer.match(verRegex) + const stMaj = parseInt(stableMatch[1], 10) + const stMin = parseInt(stableMatch[2], 10) + const stPatch = parseInt(stableMatch[3], 10) + const devMaj = parseInt(devMatch[1], 10) + const devMin = parseInt(devMatch[2], 10) + const devPatch = parseInt(devMatch[3], 10) + const isDevHigher = devMaj > stMaj || (devMaj > stMaj && devMin > stMin) || (devMaj > stMaj && devMin > stMin && devPatch > stPatch) + if (!isDevHigher && stableSelected) { + $('.channel-options').hide(); + } } /**