Skip to content

Commit

Permalink
Update downloads.js
Browse files Browse the repository at this point in the history
  • Loading branch information
SuperDragonXD authored Apr 7, 2024
1 parent 775b228 commit 1e38922
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions assets/downloads.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Octokit } from "https://esm.sh/octokit";

const octokit = new Octokit();

const getLatestRelease = async (repo) => {
const getLatestRelease = async (repo, index = 0) => {
const urlParams = new URLSearchParams(window.location.search);

if (urlParams.get("disabledownloads")) {
Expand All @@ -16,7 +16,7 @@ const getLatestRelease = async (repo) => {
owner: "lawnchairlauncher",
repo: repo,
})
).data[0];
).data[index];
return {
version: data.name.substr(data.name.search(/\d/)),
downloadLink: data.assets[0].browser_download_url,
Expand All @@ -29,16 +29,20 @@ const getLatestRelease = async (repo) => {
const repoNames = ["lawnchair", "lawnfeed", "lawnicons"];

const majorVersions = {
lawnchair: "12",
lawnchair: "14",
lawnfeed: "3",
lawnicons: "1",
lawnicons: "2",
};

const getFallbackDownloadLink = (repo) =>
`https://github.com/lawnchairlauncher/${repo}/releases`;

// todo futureproof
repoNames.forEach(async (it) => {
const latestRelease = await getLatestRelease(it);
let latestRelease = await getLatestRelease(it);
if (latestRelease.version == "y") {
latestRelease = await getLatestRelease(it, 1)
}
const versionSpan = document.querySelector(`#js-${it}-version`);
const downloadAnchor = document.querySelector(`#js-${it}-download`);
versionSpan.textContent = `Version ${
Expand All @@ -49,4 +53,4 @@ repoNames.forEach(async (it) => {
: getFallbackDownloadLink(it);
versionSpan.classList.remove("disabled");
downloadAnchor.classList.remove("disabled");
});
});

0 comments on commit 1e38922

Please sign in to comment.