keep releases listing dynamically updated

This commit is contained in:
Daniel Micay 2021-02-08 04:19:29 -05:00
parent 07326f706b
commit 7b0fda4129
2 changed files with 36 additions and 26 deletions

View File

@ -4,10 +4,14 @@ const baseUrl = "https://releases.grapheneos.org/";
const versionBaseUrl = "https://github.com/GrapheneOS/platform_manifest/releases/tag/"; const versionBaseUrl = "https://github.com/GrapheneOS/platform_manifest/releases/tag/";
const devices = ["redfin", "bramble", "sunfish", "coral", "flame", "bonito", "sargo", "crosshatch", "blueline", "taimen", "walleye"]; const devices = ["redfin", "bramble", "sunfish", "coral", "flame", "bonito", "sargo", "crosshatch", "blueline", "taimen", "walleye"];
const channels = ["stable", "beta"]; const channels = ["stable", "beta"];
const delayMs = 1000 * 60 * 5;
for (const channel of channels) { async function updateReleases() {
const requests = [];
for (const channel of channels) {
for (const device of devices) { for (const device of devices) {
fetch(baseUrl + device + "-" + channel).then(response => { requests.push(fetch(baseUrl + device + "-" + channel).then(response => {
if (!response.ok) { if (!response.ok) {
return Promise.reject(); return Promise.reject();
} }
@ -37,8 +41,14 @@ for (const channel of channels) {
links[4].innerText = updateFilename; links[4].innerText = updateFilename;
links[4].setAttribute("href", updateUrl); links[4].setAttribute("href", updateUrl);
}); }));
} }
}
await Promise.allSettled(requests);
setTimeout(updateReleases, delayMs);
} }
updateReleases();
// @license-end // @license-end

View File

@ -27,7 +27,7 @@
<link rel="stylesheet" href="/grapheneos.css?29"/> <link rel="stylesheet" href="/grapheneos.css?29"/>
<link rel="manifest" href="/manifest.webmanifest"/> <link rel="manifest" href="/manifest.webmanifest"/>
<link rel="license" href="/LICENSE.txt"/> <link rel="license" href="/LICENSE.txt"/>
<script type="module" src="/js/releases.js?13"></script> <script type="module" src="/js/releases.js?14"></script>
<script type="module" src="/js/redirect.js?9"></script> <script type="module" src="/js/redirect.js?9"></script>
</head> </head>
<body> <body>