Skip to content

Commit

Permalink
feat: adding participants adjustment strings and simplified (WPB-2297) (
Browse files Browse the repository at this point in the history
  • Loading branch information
yamilmedina authored Aug 16, 2023
1 parent 1138c26 commit aa3bc1d
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -221,8 +221,7 @@ class SystemMessageContentMapper @Inject constructor(
UIMessageContent.SystemMessage.ConversationStartedWithMembers(memberNames = memberNameList)
}

is FailedToAdd ->
UIMessageContent.SystemMessage.MemberFailedToAdd(mapFailedToAddUsersByDomain(content.members, userList))
is FailedToAdd -> UIMessageContent.SystemMessage.MemberFailedToAdd(memberNameList)

is MemberChange.FederationRemoved -> UIMessageContent.SystemMessage.FederationMemberRemoved(
memberNames = memberNameList
Expand All @@ -235,18 +234,6 @@ class SystemMessageContentMapper @Inject constructor(
is MessageContent.FederationStopped.Removed -> UIMessageContent.SystemMessage.FederationStopped(listOf(content.domain))
}

private fun mapFailedToAddUsersByDomain(members: List<UserId>, userList: List<User>): Map<String, List<UIText>> {
val memberNameList = members.groupBy { it.domain }.mapValues {
it.value.map { userId ->
mapMemberName(
user = userList.findUser(userId = userId),
type = SelfNameType.ResourceLowercase
)
}
}
return memberNameList
}

private fun mapConversationHistoryLost(): UIMessageContent.SystemMessage = UIMessageContent.SystemMessage.HistoryLost()
private fun mapMLSWrongEpochWarning(): UIMessageContent.SystemMessage = UIMessageContent.SystemMessage.MLSWrongEpochWarning()
private fun mapConversationDegraded(protocol: Conversation.Protocol): UIMessageContent.SystemMessage =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ fun PreviewSystemMessageFailedToAddSingle() {
SystemMessageItem(
message = mockMessageWithKnock.copy(
messageContent = SystemMessage.MemberFailedToAdd(
mapOf("wire.com" to listOf(UIText.DynamicString("Barbara Cotolina")))
listOf(UIText.DynamicString("Barbara Cotolina"))
)
)
)
Expand All @@ -389,11 +389,9 @@ fun PreviewSystemMessageFailedToAddMultiple() {
SystemMessageItem(
message = mockMessageWithKnock.copy(
messageContent = SystemMessage.MemberFailedToAdd(
mapOf(
"wire.com" to listOf(
UIText.DynamicString("Barbara Cotolina"),
UIText.DynamicString("Albert Lewis")
)
listOf(
UIText.DynamicString("Barbara Cotolina"),
UIText.DynamicString("Albert Lewis")
)
)
)
Expand Down Expand Up @@ -612,18 +610,12 @@ private fun SystemMessage.MemberFailedToAdd.toFailedToAddAnnotatedText(

if (expanded) {
if (isMultipleUsersFailure) failedToAddAnnotatedText.append("\n")
memberNames.onEachIndexed { index, entry ->
failedToAddAnnotatedText.append(
res.annotatedText(
stringResId, normalStyle, boldStyle, normalColor, boldColor, errorColor, isErrorString,
*arrayOf(
entry.value.limitUserNamesList(res, entry.value.size).toUserNamesListString(res),
entry.key
)
)
failedToAddAnnotatedText.append(
res.annotatedText(
stringResId, normalStyle, boldStyle, normalColor, boldColor, errorColor, isErrorString,
memberNames.limitUserNamesList(res, usersCount).toUserNamesListString(res)
)
if (index < memberNames.size - 1) failedToAddAnnotatedText.append("\n")
}
)
}
return failedToAddAnnotatedText.toAnnotatedString()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -431,12 +431,12 @@ sealed class UIMessageContent {
)

data class MemberFailedToAdd(
val memberNames: Map<String, List<UIText>>
val memberNames: List<UIText>
) : SystemMessage(
R.drawable.ic_info,
R.string.label_system_message_conversation_failed_add_members_details
) {
val usersCount = memberNames.values.flatten().size
val usersCount = memberNames.size
}

data class ConversationDegraded(val protocol: Conversation.Protocol) : SystemMessage(
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -588,7 +588,7 @@
<string name="label_system_message_conversation_started_by_other">%1$s started the conversation</string>
<string name="label_system_message_conversation_started_with_members">With %1$s</string>
<string name="label_system_message_conversation_failed_add_members_summary">%1$s **participants** could not be added to the group.</string>
<string name="label_system_message_conversation_failed_add_members_details">%1$s could not be added to the group as the backend of %2$s could not be reached.</string>
<string name="label_system_message_conversation_failed_add_members_details">%1$s could not be added to the group.</string>
<string name="label_system_message_conversation_degraded">This conversation is no longer verified, as some user uses at least one device without a valid end-to-end identity certificate.</string>
<!-- Last messages -->
<plurals name="last_message_self_added_users">
Expand Down

0 comments on commit aa3bc1d

Please sign in to comment.