Skip to content

Commit

Permalink
Fixes #7: Hide dev release if it's the same version as stable
Browse files Browse the repository at this point in the history
  • Loading branch information
gornostal committed Aug 27, 2021
1 parent 0b95812 commit d22fafe
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions assets/js/releases.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand All @@ -36,10 +38,10 @@ jQuery(function($) {
.addClass(!selectStable ? 'fa-dot-circle' : 'fa-circle');

$('#stable-release + .option-info')
.html('<b>v' + (stable.name || stable.tag_name) + '</b> from ' + new Date(stable.published_at).toLocaleDateString() +
.html('<b>v' + stableVer + '</b> from ' + new Date(stable.published_at).toLocaleDateString() +
' <a href="' + stable.html_url + '">Release notes</a>.');
$('#dev-release + .option-info')
.html('<b>v' + (dev.name || dev.tag_name) + '</b> from ' + new Date(dev.published_at).toLocaleDateString() +
.html('<b>v' + devVer + '</b> from ' + new Date(dev.published_at).toLocaleDateString() +
' <a href="' + dev.html_url + '">Release notes</a>.');

var aurLink = selectStable ? 'https://aur.archlinux.org/packages/ulauncher/' :
Expand Down Expand Up @@ -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();
}
}

/**
Expand Down

0 comments on commit d22fafe

Please sign in to comment.