fix: Avoid reprocessing API v2 deeplink multiple times#631
fix: Avoid reprocessing API v2 deeplink multiple times#631
Conversation
There was a problem hiding this comment.
Pull request overview
Fixes duplicate processing of API v2 transfer deeplinks by attempting to reuse an existing locally-stored transfer (instead of re-adding it) while the deeplink intent remains active.
Changes:
- Bumps
com.infomaniak.multiplatform_swisstransferdependency version to8.0.0. - Updates
TransferDetailsViewModel.loadTransfer()to look up existing transfers by v2linkIdwhen the deeplink is API v2.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
gradle/libs.versions.toml |
Updates SwissTransfer multiplatform library version. |
app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/transferdetails/TransferDetailsViewModel.kt |
Adjusts deeplink load logic to avoid re-adding existing API v2 transfers. |
Comments suppressed due to low confidence (1)
app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/transferdetails/TransferDetailsViewModel.kt:129
- When
isApiV2Deeplink == true,transferUuidis actually a V2 linkId (seeaddTransferByLinkIdApiV2(linkId = transferUuid, ...)) and you correctly look up the transfer viagetTransferByLinkId(transferUuid). However, in theelsebranch you still emitTransferSource.Local(transferUuid)and callfetchTransfer(transferUuid), which will treat the linkId as the local transfer UUID used bygetTransferFlow(...). This can load/fetch the wrong transfer (or none) for existing V2 transfers. Use the already-loadedtransferto derive the local UUID (e.g.,transfer.uuid) for theTransferSource.Local(...)+fetchTransfer(...)calls when the V2 deeplink transfer is already present.
val transfer = when {
isApiV2Deeplink == true -> transferManager.getTransferByLinkId(transferUuid)
else -> transferManager.getTransferFlow(transferUuid).first()
}
if (transfer == null && isApiV2Deeplink != null) {
val transferId = handleTransferDeeplink(transferUuid, _deeplinkPassword, isApiV2Deeplink)
_transferSourceFlow.emit(TransferSource.Local(transferId))
} else {
_transferSourceFlow.emit(TransferSource.Local(transferUuid))
transferManager.fetchTransfer(transferUuid)
}
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
LunarX
left a comment
There was a problem hiding this comment.
When I try to deeplink to a transfer it fails to open it so I can't test if the bug is fixed
f8dcdf8 to
844a794
Compare
Handle API v2 deeplink flow correctly to prevent duplicate processing while the intent is still active.
For API v2 deeplinks, the provided uuid is a linkId. Use the resolved transfer.uuid to ensure correct fetch and data consistency.
Since API v2, only the `linkId` is required for a deep link. However, Composer still tracks that it originated from a deep link even after usage. This change ensures that `linkId` is only used if the transfer was actually opened via a deep link. For all other navigation scenarios, `transferId` is now used instead.
288d9be to
f3779b0
Compare
|



Description
Currently, when you have an APIv2 deep link with a folder, as long as you navigate within the folder and return to the root transfer, you can duplicate the data because, as long as the intent is active and you return to the root of a transfer, the transfer is re-added to the database each time you return.
Fix
Handle API v2 deeplink flow correctly to prevent duplicate processing
while the intent is still active.