fix(deeplink): drop a pending link once it fails for good

RootDeepLinkHandler cleared the persisted pending link only on success or
when no handler matched. A link that reached a handler and failed with a
DeepLinkHandlingException stayed in preferences and was replayed on
every launch. Clear it on terminal handling failures in both the fresh
and pending paths; this also recovers installs already stuck on update.
Other failures keep the link pending for a retry.
This commit is contained in:
Satoshi Qazi Muhammed committed 2026-10-19 13:14:41 +04:00
1 parent 910716c55c
commit af3476982d
1 file changed
+7
@@ -2,6 +2,7 @@ package io.novafoundation.nova.feature_deep_linking.presentation.handling
import android.net.Uri
import io.novafoundation.nova.common.utils.onFailureInstance
import io.novafoundation.nova.feature_deep_linking.presentation.handling.common.DeepLinkHandlingException
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.merge
@@ -23,12 +24,18 @@ class RootDeepLinkHandler(
return handleDeepLinkInternal(pendingDeepLink)
.onSuccess { pendingDeepLinkProvider.clear() }
// A pending link that reaches a handler but fails with a terminal error (malformed/unresolvable),
// or matches no handler, will never succeed on retry - clear it so it does not replay on every launch.
.onFailureInstance<DeepLinkHandlingException, Unit> { pendingDeepLinkProvider.clear() }
.onFailureInstance<HandlerNotFoundException, Unit> { pendingDeepLinkProvider.clear() }
}
override suspend fun handleDeepLink(data: Uri): Result<Unit> {
pendingDeepLinkProvider.save(data)
return handleDeepLinkInternal(data)
.onSuccess { pendingDeepLinkProvider.clear() }
// Same as above: a terminal handling failure must not be persisted, otherwise it bricks every launch.
.onFailureInstance<DeepLinkHandlingException, Unit> { pendingDeepLinkProvider.clear() }
.onFailureInstance<HandlerNotFoundException, Unit> { pendingDeepLinkProvider.clear() } // If we haven't find any handler - no need to save deep link
}