getRedactionReason function is refactored.

This commit is contained in:
onurays 2020-02-13 17:28:14 +03:00
parent 1b413934b5
commit 983593d647

View file

@ -214,15 +214,17 @@ class MessageActionsViewModel @AssistedInject constructor(@Assisted
?.get("reason") as? String) ?.get("reason") as? String)
?.takeIf { it.isNotBlank() } ?.takeIf { it.isNotBlank() }
?.let { reason -> ?.let { reason ->
stringProvider.getString( when (timelineEvent.root.senderId == session.myUserId) {
(R.string.event_redacted_by_user_reason_with_reason true -> stringProvider.getString(R.string.event_redacted_by_user_reason_with_reason, reason)
.takeIf { timelineEvent.root.senderId == session.myUserId } false -> stringProvider.getString(R.string.event_redacted_by_admin_reason_with_reason, reason)
?: R.string.event_redacted_by_admin_reason_with_reason), reason }
) }
} ?: stringProvider.getString( ?: run {
R.string.event_redacted_by_user_reason when (timelineEvent.root.senderId == session.myUserId) {
.takeIf { timelineEvent.root.senderId == session.myUserId } true -> stringProvider.getString(R.string.event_redacted_by_user_reason)
?: R.string.event_redacted_by_admin_reason_with_reason) false -> stringProvider.getString(R.string.event_redacted_by_admin_reason)
}
}
private fun actionsForEvent(timelineEvent: TimelineEvent): List<EventSharedAction> { private fun actionsForEvent(timelineEvent: TimelineEvent): List<EventSharedAction> {
val messageContent: MessageContent? = timelineEvent.annotations?.editSummary?.aggregatedContent.toModel() val messageContent: MessageContent? = timelineEvent.annotations?.editSummary?.aggregatedContent.toModel()