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

More meaningful errors when adding repositories #537

Merged
merged 4 commits into from
Aug 4, 2023
Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -224,14 +224,31 @@ class ExtensionsFragment : Fragment() {
showToast(R.string.error_invalid_data, Toast.LENGTH_SHORT)
}
} else {
val repository = RepositoryManager.parseRepository(url)

// Exit if wrong repository
if (repository == null) {
showToast(R.string.no_repository_found_error, Toast.LENGTH_LONG)
return@ioSafe
}

val fixedName = if (!name.isNullOrBlank()) name
else RepositoryManager.parseRepository(url)?.name ?: "No name"
else repository.name

val newRepo = RepositoryData(fixedName, url)
RepositoryManager.addRepository(newRepo)
extensionViewModel.loadStats()
extensionViewModel.loadRepositories()
this@ExtensionsFragment.activity?.downloadAllPluginsDialog(url, fixedName)

val plugins = RepositoryManager.getRepoPlugins(url)
if (plugins.isNullOrEmpty()) {
showToast(R.string.no_plugins_found_error, Toast.LENGTH_LONG)
} else {
this@ExtensionsFragment.activity?.downloadAllPluginsDialog(
url,
fixedName
)
}
}
}
dialog.dismissSafe(activity)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,13 +86,17 @@ class PluginsViewModel : ViewModel() {
}.also { list ->
main {
showToast(
if (list.isEmpty()) {
txt(
when {
// No plugins at all
plugins.isEmpty() -> txt(
R.string.no_plugins_found_error,
)
// All plugins downloaded
list.isEmpty() -> txt(
R.string.batch_download_nothing_to_download_format,
txt(R.string.plugin)
)
} else {
txt(
else -> txt(
R.string.batch_download_start_format,
list.size,
txt(if (list.size == 1) R.string.plugin_singular else R.string.plugin)
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -572,6 +572,8 @@
<string name="batch_download_start_format" formatted="true">Started downloading %d %s…</string>
<string name="batch_download_finish_format" formatted="true">Downloaded %d %s</string>
<string name="batch_download_nothing_to_download_format" formatted="true">All %s already downloaded</string>
<string name="no_plugins_found_error">No plugins found in repository</string>
<string name="no_repository_found_error">Repository not found, check the URL and try VPN</string>
<string name="batch_download">Batch download</string>
<string name="plugin_singular">plugin</string>
<string name="plugin">plugins</string>
Expand Down
Loading