From 56acddb29a20927d5cbc45bc081367317eacd07e Mon Sep 17 00:00:00 2001 From: Abdourahamane Boinaidi Date: Fri, 8 Nov 2024 11:37:05 +0100 Subject: [PATCH 1/2] fix: Remove old data with db data --- .../ui/screen/newtransfer/ImportFilesViewModel.kt | 7 ++++++- gradle/libs.versions.toml | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) 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 264b23edc..7461fe116 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 @@ -83,7 +83,7 @@ class ImportFilesViewModel @Inject constructor( isFirstViewModelCreation = false // Remove old imported files in case it would've crashed or similar to start with a clean slate. This is required // for already imported files restoration to not pick up old files in some extreme cases. - importationFilesManager.removeLocalCopyFolder() + removeOldData() } else { importationFilesManager.restoreAlreadyImportedFiles() } @@ -124,6 +124,11 @@ class ImportFilesViewModel @Inject constructor( } } + private suspend fun removeOldData() { + importationFilesManager.removeLocalCopyFolder() + uploadManager.removeAllUploadSession() + } + private fun generateNewUploadSession(): NewUploadSession { return NewUploadSession( duration = "30", diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 5ac4e109d..468b62c07 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -20,7 +20,7 @@ qrose = "1.0.1" recaptcha = "18.6.1" sentry = "4.12.0" serialization = "1.7.1" -swisstransfer = "0.7.0" +swisstransfer = "0.7.2" workmanager = "2.9.1" [libraries] From bc084e787f15c5f1752df7dd757b0effcecf3eeb Mon Sep 17 00:00:00 2001 From: Abdourahamane Boinaidi Date: Fri, 8 Nov 2024 15:27:03 +0100 Subject: [PATCH 2/2] fix: Build after update libs --- .../swisstransfer/ui/screen/main/received/ReceivedScreen.kt | 4 ++-- .../ui/screen/newtransfer/upload/UploadProgressViewModel.kt | 2 +- .../com/infomaniak/swisstransfer/workers/UploadFileTask.kt | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/received/ReceivedScreen.kt b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/received/ReceivedScreen.kt index 85e91694f..e84290430 100644 --- a/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/received/ReceivedScreen.kt +++ b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/received/ReceivedScreen.kt @@ -23,9 +23,9 @@ import androidx.compose.material3.Surface import androidx.compose.runtime.* import androidx.compose.runtime.saveable.rememberSaveable import androidx.compose.ui.Modifier -import androidx.compose.ui.res.stringResource import androidx.hilt.navigation.compose.hiltViewModel import androidx.lifecycle.compose.collectAsStateWithLifecycle +import com.infomaniak.multiplatform_swisstransfer.common.ext.toDateFromSeconds import com.infomaniak.swisstransfer.R import com.infomaniak.swisstransfer.ui.components.EmptyState import com.infomaniak.swisstransfer.ui.components.transfer.TransferExpiredBottomSheet @@ -86,7 +86,7 @@ private fun ReceivedScreen( when { transfer.expiresInDays < 0 -> { isVisible = true - expirationDate = Date(transfer.expirationDateTimestamp) + expirationDate = transfer.expirationDateTimestamp.toDateFromSeconds() } transfer.downloadLeft == 0 -> { isVisible = true diff --git a/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/newtransfer/upload/UploadProgressViewModel.kt b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/newtransfer/upload/UploadProgressViewModel.kt index 95eb4c455..7dfe14f06 100644 --- a/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/newtransfer/upload/UploadProgressViewModel.kt +++ b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/newtransfer/upload/UploadProgressViewModel.kt @@ -67,7 +67,7 @@ class UploadProgressViewModel @Inject constructor( viewModelScope.launch(ioDispatcher) { uploadManager.getLastUpload()?.let { - uploadManager.deleteUploadSession(it.uuid) + uploadManager.removeUploadSession(it.uuid) } } } diff --git a/app/src/main/java/com/infomaniak/swisstransfer/workers/UploadFileTask.kt b/app/src/main/java/com/infomaniak/swisstransfer/workers/UploadFileTask.kt index 9c6fdca38..d501c24e1 100644 --- a/app/src/main/java/com/infomaniak/swisstransfer/workers/UploadFileTask.kt +++ b/app/src/main/java/com/infomaniak/swisstransfer/workers/UploadFileTask.kt @@ -135,7 +135,7 @@ class UploadFileTask( } private suspend inline fun throwAndDestroyUpload(uploadUuid: String, throwMessage: String): Nothing { - uploadManager.deleteUploadSession(uploadUuid) + uploadManager.removeUploadSession(uploadUuid) error(throwMessage) }