Skip to content

Commit

Permalink
adding windows support to the download button and also fixing a bug w…
Browse files Browse the repository at this point in the history
…here platforms were not being detected properly resulting in all platforms getting a email prompt
  • Loading branch information
software-person committed May 10, 2024
1 parent 933abde commit ee34d9b
Showing 1 changed file with 13 additions and 15 deletions.
28 changes: 13 additions & 15 deletions src/components/Download.astro
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@
return e => {
e.preventDefault();
e.stopImmediatePropagation();

if (selected.asset) {
const dl = document.createElement('a')
dl.setAttribute('href', selected.asset.browser_download_url)
Expand Down Expand Up @@ -111,8 +110,8 @@

const getRelease = async () => {
const release = await fetch('https://api.github.com/repos/noop-inc/desktop/releases/latest',
{
headers: {
{
headers: {
Accept: 'application/vnd.github+json',
'X-GitHub-Api-Version': '2022-11-28'
}
Expand All @@ -136,7 +135,8 @@
case ('macIntel'):
searchTerm = `Noop-${version}-x64.dmg`;
break;
case ('windows'):
case ('win'):
searchTerm = `Noop-${version}.Setup.exe`;
break;
case ('linux'):
break;
Expand All @@ -161,7 +161,7 @@
},
win: {
label: 'Windows',
supported: false,
supported: true,
releases: [
{label: 'Windows'}
]},
Expand All @@ -175,36 +175,34 @@
}

const rel = await getRelease()

const {name, assets } = rel

Object.keys(detectables).forEach(k => detectables[k].releases.forEach(rel => Object.assign(rel, {asset: findAsset(k, name, assets), name: k})))

const selected = detectables[os]

if (!selected) {

} else if (selected.supported) {
if (selected && selected.supported) {
detectedOptions.innerHTML = ''
selected.releases.forEach(rel => {
selected.releases.forEach(s => {
const relBtn = defaultButton.cloneNode()

const label = document.createElement('span')
label.textContent = `Download Noop ${rel.label}`
label.textContent = `Download Noop ${s.label}`

const icon = document.createElement('span')
icon.innerHTML = icons[rel.name]
icon.innerHTML = icons[s.name]
icon.setAttribute('class', 'mr-2')


relBtn.textContent = ''
relBtn.appendChild(icon)
relBtn.appendChild(label)
relBtn.setAttribute('href', rel.asset.browser_download_url)
relBtn.addEventListener('click', dlButtonHandler(rel, selected))
relBtn.setAttribute('href', s.asset.browser_download_url)
relBtn.addEventListener('click', dlButtonHandler(rel, s))
detectedOptions.appendChild(relBtn)
})
} else {
} else if (selected) {
detectedOptions.innerHTML = ''

notifyHeadline.textContent = `${selected.label} support isn't available today, but we are working on it.`
Expand Down

0 comments on commit ee34d9b

Please sign in to comment.