Improved lifecycle handling & code clean up (#1653)
## Description Add some improvements related to life cycle handling whenever the app is resumed: - Refreshing the server-side user config - Refreshing the home page automatically Also 401/403 errors accessing recording folders will be skipped since this typically means the user lost access while the app was running. Refreshing the server-side user config (above) will also help with this. Finally, there's some general code clean up in `MainActivity` to move non-UI related code out of Compose. ### Related issues Closes #1647 ### Testing Emulator ## Screenshots N/A ## AI or LLM usage None
This commit is contained in:
parent
ad25a1eb7c
commit
0e62b9582c
4 changed files with 161 additions and 104 deletions
|
|
@ -26,6 +26,7 @@ import kotlinx.coroutines.flow.combine
|
|||
import kotlinx.coroutines.flow.update
|
||||
import kotlinx.coroutines.withContext
|
||||
import org.jellyfin.sdk.api.client.ApiClient
|
||||
import org.jellyfin.sdk.api.client.exception.InvalidStatusException
|
||||
import org.jellyfin.sdk.api.client.extensions.liveTvApi
|
||||
import org.jellyfin.sdk.api.client.extensions.userViewsApi
|
||||
import org.jellyfin.sdk.model.api.CollectionType
|
||||
|
|
@ -132,13 +133,22 @@ class NavDrawerService
|
|||
.content.items
|
||||
val recordingFolders =
|
||||
if (tvAccess) {
|
||||
api.liveTvApi
|
||||
.getRecordingFolders(userId = userId)
|
||||
.content.items
|
||||
.map { it.id }
|
||||
.toSet()
|
||||
try {
|
||||
api.liveTvApi
|
||||
.getRecordingFolders(userId = userId)
|
||||
.content.items
|
||||
.map { it.id }
|
||||
.toSet()
|
||||
} catch (ex: InvalidStatusException) {
|
||||
if (ex.status == 401 || ex.status == 403) {
|
||||
Timber.w("Got HTTP %s querying for recording folders", ex.status)
|
||||
emptySet()
|
||||
} else {
|
||||
throw ex
|
||||
}
|
||||
}
|
||||
} else {
|
||||
setOf()
|
||||
emptySet()
|
||||
}
|
||||
val libraries =
|
||||
userViews
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue