Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: adding participants adjustment strings and simplified (WPB-2297) #2105

Merged
merged 4 commits into from
Aug 16, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
2 changes: 1 addition & 1 deletion default.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"logging_enabled": true,
"application_is_private_build": true,
"development_api_enabled": true,
"mls_support_enabled": true,
"mls_support_enabled": false,
"firebase_push_sender_id": "723990470614",
"firebase_app_id": "1:723990470614:android:10cf802bfcc7bb71d28e77",
"google_api_key": "AIzaSyAGCoJGUtDBLJJiQPLxHQRrdkbyI0wlbo8",
Expand Down
Loading