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:
parent
0d34804359
commit
e758321866
6 changed files with 108 additions and 52 deletions
|
|
@ -19,7 +19,6 @@ package com.keylesspalace.tusky
|
|||
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4
|
||||
import at.connyduck.calladapter.networkresult.NetworkResult
|
||||
import com.keylesspalace.tusky.components.filters.EditFilterActivity
|
||||
import com.keylesspalace.tusky.components.instanceinfo.InstanceInfoRepository
|
||||
import com.keylesspalace.tusky.entity.Attachment
|
||||
import com.keylesspalace.tusky.entity.Filter
|
||||
|
|
@ -277,22 +276,6 @@ class FilterV1Test {
|
|||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun unchangedExpiration_shouldBeNegative_whenFilterIsExpired() {
|
||||
val expiredBySeconds = 3600
|
||||
val expiredDate = Date.from(Instant.now().minusSeconds(expiredBySeconds.toLong()))
|
||||
val updatedDuration = EditFilterActivity.getSecondsForDurationIndex(-1, null, expiredDate)
|
||||
assert(updatedDuration != null && updatedDuration <= -expiredBySeconds)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun unchangedExpiration_shouldBePositive_whenFilterIsUnexpired() {
|
||||
val expiresInSeconds = 3600
|
||||
val expiredDate = Date.from(Instant.now().plusSeconds(expiresInSeconds.toLong()))
|
||||
val updatedDuration = EditFilterActivity.getSecondsForDurationIndex(-1, null, expiredDate)
|
||||
assert(updatedDuration != null && updatedDuration > (expiresInSeconds - 60))
|
||||
}
|
||||
|
||||
companion object {
|
||||
fun mockStatus(
|
||||
content: String = "",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue