chore: add checks in the url fetch step of the installFromGitHub

This commit is contained in:
Yi
2025-01-09 11:52:44 +08:00
parent eaf1177cd4
commit a7f0933e55
3 changed files with 26 additions and 7 deletions

View File

@ -86,13 +86,28 @@ const InstallFromGitHub: React.FC<InstallFromGitHubProps> = ({ updatePayload, on
})
return
}
await fetchReleases(owner, repo).then((fetchedReleases) => {
setState(prevState => ({
...prevState,
releases: fetchedReleases,
step: InstallStepFromGitHub.selectPackage,
}))
})
try {
const fetchedReleases = await fetchReleases(owner, repo)
if (fetchedReleases.length > 0) {
setState(prevState => ({
...prevState,
releases: fetchedReleases,
step: InstallStepFromGitHub.selectPackage,
}))
}
else {
Toast.notify({
type: 'error',
message: t('plugin.error.noReleasesFound'),
})
}
}
catch (error) {
Toast.notify({
type: 'error',
message: t('plugin.error.fetchReleasesError'),
})
}
}
const handleError = (e: any, isInstall: boolean) => {