fix: Only enable accessible actions on notifications attached to a status
Fixes #669
This commit is contained in:
parent
fc5061f777
commit
22729df1b7
|
@ -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<T : IStatusViewData>(
|
|||
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)
|
||||
}
|
||||
|
|
|
@ -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?
|
||||
|
|
Loading…
Reference in New Issue