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
|
|
@ -16,6 +16,7 @@ import kotlinx.coroutines.flow.Flow
|
|||
import kotlinx.coroutines.flow.MutableStateFlow
|
||||
import kotlinx.coroutines.flow.StateFlow
|
||||
import kotlinx.coroutines.flow.map
|
||||
import kotlinx.coroutines.flow.update
|
||||
import kotlinx.coroutines.withContext
|
||||
import kotlinx.serialization.Serializable
|
||||
import org.jellyfin.sdk.Jellyfin
|
||||
|
|
@ -298,6 +299,16 @@ class ServerRepository
|
|||
response.content
|
||||
}
|
||||
|
||||
/**
|
||||
* Update [currentUserDto] by querying the server
|
||||
*/
|
||||
suspend fun updateUserDto() {
|
||||
val userDto by apiClient.userApi.getCurrentUser()
|
||||
_currentUserDto.update {
|
||||
if (it?.id == userDto.id && currentUser?.id == userDto.id) userDto else it
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
fun getServerSharedPreferences(context: Context): SharedPreferences =
|
||||
context.getSharedPreferences(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue