Skip to content

Commit 0f9bc3a

Browse files
authored
Merge pull request #854 from arkivanov/avoid-restarting-activity-deep-link
Don't restart Activity stack when there is no deep link
2 parents 0c09dd0 + bc1c113 commit 0f9bc3a

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

decompose/src/androidMain/kotlin/com/arkivanov/decompose/DeeplinkUtils.kt

+4-2
Original file line numberDiff line numberDiff line change
@@ -51,13 +51,15 @@ import androidx.savedstate.SavedStateRegistryOwner
5151
fun <A, T : Any> A.handleDeepLink(
5252
block: (Uri?) -> T,
5353
): T? where A : Activity, A : SavedStateRegistryOwner {
54-
if (restartIfNeeded()) {
54+
val intentData: Uri? = intent.data
55+
56+
if ((intentData != null) && restartIfNeeded()) {
5557
return null
5658
}
5759

5860
val savedState: Bundle? = savedStateRegistry.consumeRestoredStateForKey(key = KEY_SAVED_DEEP_LINK_STATE)
5961
val isDeepLinkHandled = savedState?.getBoolean(KEY_DEEP_LINK_HANDLED) ?: false
60-
val deepLink = intent.data.takeUnless { isDeepLinkHandled }
62+
val deepLink = intentData?.takeUnless { isDeepLinkHandled }
6163

6264
savedStateRegistry.registerSavedStateProvider(key = KEY_SAVED_DEEP_LINK_STATE) {
6365
bundleOf(KEY_DEEP_LINK_HANDLED to (isDeepLinkHandled || (deepLink != null)))

0 commit comments

Comments
 (0)