Skip to content

Commit

Permalink
fix(ImportCancellation): Canceling small uploads works + doesn't popb…
Browse files Browse the repository at this point in the history
…ackstack anymore
  • Loading branch information
FabianDevel committed Oct 9, 2024
1 parent d9ef56b commit 66393d1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,13 @@ open class FileAdapter(
}
}

fun deleteByFileName(fileName: String) {
if (!fileList.isManaged) {
val position = indexOf(fileName)
if (position >= 0) deleteAt(position)
}
}

private fun indexOf(fileId: Int) = fileList.indexOfFirst { it.id == fileId }

fun indexOf(fileName: String) = fileList.indexOfFirst { it.name == fileName }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,10 +136,8 @@ class UploadInProgressFragment : FileListFragment() {
pendingUploadFiles.find { it.fileName == fileName }?.let { syncFile ->
val title = getString(R.string.uploadInProgressCancelFileUploadTitle, syncFile.fileName)
Utils.createConfirmation(requireContext(), title) {
if (fileAdapter.fileList.getOrNull(position)?.name == fileName) {
closeItemClicked(uploadFile = syncFile)
fileAdapter.deleteAt(position)
}
closeItemClicked(uploadFile = syncFile)
fileAdapter.deleteByFileName(fileName)
}
}
}
Expand Down Expand Up @@ -197,7 +195,6 @@ class UploadInProgressFragment : FileListFragment() {
ApiRepository.cancelSession(AccountUtils.currentDriveId, token, it.okHttpClient)
}
UploadFile.deleteAll(listOf(it))
needPopBackStack = true
}
folderId?.let {
UploadFile.cancelAllPendingFilesSessions(folderId = it)
Expand Down

0 comments on commit 66393d1

Please sign in to comment.