Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Navigate to upload error screen when an error is detected #161

Merged
merged 2 commits into from
Nov 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ fun NewTransferNavHost(navController: NavHostController, closeActivity: () -> Un
navigateToUploadSuccess = { transferLink ->
navController.navigate(UploadSuccessDestination(args.transferType, transferLink))
},
navigateToUploadError = { navController.navigate(UploadErrorDestination) },
closeActivity = closeActivity
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ fun UploadProgressScreen(
uploadProgressViewModel: UploadProgressViewModel = hiltViewModel<UploadProgressViewModel>(),
totalSizeInBytes: Long,
navigateToUploadSuccess: (String) -> Unit,
navigateToUploadError: () -> Unit,
closeActivity: () -> Unit,
) {
val uiState by uploadProgressViewModel.transferProgressUiState.collectAsStateWithLifecycle()
Expand All @@ -63,7 +64,7 @@ fun UploadProgressScreen(
uploadProgressViewModel.trackUploadProgress()
}

HandleProgressState({ uiState }, navigateToUploadSuccess)
HandleProgressState({ uiState }, navigateToUploadSuccess, navigateToUploadError)

UploadProgressScreen(
progressState = { uiState },
Expand All @@ -80,17 +81,14 @@ fun UploadProgressScreen(
@Composable
private fun HandleProgressState(
uiState: () -> UploadProgressUiState,
navigateToUploadSuccess: (String) -> Unit
navigateToUploadSuccess: (String) -> Unit,
navigateToUploadError: () -> Unit,
) {
val currentUiState = uiState()
LaunchedEffect(uiState()) {
when (currentUiState) {
is UploadProgressUiState.Success -> {
navigateToUploadSuccess(currentUiState.transferLink)
}
is UploadProgressUiState.Cancelled -> {
// TODO: navigate to failure screen
}
is UploadProgressUiState.Success -> navigateToUploadSuccess(currentUiState.transferLink)
is UploadProgressUiState.Cancelled -> navigateToUploadError()
else -> Unit
}
}
Expand Down
Loading