Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Return the added transfer by deeplink UUID #74

Merged
merged 1 commit into from
Nov 1, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,9 @@ class TransferManager internal constructor(
* @see getTransfers
*
* @param url The URL associated with the transfer to retrieve.
*
* @return The transferUUID of the added transfer, otherwise null if the api doesn't return the transfer
*
* @throws CancellationException If the operation is cancelled.
* @throws ApiException If there is an error related to the API during transfer retrieval.
* @throws UnexpectedApiErrorFormatException Unparsable api error response.
Expand All @@ -135,8 +138,10 @@ class TransferManager internal constructor(
UnknownException::class,
RealmException::class,
)
suspend fun addTransferByUrl(url: String): Unit = withContext(Dispatchers.IO) {
addTransfer(transferRepository.getTransferByUrl(url).data, TransferDirection.RECEIVED)
suspend fun addTransferByUrl(url: String): String? = withContext(Dispatchers.IO) {
val transferApi = transferRepository.getTransferByUrl(url).data ?: return@withContext null
addTransfer(transferApi, TransferDirection.RECEIVED)
return@withContext transferApi.linkUUID
}

private suspend fun addTransfer(transferApi: TransferApi?, transferDirection: TransferDirection) {
Expand Down
Loading