extract checks to separate methods

Signed-off-by: Andy Scherzinger <info@andy-scherzinger.de>
This commit is contained in:
Andy Scherzinger 2022-05-09 16:46:16 +02:00
parent c3dd263b3f
commit 5a76f3a3d3
No known key found for this signature in database
GPG Key ID: 6CADC7E3523C308B

View File

@ -76,10 +76,8 @@ class MessageActionsDialog(
initMenuReplyToMessage(message.replyable)
initMenuReplyPrivately(
message.replyable &&
user?.userId?.isNotEmpty() == true &&
user?.userId != "?" &&
message.user.id.startsWith("users/") &&
message.user.id.substring(ACTOR_LENGTH) != currentConversation?.actorId &&
hasUserId(user) &&
hasUserActorId(message) &&
currentConversation?.type != Conversation.ConversationType.ROOM_TYPE_ONE_TO_ONE_CALL
)
initMenuDeleteMessage(showMessageDeletionButton)
@ -101,6 +99,15 @@ class MessageActionsDialog(
behavior.state = BottomSheetBehavior.STATE_EXPANDED
}
private fun hasUserId(user: UserEntity?): Boolean {
return user?.userId?.isNotEmpty() == true && user?.userId != "?"
}
private fun hasUserActorId(message: ChatMessage): Boolean {
return message.user.id.startsWith("users/") &&
message.user.id.substring(ACTOR_LENGTH) != currentConversation?.actorId
}
@SuppressLint("ClickableViewAccessibility")
private fun initEmojiMore() {
dialogMessageActionsBinding.emojiMore.setOnTouchListener { v, event ->