mirror of
https://github.com/nextcloud/talk-android.git
synced 2024-11-21 20:45:29 +03:00
fix error handling for shared items.
Before this with http 406 it threw a NPE and UI was shown as loading state. With this commit an empty list is returned when there is a http error. http 406 happens for federated rooms for now. So it might be that Shared items screen will be hidden by additional commits. Signed-off-by: Marcel Hibbe <dev@mhibbe.de>
This commit is contained in:
parent
5fead79743
commit
611dcb7911
2 changed files with 14 additions and 8 deletions
|
@ -188,15 +188,20 @@ class SharedItemsRepositoryImpl @Inject constructor(private val ncApi: NcApi, pr
|
|||
1
|
||||
).map {
|
||||
val types = mutableSetOf<SharedItemType>()
|
||||
val typeMap = it.body()!!.ocs!!.data!!
|
||||
for (t in typeMap) {
|
||||
if (t.value.isNotEmpty()) {
|
||||
try {
|
||||
types += SharedItemType.typeFor(t.key)
|
||||
} catch (e: IllegalArgumentException) {
|
||||
Log.w(TAG, "Server responds an unknown shared item type: ${t.key}")
|
||||
|
||||
if (it.code() == HTTP_OK) {
|
||||
val typeMap = it.body()!!.ocs!!.data!!
|
||||
for (t in typeMap) {
|
||||
if (t.value.isNotEmpty()) {
|
||||
try {
|
||||
types += SharedItemType.typeFor(t.key)
|
||||
} catch (e: IllegalArgumentException) {
|
||||
Log.w(TAG, "Server responds an unknown shared item type: ${t.key}")
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
Log.e(TAG, "Failed to getSharedItemsOverview")
|
||||
}
|
||||
|
||||
types.toSet()
|
||||
|
@ -213,6 +218,7 @@ class SharedItemsRepositoryImpl @Inject constructor(private val ncApi: NcApi, pr
|
|||
|
||||
companion object {
|
||||
const val BATCH_SIZE: Int = 28
|
||||
private const val HTTP_OK: Int = 200
|
||||
private val TAG = SharedItemsRepositoryImpl::class.simpleName
|
||||
}
|
||||
}
|
||||
|
|
|
@ -81,7 +81,7 @@ class SharedItemsViewModel @Inject constructor(
|
|||
}
|
||||
|
||||
override fun onError(e: Throwable) {
|
||||
Log.d(TAG, "An error occurred: $e")
|
||||
Log.e(TAG, "An error occurred when loading available types", e)
|
||||
}
|
||||
|
||||
override fun onComplete() {
|
||||
|
|
Loading…
Reference in a new issue