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

@ -44,6 +44,7 @@ import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.DpSize
import androidx.compose.ui.unit.dp
import androidx.hilt.lifecycle.viewmodel.compose.hiltViewModel
import androidx.lifecycle.compose.LifecycleStartEffect
import androidx.tv.material3.MaterialTheme
import androidx.tv.material3.Text
import com.github.damontecres.wholphin.R
@ -103,8 +104,9 @@ fun HomePage(
playlistViewModel: AddPlaylistViewModel = hiltViewModel(),
) {
val context = LocalContext.current
LaunchedEffect(Unit) {
LifecycleStartEffect(Unit) {
viewModel.init()
onStopOrDispose { }
}
val state by viewModel.state.collectAsState()
val loading = state.loadingState