Skip to content

Commit

Permalink
fix: Correctly remove previous UploadSession when trying again to sen…
Browse files Browse the repository at this point in the history
…d a new transfer (#285)
  • Loading branch information
KevinBoulongne authored Dec 24, 2024
2 parents 0746669 + b743eb1 commit 52057ef
Showing 1 changed file with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,18 @@ class TransferSendManager @Inject constructor(
private val uploadWorkerScheduler: UploadWorker.Scheduler,
) {

// TODO: Merge these two UI states in a single one for the whole flow of logic
private val _sendStatus = MutableStateFlow<SendStatus>(SendStatus.Initial)
val sendStatus = _sendStatus.asStateFlow()

suspend fun sendNewTransfer(newUploadSession: NewUploadSession) {

// When clicking the "Send" button, a new session is created.
// If there is an error before reaching the UploadProgressScreen, we stay in ImportFilesScreen.
// Every time we'll click the "Send" button again, a new session will be created.
// So we'll have multiple UploadSession in Realm. We don't want that. We only want the last session.
// So before creating the new session, we need to remove the previous failed ones.
uploadManager.removeAllUploadSession()

val uploadSession = uploadManager.createAndGetUpload(newUploadSession)
sendTransfer(uploadSession.uuid)
}
Expand Down

0 comments on commit 52057ef

Please sign in to comment.