Skip to content

Commit

Permalink
DO NOT MERGE: Make Transfers come back from the dead 5sec after being…
Browse files Browse the repository at this point in the history
… deleted
  • Loading branch information
KevinBoulongne committed Nov 27, 2024
1 parent 753196a commit 6af0617
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import com.infomaniak.swisstransfer.ui.theme.CustomShapes
import com.infomaniak.swisstransfer.ui.theme.Margin
import com.infomaniak.swisstransfer.ui.theme.SwissTransferTheme
import com.infomaniak.swisstransfer.ui.utils.PreviewLightAndDark
import java.util.UUID

@Composable
fun TransferItemList(
Expand Down Expand Up @@ -63,7 +64,10 @@ fun TransferItemList(

items(
count = getTransfers().count(),
key = { getTransfers()[it].uuid },
key = {
// getTransfers()[it].uuid
UUID.randomUUID().toString()
},
contentType = { getTransfers()[it] },
itemContent = {
val transfer = getTransfers()[it]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import com.infomaniak.sentry.SentryLog
import com.infomaniak.swisstransfer.di.IoDispatcher
import dagger.hilt.android.lifecycle.HiltViewModel
import kotlinx.coroutines.CoroutineDispatcher
import kotlinx.coroutines.delay
import kotlinx.coroutines.flow.SharingStarted
import kotlinx.coroutines.flow.flowOn
import kotlinx.coroutines.flow.stateIn
Expand Down Expand Up @@ -62,7 +63,10 @@ class TransfersViewModel @Inject constructor(
fun deleteSwipedTransfer(transferUuid: String) {
viewModelScope.launch(ioDispatcher) {
runCatching {
val transfer = transferManager.getTransferByUUID(transferUuid)
transferManager.deleteTransfer(transferUuid)
delay(5_000L)
transfer?.uuid?.let { transferManager.addTransferByLinkUUID(it, password = null) }
}.onFailure {
SentryLog.e(TAG, "Failure for deleteTransfer", it)
}
Expand Down

0 comments on commit 6af0617

Please sign in to comment.