Skip to content

Commit

Permalink
Fixed download logic
Browse files Browse the repository at this point in the history
  • Loading branch information
ansxuman committed Nov 30, 2024
1 parent c68c553 commit 3ba7441
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions docs/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ prefersDark.addEventListener('change', (e) => {
}
});

let currentVersion = '';

async function updateVersion() {
try {
const response = await fetch('https://api.github.com/repos/ansxuman/clave/releases/latest');
Expand All @@ -39,9 +41,9 @@ async function updateVersion() {
throw new Error('Invalid release data');
}

const versionNumber = data.tag_name.replace(/^v/, '');
if (versionNumber) {
updateDownloadLinks(versionNumber);
currentVersion = data.tag_name.replace(/^v/, '');
if (currentVersion) {
updateDownloadLinks(currentVersion);
}
} catch (error) {
console.error('Failed to fetch version:', error);
Expand Down Expand Up @@ -70,13 +72,13 @@ document.querySelectorAll('.download-button').forEach(button => {
gtag('event', 'download', {
'event_category': 'App',
'event_label': button.getAttribute('data-platform'),
'value': versionNumber
'value': currentVersion
});
}
});
});

document.querySelectorAll('a[href^="#"]').forEach(anchor => {
document.querySelectorAll('nav a[href^="#"]').forEach(anchor => {
anchor.addEventListener('click', function (e) {
e.preventDefault();
const target = document.querySelector(this.getAttribute('href'));
Expand Down

0 comments on commit 3ba7441

Please # to comment.