diff --git a/app/src/main/java/app/pachli/util/ListStatusAccessibilityDelegate.kt b/app/src/main/java/app/pachli/util/ListStatusAccessibilityDelegate.kt index ca10b2996..614094b1c 100644 --- a/app/src/main/java/app/pachli/util/ListStatusAccessibilityDelegate.kt +++ b/app/src/main/java/app/pachli/util/ListStatusAccessibilityDelegate.kt @@ -20,6 +20,7 @@ import app.pachli.core.activity.openLink import app.pachli.core.network.model.Status.Companion.MAX_MEDIA_ATTACHMENTS import app.pachli.interfaces.StatusActionListener import app.pachli.viewdata.IStatusViewData +import app.pachli.viewdata.NotificationViewData import app.pachli.viewdata.StatusViewData import kotlin.math.min @@ -50,6 +51,11 @@ class ListStatusAccessibilityDelegate( val pos = recyclerView.getChildAdapterPosition(host) val status = statusProvider.getStatus(pos) ?: return + // Ignore notifications that don't have an associated statusViewData, + // otherwise the accessors throw IllegalStateException. + // See https://github.com/pachli/pachli-android/issues/669 + if ((status as? NotificationViewData)?.statusViewData == null) return + if (status.spoilerText.isNotEmpty()) { info.addAction(if (status.isExpanded) collapseCwAction else expandCwAction) } diff --git a/app/src/main/java/app/pachli/viewdata/NotificationViewData.kt b/app/src/main/java/app/pachli/viewdata/NotificationViewData.kt index 43f23aa75..b0d0cf3d0 100644 --- a/app/src/main/java/app/pachli/viewdata/NotificationViewData.kt +++ b/app/src/main/java/app/pachli/viewdata/NotificationViewData.kt @@ -72,6 +72,8 @@ data class NotificationViewData( // as that might be null. It's up to the calling code to only check these properties if // `statusViewData` is not null; not doing that is an illegal state, hence the exception. + // TODO: Don't do this, it's a significant footgun, see + // https://github.com/pachli/pachli-android/issues/669 override val username: String get() = statusViewData?.username ?: throw IllegalStateException() override val rebloggedAvatar: String?