From ec27aa2435fd2a6f4b6b228bcffc2a6d6f7f876b Mon Sep 17 00:00:00 2001 From: Nik Clayton Date: Fri, 4 Oct 2024 11:28:20 +0200 Subject: [PATCH] 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 --- .../app/pachli/components/conversation/ConversationViewHolder.kt | 1 + app/src/main/res/values/strings.xml | 1 + 2 files changed, 2 insertions(+) diff --git a/app/src/main/java/app/pachli/components/conversation/ConversationViewHolder.kt b/app/src/main/java/app/pachli/components/conversation/ConversationViewHolder.kt index 9bc5a7f58..572302b21 100644 --- a/app/src/main/java/app/pachli/components/conversation/ConversationViewHolder.kt +++ b/app/src/main/java/app/pachli/components/conversation/ConversationViewHolder.kt @@ -102,6 +102,7 @@ class ConversationViewHolder internal constructor( private fun setConversationName(accounts: List) { conversationNameTextView.text = when (accounts.size) { + 0 -> context.getString(R.string.conversation_0_recipients) 1 -> context.getString( R.string.conversation_1_recipients, accounts[0].username, diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 805b3365f..faedbc9e5 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -444,6 +444,7 @@ Boosted by Favorited by + No other participants %1$s %1$s and %2$s %1$s, %2$s and %3$d more