Fix media send scheduled times.

This commit is contained in:
Michelle Tang
2026-09-02 16:11:27 -03:00
committed by Alex Hart
parent 25de8d686d
commit 15328062a3
2 changed files with 21 additions and 21 deletions
@@ -65,8 +65,8 @@ sealed interface ScheduleSendOption {
private val PRESET_HOURS = intArrayOf(8, 12, 18, 21)
/**
* The options to offer at [currentTimeMs], ordered for a menu that opens above its trigger: the soonest suggestion
* sits closest to the send button and [PickTime] furthest from it.
* The options to offer at [currentTimeMs], in the order they are rendered top-to-bottom: the soonest suggestion
* first, then the rest in chronological order, with [PickTime] last.
*
* Suggestions are the next three [PRESET_HOURS] on the clock, plus Monday morning when the week is already over.
*/
@@ -103,7 +103,7 @@ sealed interface ScheduleSendOption {
.toEpochMillis(zoneId)
}
return listOf(PickTime) + times.reversed().map { PresetTime(it) }
return times.map { PresetTime(it) } + PickTime
}
private fun Long.toLocalDateTime(zoneId: ZoneId): LocalDateTime = LocalDateTime.ofInstant(Instant.ofEpochMilli(this), zoneId)
@@ -20,15 +20,15 @@ import java.time.ZoneOffset
class ScheduleSendOptionTest {
@Test
fun `Given a mid-morning weekday, when building options, then the rest of today is suggested soonest-last`() {
fun `Given a mid-morning weekday, when building options, then the rest of today is suggested soonest-first`() {
val options = optionsAt(WEDNESDAY.atTime(9, 30))
assertEquals(
listOf(
ScheduleSendOption.PickTime,
presetAt(WEDNESDAY.atTime(21, 0)),
presetAt(WEDNESDAY.atTime(12, 0)),
presetAt(WEDNESDAY.atTime(18, 0)),
presetAt(WEDNESDAY.atTime(12, 0))
presetAt(WEDNESDAY.atTime(21, 0)),
ScheduleSendOption.PickTime
),
options
)
@@ -40,10 +40,10 @@ class ScheduleSendOptionTest {
assertEquals(
listOf(
ScheduleSendOption.PickTime,
presetAt(THURSDAY.atTime(18, 0)),
presetAt(THURSDAY.atTime(8, 0)),
presetAt(THURSDAY.atTime(12, 0)),
presetAt(THURSDAY.atTime(8, 0))
presetAt(THURSDAY.atTime(18, 0)),
ScheduleSendOption.PickTime
),
options
)
@@ -55,10 +55,10 @@ class ScheduleSendOptionTest {
assertEquals(
listOf(
ScheduleSendOption.PickTime,
presetAt(THURSDAY.atTime(12, 0)),
presetAt(WEDNESDAY.atTime(21, 0)),
presetAt(THURSDAY.atTime(8, 0)),
presetAt(WEDNESDAY.atTime(21, 0))
presetAt(THURSDAY.atTime(12, 0)),
ScheduleSendOption.PickTime
),
options
)
@@ -70,11 +70,11 @@ class ScheduleSendOptionTest {
assertEquals(
listOf(
ScheduleSendOption.PickTime,
presetAt(MONDAY.atTime(8, 0)),
presetAt(FRIDAY.atTime(21, 0)),
presetAt(FRIDAY.atTime(12, 0)),
presetAt(FRIDAY.atTime(18, 0)),
presetAt(FRIDAY.atTime(12, 0))
presetAt(FRIDAY.atTime(21, 0)),
presetAt(MONDAY.atTime(8, 0)),
ScheduleSendOption.PickTime
),
options
)
@@ -86,11 +86,11 @@ class ScheduleSendOptionTest {
assertEquals(
listOf(
ScheduleSendOption.PickTime,
presetAt(MONDAY.atTime(8, 0)),
presetAt(SATURDAY.atTime(21, 0)),
presetAt(SATURDAY.atTime(12, 0)),
presetAt(SATURDAY.atTime(18, 0)),
presetAt(SATURDAY.atTime(12, 0))
presetAt(SATURDAY.atTime(21, 0)),
presetAt(MONDAY.atTime(8, 0)),
ScheduleSendOption.PickTime
),
options
)