From 4152f01888d7c5a97fffe7b5f5d38245ed3f76e5 Mon Sep 17 00:00:00 2001 From: Evgenii Kozlov Date: Tue, 23 Aug 2022 13:18:13 +0300 Subject: [PATCH] DROID-302 Relations | Enhancement | Update relation value before reloading object by source relation (#2545) --- .../ui/relations/RelationTextValueFragment.kt | 28 ++++++++++++++++--- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/com/anytypeio/anytype/ui/relations/RelationTextValueFragment.kt b/app/src/main/java/com/anytypeio/anytype/ui/relations/RelationTextValueFragment.kt index 0911ef804b..2bec0e0c79 100644 --- a/app/src/main/java/com/anytypeio/anytype/ui/relations/RelationTextValueFragment.kt +++ b/app/src/main/java/com/anytypeio/anytype/ui/relations/RelationTextValueFragment.kt @@ -4,7 +4,9 @@ import android.os.Bundle import android.view.LayoutInflater import android.view.View import android.view.ViewGroup +import android.widget.EditText import android.widget.FrameLayout +import android.widget.TextView import androidx.core.os.bundleOf import androidx.fragment.app.viewModels import androidx.lifecycle.lifecycleScope @@ -72,10 +74,28 @@ open class RelationTextValueFragment : private val relationValueActionAdapter by lazy { RelationActionAdapter { action -> - vm.onAction( - target = objectId, - action = action - ) + val input = binding.recycler.findViewById(R.id.textInputField) + val parsed = input?.text?.toString().orEmpty() + // Workaround for updating relation value when before reloading content + if (action is RelationValueAction.Url.Reload && parsed != action.url) { + withParent { + onTextValueChanged( + ctx = ctx, + relationId = relationId, + objectId = objectId, + text = parsed + ) + } + vm.onAction( + target = objectId, + action = action.copy(url = parsed) + ) + } else { + vm.onAction( + target = objectId, + action = action + ) + } } }