Avoid sending blank replies and do not clear input when sending reactions.

This commit is contained in:
Sagar
2025-04-09 18:55:56 +05:30
committed by Michelle Tang
parent af52765821
commit 6ea63f3e34
2 changed files with 17 additions and 8 deletions

View File

@@ -92,15 +92,22 @@ class StoryReplyComposer @JvmOverloads constructor(
}
input.doAfterTextChanged {
val notEmpty = !it.isNullOrEmpty()
reply.isEnabled = notEmpty
if (notEmpty && reply.visibility != View.VISIBLE) {
if (it == null) return@doAfterTextChanged
val isEmpty = it.isBlank()
reply.isEnabled = !isEmpty
val transition = AutoTransition().setDuration(200L).setInterpolator(OvershootInterpolator(1f))
if (!isEmpty && reply.visibility != View.VISIBLE) {
TransitionManager.beginDelayedTransition(bubbleView, transition)
reply.visibility = View.VISIBLE
reply.scaleX = 0f
reply.scaleY = 0f
reply.animate().setDuration(150).scaleX(1f).scaleY(1f).setInterpolator(OvershootInterpolator(1f)).start()
} else if (isEmpty) {
TransitionManager.beginDelayedTransition(bubbleView, transition)
reply.visibility = View.GONE
reply.scaleX = 1f
reply.scaleY = 1f
reply.animate().setDuration(150).scaleX(0f).scaleY(0f).setInterpolator(OvershootInterpolator(1f)).start()
}
}

View File

@@ -92,7 +92,7 @@ class StoryDirectReplyDialogFragment :
}
override fun onReactionClicked(emoji: String) {
sendReaction(emoji)
sendReaction(emoji, composer.input.text.isNullOrBlank())
}
override fun onPickAnyReactionClicked() {
@@ -176,11 +176,11 @@ class StoryDirectReplyDialogFragment :
}
override fun onReactWithAnyEmojiSelected(emoji: String) {
sendReaction(emoji)
sendReaction(emoji, composer.input.text.isNullOrBlank())
isReactClosingAfterSend = true
}
private fun sendReaction(emoji: String) {
private fun sendReaction(emoji: String, shouldClose: Boolean) {
lifecycleDisposable += viewModel.sendReaction(emoji)
.observeOn(AndroidSchedulers.mainThread())
.subscribe {
@@ -190,7 +190,9 @@ class StoryDirectReplyDialogFragment :
putString(REQUEST_EMOJI, emoji)
}
)
if (shouldClose) {
dismissAllowingStateLoss()
}
}
}
}