diff --git a/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/newtransfer/ImportFilesViewModel.kt b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/newtransfer/ImportFilesViewModel.kt index d14b4a1a1..bc27963b4 100644 --- a/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/newtransfer/ImportFilesViewModel.kt +++ b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/newtransfer/ImportFilesViewModel.kt @@ -104,7 +104,7 @@ class ImportFilesViewModel @Inject constructor( } } - fun getFiles(folderUuid: String?): Flow?> { + fun getFiles(folderUuid: String?): Flow> { return if (folderUuid == null) { importationFilesManager.importedFiles } else { diff --git a/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/newtransfer/importfiles/FilesDetailsScreen.kt b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/newtransfer/importfiles/FilesDetailsScreen.kt index e8603cfed..f46231c0c 100644 --- a/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/newtransfer/importfiles/FilesDetailsScreen.kt +++ b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/newtransfer/importfiles/FilesDetailsScreen.kt @@ -49,18 +49,16 @@ fun FilesDetailsScreen( navigateBack: (() -> Unit), ) { // If we don't have a folderUuid, it means we have to load files from importedFiles in ImportFilesViewModel - val files by importFilesViewModel.getFiles(folderUuid).collectAsStateWithLifecycle(null) + val files by importFilesViewModel.getFiles(folderUuid).collectAsStateWithLifecycle(emptyList()) - if (files?.isEmpty() == true) navigateBack() + if (files.isEmpty() == true) navigateBack() FilesDetailsScreen( - files = files ?: emptyList(), + files = files, navigateToDetails = navigateToDetails, withFileSize = withFileSize, withSpaceLeft = withSpaceLeft, - onFileRemoved = if (withFileDelete) { - { importFilesViewModel.removeFileByUid(it) } - } else null, + onFileRemoved = getOnFileRemoveCallback(withFileDelete, importFilesViewModel), onCloseClicked = onCloseClicked, navigateBack = navigateBack, )