From 983593d6476431bf0d6927978fda7d36fac7d8ff Mon Sep 17 00:00:00 2001 From: onurays Date: Thu, 13 Feb 2020 17:28:14 +0300 Subject: [PATCH] getRedactionReason function is refactored. --- .../action/MessageActionsViewModel.kt | 20 ++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/vector/src/main/java/im/vector/riotx/features/home/room/detail/timeline/action/MessageActionsViewModel.kt b/vector/src/main/java/im/vector/riotx/features/home/room/detail/timeline/action/MessageActionsViewModel.kt index e7c8cfec54..5e65330d6f 100644 --- a/vector/src/main/java/im/vector/riotx/features/home/room/detail/timeline/action/MessageActionsViewModel.kt +++ b/vector/src/main/java/im/vector/riotx/features/home/room/detail/timeline/action/MessageActionsViewModel.kt @@ -214,15 +214,17 @@ class MessageActionsViewModel @AssistedInject constructor(@Assisted ?.get("reason") as? String) ?.takeIf { it.isNotBlank() } ?.let { reason -> - stringProvider.getString( - (R.string.event_redacted_by_user_reason_with_reason - .takeIf { timelineEvent.root.senderId == session.myUserId } - ?: R.string.event_redacted_by_admin_reason_with_reason), reason - ) - } ?: stringProvider.getString( - R.string.event_redacted_by_user_reason - .takeIf { timelineEvent.root.senderId == session.myUserId } - ?: R.string.event_redacted_by_admin_reason_with_reason) + when (timelineEvent.root.senderId == session.myUserId) { + true -> stringProvider.getString(R.string.event_redacted_by_user_reason_with_reason, reason) + false -> stringProvider.getString(R.string.event_redacted_by_admin_reason_with_reason, reason) + } + } + ?: run { + when (timelineEvent.root.senderId == session.myUserId) { + true -> stringProvider.getString(R.string.event_redacted_by_user_reason) + false -> stringProvider.getString(R.string.event_redacted_by_admin_reason) + } + } private fun actionsForEvent(timelineEvent: TimelineEvent): List { val messageContent: MessageContent? = timelineEvent.annotations?.editSummary?.aggregatedContent.toModel()