Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Windows DL button and bug fix #159

Merged
merged 1 commit into from
May 10, 2024
Merged
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
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
Loading