mirror of https://github.com/readrops/Readrops.git
Improve error handling when adding a new feed in FeedTab
This commit is contained in:
parent
e176cdbdb1
commit
a3c9e0a89e
|
@ -21,6 +21,7 @@ import kotlinx.coroutines.flow.update
|
|||
import kotlinx.coroutines.launch
|
||||
import org.koin.core.component.KoinComponent
|
||||
import org.koin.core.component.get
|
||||
import java.net.UnknownHostException
|
||||
|
||||
@OptIn(ExperimentalCoroutinesApi::class)
|
||||
class FeedViewModel(
|
||||
|
@ -161,6 +162,7 @@ class FeedViewModel(
|
|||
}
|
||||
|
||||
else -> viewModelScope.launch(Dispatchers.IO) {
|
||||
try {
|
||||
if (localRSSDataSource.isUrlRSSResource(url)) {
|
||||
// TODO add support for all account types
|
||||
repository?.insertNewFeeds(listOf(url))
|
||||
|
@ -180,6 +182,12 @@ class FeedViewModel(
|
|||
closeDialog()
|
||||
}
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
when (e) {
|
||||
is UnknownHostException -> _addFeedDialogState.update { it.copy(error = TextFieldError.UnreachableUrl) }
|
||||
else -> _addFeedDialogState.update { it.copy(error = TextFieldError.NoRSSFeed) }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -304,4 +312,3 @@ class FeedViewModel(
|
|||
|
||||
// add/update folder
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue