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:
Damontecres 2026-07-01 19:18:16 -04:00 • committed by GitHub
parent ad25a1eb7c
commit 0e62b9582c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 161 additions and 104 deletions

View file

@ -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