Skip to content

Commit

Permalink
chore: Apply reviews code
Browse files Browse the repository at this point in the history
  • Loading branch information
sirambd committed Nov 6, 2024
1 parent c897300 commit 6ad51c6
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,7 @@ fun ImportFilesScreen(
removeFileByUid = newTransferViewModel::removeFileByUid,
addFiles = newTransferViewModel::importFiles,
closeActivity = closeActivity,
sendTransfer = {
newTransferViewModel.sendTransfer()
},
sendTransfer = newTransferViewModel::sendTransfer,
initialShowUploadSourceChoiceBottomSheet = true,
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ private fun HandleProgressState(
LaunchedEffect(uiState()) {
when (currentUiState) {
is UploadProgressUiState.Success -> {
// TODO: Use correct TransferType instead of hard-coded value
navigateToUploadSuccess(transferType, currentUiState.transferLink)
}
is UploadProgressUiState.Cancelled -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class UploadWorker @AssistedInject constructor(
UploadFileTask(uploadManager, fileChunkSizeManager)
}

private var totalUploadedBytes = 0L
private var uploadedBytes = 0L
private var lastUpdateTime = 0L

override suspend fun launchWork(): Result {
Expand All @@ -72,7 +72,7 @@ class UploadWorker @AssistedInject constructor(

uploadSession.files.forEach { fileSession ->
uploadFileTask.start(fileSession, uploadSession) { bytesSent ->
totalUploadedBytes += bytesSent
uploadedBytes += bytesSent
emitProgress()
}
}
Expand All @@ -90,7 +90,7 @@ class UploadWorker @AssistedInject constructor(
private suspend fun emitProgress() {
val currentTime = System.currentTimeMillis()
if (currentTime - lastUpdateTime > PROGRESS_ELAPSED_TIME) {
setProgress(workDataOf(UPLOADED_BYTES_TAG to totalUploadedBytes))
setProgress(workDataOf(UPLOADED_BYTES_TAG to uploadedBytes))
lastUpdateTime = currentTime
}
}
Expand Down Expand Up @@ -166,7 +166,7 @@ class UploadWorker @AssistedInject constructor(
private const val MAX_CHUNK_COUNT = (TOTAL_FILE_SIZE / EXPECTED_CHUNK_SIZE).toInt()

private const val UPLOADED_BYTES_TAG = "uploaded_bytes_tag"
private const val TRANSFER_UUID_TAG = "transfer_result_tag"
private const val TRANSFER_UUID_TAG = "transfer_uuid_tag"

private const val PROGRESS_ELAPSED_TIME = 50
}
Expand Down

0 comments on commit 6ad51c6

Please sign in to comment.