Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 4 additions & 8 deletions app/routes/crate/version.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,23 +45,19 @@ export default Route.extend({
.then(versions => {
const latestStableVersion = versions.find(version => {
// Find the latest version that is stable AND not-yanked.
if (!isUnstableVersion(version.get('num')) && !version.get('yanked')) {
return version;
}
return !isUnstableVersion(version.get('num')) && !version.get('yanked');
});

if (latestStableVersion == null) {
// Cannot find any version that is stable AND not-yanked.
// The fact that "maxVersion" itself cannot be found means that
// we have to fall back to the latest one that is unstable....
const latestUnyankedVersion = versions.find(version => {
// Find the latest version that is stable AND not-yanked.
if (!version.get('yanked')) {
return version;
}
// Find the latest version that is not-yanked.
return !version.get('yanked');
});

if (latestStableVersion == null) {
if (latestUnyankedVersion == null) {
// There's not even any unyanked version...
params.version_num = maxVersion;
} else {
Expand Down