mirror of
https://github.com/rommapp/romm.git
synced 2026-12-03 10:33:22 +01:00
wrap version check in try catch
This commit is contained in:
@@ -15,19 +15,23 @@ function dismissVersionBanner() {
|
||||
latestVersionDismissed.value = true;
|
||||
}
|
||||
onMounted(async () => {
|
||||
const response = await fetch(
|
||||
"https://api.github.com/repos/rommapp/romm/releases/latest",
|
||||
);
|
||||
const json = await response.json();
|
||||
GITHUB_VERSION.value = json.tag_name;
|
||||
const publishedAt = new Date(json.published_at);
|
||||
latestVersionDismissed.value =
|
||||
// Hide if the version is not valid
|
||||
!semver.valid(VERSION) ||
|
||||
// Hide if the version is the same as the dismissed version
|
||||
json.tag_name === localStorage.getItem("dismissedVersion") ||
|
||||
// Hide if the version is less than 2 hours old
|
||||
publishedAt.getTime() + 2 * 60 * 60 * 1000 > Date.now();
|
||||
try {
|
||||
const response = await fetch(
|
||||
"https://api.github.com/repos/rommapp/romm/releases/latest",
|
||||
);
|
||||
const json = await response.json();
|
||||
GITHUB_VERSION.value = json.tag_name;
|
||||
const publishedAt = new Date(json.published_at);
|
||||
latestVersionDismissed.value =
|
||||
// Hide if the version is not valid
|
||||
!semver.valid(VERSION) ||
|
||||
// Hide if the version is the same as the dismissed version
|
||||
json.tag_name === localStorage.getItem("dismissedVersion") ||
|
||||
// Hide if the version is less than 2 hours old
|
||||
publishedAt.getTime() + 2 * 60 * 60 * 1000 > Date.now();
|
||||
} catch (error) {
|
||||
console.error("Failed to fetch latest version from Github", error);
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user