mirror of
https://github.com/Aviortheking/Neo-Store.git
synced 2025-04-23 03:12:15 +00:00
Fix: Parsing clipboard's content for repo URI (closes #244)
This commit is contained in:
parent
93dec1ed7a
commit
1750020e20
@ -66,13 +66,14 @@ data class Repository(
|
||||
|
||||
fun newRepository(
|
||||
address: String = "",
|
||||
fallbackName: String = "",
|
||||
fingerprint: String = "",
|
||||
authentication: String = "",
|
||||
): Repository {
|
||||
val name = try {
|
||||
URL(address).let { "${it.host}${it.path}" }
|
||||
} catch (e: Exception) {
|
||||
address
|
||||
fallbackName
|
||||
}
|
||||
return Repository(
|
||||
address = address,
|
||||
|
@ -151,7 +151,7 @@ class EditRepositorySheetX() : FullscreenBottomSheetDialogFragment(), RepoManage
|
||||
|
||||
override fun updateSheet() {
|
||||
val repository = viewModel.repo.value
|
||||
if (repository == null) {
|
||||
if (repository == null || repository.address == "") {
|
||||
val clipboardManager =
|
||||
requireContext().getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager
|
||||
val text = clipboardManager.primaryClip
|
||||
|
@ -63,7 +63,7 @@ class RepositoriesViewModelX(val repositoryDao: RepositoryDao) : ViewModel() {
|
||||
}
|
||||
|
||||
private suspend fun addNewRepository(): Long = withContext(Dispatchers.IO) {
|
||||
repositoryDao.insert(newRepository(address = "new repository"))
|
||||
repositoryDao.insert(newRepository(fallbackName = "new repository"))
|
||||
repositoryDao.latestAddedId()
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user