From 21955e6e726abdf0a7ab8cf1189a203943d90b46 Mon Sep 17 00:00:00 2001 From: Laimonas Turauskas <laimiux@gmail.com> Date: Thu, 10 Oct 2024 14:07:12 -0400 Subject: [PATCH] Set fragment instance id to all fragments. (#401) --- .../android/internal/FragmentLifecycle.kt | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/formula-android/src/main/java/com/instacart/formula/android/internal/FragmentLifecycle.kt b/formula-android/src/main/java/com/instacart/formula/android/internal/FragmentLifecycle.kt index 1240e393..a558e402 100644 --- a/formula-android/src/main/java/com/instacart/formula/android/internal/FragmentLifecycle.kt +++ b/formula-android/src/main/java/com/instacart/formula/android/internal/FragmentLifecycle.kt @@ -29,16 +29,12 @@ internal fun Fragment.getFragmentKey(): FragmentKey { * one if it doesn't exist. */ internal fun Fragment.getFragmentInstanceId(): String { - return if (this is BaseFormulaFragment<*>) { - val arguments = getOrSetArguments() - val id = arguments.getString(FormulaFragment.ARG_FORMULA_ID, "") - id.ifBlank { - val initializedId = UUID.randomUUID().toString() - arguments.putString(FormulaFragment.ARG_FORMULA_ID, initializedId) - initializedId - } - } else { - "" + val arguments = getOrSetArguments() + val id = arguments.getString(FormulaFragment.ARG_FORMULA_ID, "") + return id.ifBlank { + val initializedId = UUID.randomUUID().toString() + arguments.putString(FormulaFragment.ARG_FORMULA_ID, initializedId) + initializedId } }