fix: Don't crash if a conversation has no participants (#978)

It's possible for some servers to return a conversation that has an
empty (or possibly missing) `accounts` property. In the previous code
this would crash trying to access an item in an empty list.

Fix this by handling the "no participants" case.

Fixes #971
This commit is contained in:
Nik Clayton 2024-10-04 11:28:20 +02:00 committed by GitHub
parent cdbd0efe11
commit ec27aa2435
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 2 additions and 0 deletions

View File

@ -102,6 +102,7 @@ class ConversationViewHolder internal constructor(
private fun setConversationName(accounts: List<ConversationAccountEntity>) {
conversationNameTextView.text = when (accounts.size) {
0 -> context.getString(R.string.conversation_0_recipients)
1 -> context.getString(
R.string.conversation_1_recipients,
accounts[0].username,

View File

@ -444,6 +444,7 @@
</plurals>
<string name="title_reblogged_by">Boosted by</string>
<string name="title_favourited_by">Favorited by</string>
<string name="conversation_0_recipients">No other participants</string>
<string name="conversation_1_recipients">%1$s</string>
<string name="conversation_2_recipients">%1$s and %2$s</string>
<string name="conversation_more_recipients">%1$s, %2$s and %3$d more</string>