fix updating filter expiration to indefinite (#4743)

Before we would not send `expires_in` when "indefinite" was selected.
But that left the expiration at the value it was before. To actually set
it to indefinite we need to send `expires_in`, but leave it empty.
With a value class this was actually really nice to fix, the code now
self-documents what the special values mean.

Also fixes a regression from the Material 3 redesign where the filter
duration drop down would not get populated when creating a filter.

Found while working on https://github.com/tuskyapp/Tusky/pull/4742
This commit is contained in:
Konrad Pozniak 2024-11-05 20:44:08 +01:00 committed by GitHub
commit e758321866
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 108 additions and 52 deletions

View file

@ -16,6 +16,7 @@
package com.keylesspalace.tusky.network
import at.connyduck.calladapter.networkresult.NetworkResult
import com.keylesspalace.tusky.components.filters.FilterExpiration
import com.keylesspalace.tusky.entity.AccessToken
import com.keylesspalace.tusky.entity.Account
import com.keylesspalace.tusky.entity.Announcement
@ -540,7 +541,7 @@ interface MastodonApi {
@Field("context[]") context: List<String>,
@Field("irreversible") irreversible: Boolean?,
@Field("whole_word") wholeWord: Boolean?,
@Field("expires_in") expiresInSeconds: Int?
@Field("expires_in") expiresIn: FilterExpiration?
): NetworkResult<FilterV1>
@FormUrlEncoded
@ -551,7 +552,7 @@ interface MastodonApi {
@Field("context[]") context: List<String>,
@Field("irreversible") irreversible: Boolean?,
@Field("whole_word") wholeWord: Boolean?,
@Field("expires_in") expiresInSeconds: Int?
@Field("expires_in") expiresIn: FilterExpiration?
): NetworkResult<FilterV1>
@DELETE("api/v1/filters/{id}")
@ -563,7 +564,7 @@ interface MastodonApi {
@Field("title") title: String,
@Field("context[]") context: List<String>,
@Field("filter_action") filterAction: String,
@Field("expires_in") expiresInSeconds: Int?
@Field("expires_in") expiresIn: FilterExpiration?
): NetworkResult<Filter>
@FormUrlEncoded
@ -573,7 +574,7 @@ interface MastodonApi {
@Field("title") title: String? = null,
@Field("context[]") context: List<String>? = null,
@Field("filter_action") filterAction: String? = null,
@Field("expires_in") expiresInSeconds: Int? = null
@Field("expires_in") expires: FilterExpiration? = null
): NetworkResult<Filter>
@DELETE("api/v2/filters/{id}")