fix(#365): keep the default-reminder sentinel out of day rounding
This commit is contained in:
1 parent
126f1d51ef
commit
08d2452c51
2 files changed
+3
-1
No files matched your search
@@ -39,7 +39,7 @@ fun customReminderPlaceholder(units: List<ReminderUnit>): String =
|
||||
* a sub-day value carried over from a timed event blocks the day it lands on.
|
||||
*/
|
||||
fun reminderDaysTaken(alreadyChosen: List<Int>, isAllDay: Boolean): List<Int> =
|
||||
if (isAllDay) alreadyChosen.map { it / DAY * DAY } else alreadyChosen
|
||||
if (isAllDay) alreadyChosen.map { if (it == MINUTES_DEFAULT) it else it / DAY * DAY } else alreadyChosen
|
||||
|
||||
/** Whether a picker over [presets] splits its rows into sub-day and day-scale groups. */
|
||||
fun splitsSubDay(presets: Collection<Int>): Boolean = presets.any { it in 1 until DAY }
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package de.jeanlucmakiola.calendula.ui.common
|
||||
|
||||
import com.google.common.truth.Truth.assertThat
|
||||
import de.jeanlucmakiola.calendula.data.calendar.MINUTES_DEFAULT
|
||||
import de.jeanlucmakiola.floret.reminders.ReminderUnit
|
||||
import org.junit.jupiter.api.Test
|
||||
|
||||
@@ -41,6 +42,7 @@ class ReminderPresetsTest {
|
||||
@Test
|
||||
fun `sub-day reminders on an all-day event block the day they save as`() {
|
||||
assertThat(reminderDaysTaken(listOf(10, 1_500), isAllDay = true)).containsExactly(0, 1_440)
|
||||
assertThat(reminderDaysTaken(listOf(MINUTES_DEFAULT), isAllDay = true)).containsExactly(MINUTES_DEFAULT)
|
||||
assertThat(reminderDaysTaken(listOf(10), isAllDay = false)).containsExactly(10)
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user