From 37360349525e19f659cbb63c673977dc32cb7e16 Mon Sep 17 00:00:00 2001 From: Konrad Pozniak Date: Fri, 10 May 2024 12:21:48 +0200 Subject: [PATCH] make Status.filtered nullable to make some weird api implementations work again (#4426) closes https://github.com/tuskyapp/Tusky/issues/4424 --- .../tusky/components/timeline/TimelineTypeMappers.kt | 2 +- app/src/main/java/com/keylesspalace/tusky/entity/Status.kt | 5 +++-- .../main/java/com/keylesspalace/tusky/network/FilterModel.kt | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/com/keylesspalace/tusky/components/timeline/TimelineTypeMappers.kt b/app/src/main/java/com/keylesspalace/tusky/components/timeline/TimelineTypeMappers.kt index 42df6721a..e19e8498d 100644 --- a/app/src/main/java/com/keylesspalace/tusky/components/timeline/TimelineTypeMappers.kt +++ b/app/src/main/java/com/keylesspalace/tusky/components/timeline/TimelineTypeMappers.kt @@ -107,7 +107,7 @@ fun Status.toEntity( card = actionableStatus.card, repliesCount = actionableStatus.repliesCount, language = actionableStatus.language, - filtered = actionableStatus.filtered + filtered = actionableStatus.filtered.orEmpty() ) fun TimelineStatusEntity.toStatus( diff --git a/app/src/main/java/com/keylesspalace/tusky/entity/Status.kt b/app/src/main/java/com/keylesspalace/tusky/entity/Status.kt index b79659786..ccf617042 100644 --- a/app/src/main/java/com/keylesspalace/tusky/entity/Status.kt +++ b/app/src/main/java/com/keylesspalace/tusky/entity/Status.kt @@ -56,8 +56,9 @@ data class Status( val card: Card? = null, /** ISO 639 language code for this status. */ val language: String? = null, - /** If the current token has an authorized user: The filter and keywords that matched this status. */ - val filtered: List = emptyList() + /** If the current token has an authorized user: The filter and keywords that matched this status. + * Iceshrimp and maybe other implementations explicitly send filtered=null so we can't default to empty list. */ + val filtered: List? = null ) { val actionableId: String diff --git a/app/src/main/java/com/keylesspalace/tusky/network/FilterModel.kt b/app/src/main/java/com/keylesspalace/tusky/network/FilterModel.kt index d70e4fa3f..3763fa548 100644 --- a/app/src/main/java/com/keylesspalace/tusky/network/FilterModel.kt +++ b/app/src/main/java/com/keylesspalace/tusky/network/FilterModel.kt @@ -47,7 +47,7 @@ class FilterModel @Inject constructor() { } } - val matchingKind = status.filtered.filter { result -> + val matchingKind = status.filtered.orEmpty().filter { result -> result.filter.kinds.contains(kind) }