Skip to content

Commit

Permalink
feat: Navigate to upload error screen when an error is detected
Browse files Browse the repository at this point in the history
  • Loading branch information
LunarX committed Nov 8, 2024
1 parent c809b93 commit 453f46f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,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,7 +81,8 @@ fun UploadProgressScreen(
@Composable
private fun HandleProgressState(
uiState: () -> UploadProgressUiState,
navigateToUploadSuccess: (String) -> Unit
navigateToUploadSuccess: (String) -> Unit,
navigateToUploadError: () -> Unit,
) {
val currentUiState = uiState()
LaunchedEffect(uiState()) {
Expand All @@ -89,7 +91,7 @@ private fun HandleProgressState(
navigateToUploadSuccess(currentUiState.transferLink)
}
is UploadProgressUiState.Cancelled -> {
// TODO: navigate to failure screen
navigateToUploadError()
}
else -> Unit
}
Expand Down

0 comments on commit 453f46f

Please sign in to comment.