Skip to content

Commit

Permalink
fix: maintain major filter across channel switch (#38)
Browse files Browse the repository at this point in the history
  • Loading branch information
MarshallOfSound authored Jan 17, 2024
1 parent 484719c commit b39c021
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
7 changes: 5 additions & 2 deletions src/routes/releases.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,13 +78,16 @@ router.get(
const releases = await getReleasesOrUpdate();
const { page, limit, version } = req.query;
const releasesFromChannel = releases.filter(filter);
const major = Number(version);
let major = parseInt(version, 10);
if (isNaN(major) || major < 0) {
major = null;
}
const majors = releasesFromChannel.reduce((acc, val) => {
acc.add(semver.major(val.version));
return acc;
}, new Set());
const releasesFromMajor = releasesFromChannel.filter((release) => {
if (Number.isInteger(major) && major >= 0) {
if (major) {
return semver.major(release.version) === major;
} else {
return true;
Expand Down
6 changes: 3 additions & 3 deletions src/views/releases.handlebars
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,19 @@
<div class="releases__filter-container">
<strong>Filter by channel</strong>
<div class="release-channel-selector-container">
<a class="releases__filter-link" href="/releases/stable">
<a class="releases__filter-link" href="/releases/stable?version={{major}}">
<div class="releases__filter {{#ifEquals channel "stable"}} releases__filter--selected{{/ifEquals}}">
<span class="releases__filter-name"><i class="fas fa-clock"></i>&nbsp;Stable</span>
<p class="releases__filter-description">Regular, supported releases</p>
</div>
</a>
<a class="releases__filter-link" href="/releases/prerelease">
<a class="releases__filter-link" href="/releases/prerelease?version={{major}}">
<div class="releases__filter {{#ifEquals channel "prerelease"}} releases__filter--selected{{/ifEquals}}">
<span class="releases__filter-name"><i class="fas fa-flask"></i>&nbsp;Prerelease</span>
<p class="releases__filter-description">Test upcoming changes</p>
</div>
</a>
<a class="releases__filter-link" href="/releases/nightly">
<a class="releases__filter-link" href="/releases/nightly?version={{major}}">
<div class="releases__filter {{#ifEquals channel "nightly"}} releases__filter--selected{{/ifEquals}}">
<span class="releases__filter-name"><i class="fas fa-calendar"></i>&nbsp;Nightly</span>
<p class="releases__filter-description">Experiment with the latest features</p>
Expand Down

0 comments on commit b39c021

Please sign in to comment.