Skip to content

fix: Avoid reprocessing API v2 deeplink multiple times#631

Open
sirambd wants to merge 4 commits intomainfrom
fix-apiv2-deeplink
Open

fix: Avoid reprocessing API v2 deeplink multiple times#631
sirambd wants to merge 4 commits intomainfrom
fix-apiv2-deeplink

Conversation

@sirambd
Copy link
Copy Markdown
Member

@sirambd sirambd commented Apr 30, 2026

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.

Copilot AI review requested due to automatic review settings April 30, 2026 08:11
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_swisstransfer dependency version to 8.0.0.
  • Updates TransferDetailsViewModel.loadTransfer() to look up existing transfers by v2 linkId when 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, transferUuid is actually a V2 linkId (see addTransferByLinkIdApiV2(linkId = transferUuid, ...)) and you correctly look up the transfer via getTransferByLinkId(transferUuid). However, in the else branch you still emit TransferSource.Local(transferUuid) and call fetchTransfer(transferUuid), which will treat the linkId as the local transfer UUID used by getTransferFlow(...). This can load/fetch the wrong transfer (or none) for existing V2 transfers. Use the already-loaded transfer to derive the local UUID (e.g., transfer.uuid) for the TransferSource.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.

Copy link
Copy Markdown
Contributor

@LunarX LunarX left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When I try to deeplink to a transfer it fails to open it so I can't test if the bug is fixed

@sirambd sirambd force-pushed the fix-apiv2-deeplink branch from f8dcdf8 to 844a794 Compare April 30, 2026 11:11
sirambd added 4 commits May 1, 2026 14:49
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.
@sirambd sirambd force-pushed the fix-apiv2-deeplink branch from 288d9be to f3779b0 Compare May 1, 2026 12:49
@sirambd sirambd enabled auto-merge May 1, 2026 12:51
@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud Bot commented May 1, 2026

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants