mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2024-11-25 02:45:53 +03:00
parent
b7cf7e06a7
commit
04726a1ace
4 changed files with 30 additions and 26 deletions
|
@ -23,6 +23,7 @@ Bugfix 🐛:
|
|||
- Fix some invitation handling issues (#1013)
|
||||
- New direct chat: selecting a participant sometimes results in two breadcrumbs (#1022)
|
||||
- New direct chat: selecting several participants was not adding the room to the direct chats list
|
||||
- Room overview shows deleted messages as “Encrypted message” (#758)
|
||||
|
||||
Translations 🗣:
|
||||
-
|
||||
|
|
|
@ -169,7 +169,7 @@ class MessageActionsViewModel @AssistedInject constructor(@Assisted
|
|||
|
||||
private fun computeMessageBody(timelineEvent: TimelineEvent): CharSequence {
|
||||
if (timelineEvent.root.isRedacted()) {
|
||||
return getRedactionReason(timelineEvent)
|
||||
return noticeEventFormatter.getRedactionReason(timelineEvent.root)
|
||||
}
|
||||
|
||||
return when (timelineEvent.root.getClearType()) {
|
||||
|
@ -204,31 +204,6 @@ class MessageActionsViewModel @AssistedInject constructor(@Assisted
|
|||
} ?: ""
|
||||
}
|
||||
|
||||
private fun getRedactionReason(timelineEvent: TimelineEvent): String {
|
||||
return (timelineEvent
|
||||
.root
|
||||
.unsignedData
|
||||
?.redactedEvent
|
||||
?.content
|
||||
?.get("reason") as? String)
|
||||
?.takeIf { it.isNotBlank() }
|
||||
.let { reason ->
|
||||
if (reason == null) {
|
||||
if (timelineEvent.root.isRedactedBySameUser()) {
|
||||
stringProvider.getString(R.string.event_redacted_by_user_reason)
|
||||
} else {
|
||||
stringProvider.getString(R.string.event_redacted_by_admin_reason)
|
||||
}
|
||||
} else {
|
||||
if (timelineEvent.root.isRedactedBySameUser()) {
|
||||
stringProvider.getString(R.string.event_redacted_by_user_reason_with_reason, reason)
|
||||
} else {
|
||||
stringProvider.getString(R.string.event_redacted_by_admin_reason_with_reason, reason)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun actionsForEvent(timelineEvent: TimelineEvent): List<EventSharedAction> {
|
||||
val messageContent: MessageContent? = timelineEvent.annotations?.editSummary?.aggregatedContent.toModel()
|
||||
?: timelineEvent.root.getClearContent().toModel()
|
||||
|
|
|
@ -36,6 +36,10 @@ class DisplayableEventFormatter @Inject constructor(
|
|||
) {
|
||||
|
||||
fun format(timelineEvent: TimelineEvent, appendAuthor: Boolean): CharSequence {
|
||||
if (timelineEvent.root.isRedacted()) {
|
||||
return noticeEventFormatter.getRedactionReason(timelineEvent.root)
|
||||
}
|
||||
|
||||
if (timelineEvent.root.isEncrypted()
|
||||
&& timelineEvent.root.mxDecryptionResult == null) {
|
||||
return stringProvider.getString(R.string.encrypted_message)
|
||||
|
|
|
@ -317,4 +317,28 @@ class NoticeEventFormatter @Inject constructor(private val sessionHolder: Active
|
|||
else -> null
|
||||
}
|
||||
}
|
||||
|
||||
fun getRedactionReason(event: Event): String {
|
||||
return (event
|
||||
.unsignedData
|
||||
?.redactedEvent
|
||||
?.content
|
||||
?.get("reason") as? String)
|
||||
?.takeIf { it.isNotBlank() }
|
||||
.let { reason ->
|
||||
if (reason == null) {
|
||||
if (event.isRedactedBySameUser()) {
|
||||
sp.getString(R.string.event_redacted_by_user_reason)
|
||||
} else {
|
||||
sp.getString(R.string.event_redacted_by_admin_reason)
|
||||
}
|
||||
} else {
|
||||
if (event.isRedactedBySameUser()) {
|
||||
sp.getString(R.string.event_redacted_by_user_reason_with_reason, reason)
|
||||
} else {
|
||||
sp.getString(R.string.event_redacted_by_admin_reason_with_reason, reason)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue