Skip to content

Commit

Permalink
feat: Get sent or received transfers flow
Browse files Browse the repository at this point in the history
  • Loading branch information
sirambd committed Oct 15, 2024
1 parent 7ce311a commit 4af1711
Showing 1 changed file with 12 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import com.infomaniak.multiplatform_swisstransfer.network.models.transfer.Transf
import com.infomaniak.multiplatform_swisstransfer.network.repositories.TransferRepository
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.IO
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.flowOn
import kotlinx.coroutines.withContext
import kotlin.coroutines.cancellation.CancellationException
Expand All @@ -52,11 +53,17 @@ class TransferManager internal constructor(
) {

/**
* The `Flow` of [transfers] is used to receive updates for new transfers added in database.
* @see addTransferByLinkUuid
* Retrieves a flow of transfers based on the specified transfer direction.
*
* @see addTransferByUrl
* @see addTransferByLinkUuid
*
* @param transferDirection The direction of the transfers to retrieve (e.g., [TransferDirection.SENT] or [TransferDirection.RECEIVED]).
* @return A `Flow` that emits a list of transfers matching the specified direction.
*/
val transfers get() = transferController.getTransfersFlow().flowOn(Dispatchers.IO)
fun getTransfers(transferDirection: TransferDirection): Flow<List<Transfer>> {
return transferController.getTransfersFlow(transferDirection).flowOn(Dispatchers.IO)
}

/**
* Retrieves a transfer using the provided link UUID and saves it to the database.
Expand All @@ -65,7 +72,7 @@ class TransferManager internal constructor(
* a `linkUuid` is returned, which must be passed to this function to retrieve the corresponding transfer.
* After retrieving the transfer, it is saved to the database.
*
* @see transfers
* @see getTransfers
*
* @param linkUuid The UUID corresponding to the uploaded transfer link.
* @throws CancellationException If the operation is cancelled.
Expand All @@ -92,7 +99,7 @@ class TransferManager internal constructor(
* the corresponding transfer, and after the transfer is successfully retrieved, it is saved to
* the database.
*
* @see transfers
* @see getTransfers
*
* @param url The URL associated with the transfer to retrieve.
* @throws CancellationException If the operation is cancelled.
Expand Down

0 comments on commit 4af1711

Please sign in to comment.