Skip to content

Commit

Permalink
feat: When retrying the uploading transfer, we keep transfer data whe…
Browse files Browse the repository at this point in the history
…n going back to ImportFiles instead of resetting it
  • Loading branch information
KevinBoulongne committed Dec 20, 2024
1 parent f3a74d3 commit 4ffd5a8
Show file tree
Hide file tree
Showing 9 changed files with 39 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,10 @@ fun NewTransferNavHost(navController: NavHostController, closeActivity: () -> Un
)
}
composable<UploadErrorDestination> {
UploadErrorScreen(navigateToImportFiles = { navController.navigate(ImportFilesDestination) })
UploadErrorScreen(
retryTransfer = { /* TODO */ },
navigateBackToImportFiles = { navController.popBackStack(route = ImportFilesDestination, inclusive = false) },
)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,25 +21,30 @@ import androidx.compose.material3.Surface
import androidx.compose.runtime.Composable
import androidx.compose.ui.res.stringResource
import com.infomaniak.swisstransfer.R
import com.infomaniak.swisstransfer.ui.components.BottomStickyButtonScaffold
import com.infomaniak.swisstransfer.ui.components.BrandTopAppBar
import com.infomaniak.swisstransfer.ui.components.EmptyState
import com.infomaniak.swisstransfer.ui.components.LargeButton
import com.infomaniak.swisstransfer.ui.components.*
import com.infomaniak.swisstransfer.ui.images.AppImages.AppIllus
import com.infomaniak.swisstransfer.ui.images.illus.uploadError.GhostMagnifyingGlassQuestionMark
import com.infomaniak.swisstransfer.ui.theme.SwissTransferTheme
import com.infomaniak.swisstransfer.ui.utils.PreviewAllWindows
import com.infomaniak.core2.R as RCore2

@Composable
fun UploadErrorScreen(navigateToImportFiles: () -> Unit) {
fun UploadErrorScreen(retryTransfer: () -> Unit, navigateBackToImportFiles: () -> Unit) {
BottomStickyButtonScaffold(
topBar = { BrandTopAppBar() },
bottomButton = {
topButton = {
LargeButton(
modifier = it,
title = stringResource(RCore2.string.buttonRetry),
onClick = navigateToImportFiles,
onClick = retryTransfer,
)
},
bottomButton = {
LargeButton(
modifier = it,
title = stringResource(R.string.buttonEditTransfer),
style = ButtonType.SECONDARY,
onClick = navigateBackToImportFiles,
)
}
) {
Expand All @@ -56,7 +61,7 @@ fun UploadErrorScreen(navigateToImportFiles: () -> Unit) {
private fun UploadErrorScreenPreview() {
SwissTransferTheme {
Surface {
UploadErrorScreen({})
UploadErrorScreen({}, {})
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,19 @@ fun UploadProgressScreen(
uploadProgressViewModel.trackUploadProgress()
}

HandleProgressState({ uiState }, navigateToUploadSuccess, navigateToUploadError, navigateBackToImportFiles)
HandleProgressState(
uiState = { uiState },
navigateToUploadSuccess = navigateToUploadSuccess,
navigateToUploadError = {
// If the transfer fails, we need to remove the upload session
// before going back to ImportFilesScreen to edit the transfer.
// TODO: This is possibly only mandatory for editing the transfer, and not retrying it.
// This needs to be checked when implementing the "Retry" feature.
uploadProgressViewModel.removeAllUploadSession()
navigateToUploadError()
},
navigateBackToImportFiles = navigateBackToImportFiles,
)

UploadProgressScreen(
progressState = { uiState },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,10 @@ class UploadProgressViewModel @Inject constructor(
}
}

fun removeAllUploadSession() {
viewModelScope.launch(ioDispatcher) { uploadManager.removeAllUploadSession() }
}

companion object {
private val TAG = UploadProgressViewModel::class.java.simpleName
}
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values-de/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
<string name="buttonCopyLink">Link kopieren</string>
<string name="buttonDownload">Download</string>
<string name="buttonDownloadSelected">Auswahl herunterladen</string>
<string name="buttonEditTransfer">Meine Übertragung bearbeiten</string>
<string name="buttonFinished">Beenden</string>
<string name="buttonShare">Teilen</string>
<string name="buttonStart">Starten</string>
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values-es/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
<string name="buttonCopyLink">Copiar enlace</string>
<string name="buttonDownload">Descargar</string>
<string name="buttonDownloadSelected">Descargar la selección</string>
<string name="buttonEditTransfer">Editar mi transferencia</string>
<string name="buttonFinished">Acabado</string>
<string name="buttonShare">Compartir</string>
<string name="buttonStart">Inicio</string>
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values-fr/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
<string name="buttonCopyLink">Copier le lien</string>
<string name="buttonDownload">Télécharger</string>
<string name="buttonDownloadSelected">Télécharger la sélection</string>
<string name="buttonEditTransfer">Modifier mon transfert</string>
<string name="buttonFinished">Terminer</string>
<string name="buttonShare">Partager</string>
<string name="buttonStart">Démarrer</string>
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values-it/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
<string name="buttonCopyLink">Copia link</string>
<string name="buttonDownload">Scaricare</string>
<string name="buttonDownloadSelected">Scarica la selezione</string>
<string name="buttonEditTransfer">Modifica mio trasferimento</string>
<string name="buttonFinished">Finisci</string>
<string name="buttonShare">Condividi</string>
<string name="buttonStart">Inizio</string>
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
<string name="buttonCopyLink">Copy link</string>
<string name="buttonDownload">Download</string>
<string name="buttonDownloadSelected">Download selection</string>
<string name="buttonEditTransfer">Edit my transfer</string>
<string name="buttonFinished">Finish</string>
<string name="buttonShare">Share</string>
<string name="buttonStart">Start</string>
Expand Down

0 comments on commit 4ffd5a8

Please sign in to comment.