Skip to content

Commit

Permalink
EntryList: Copy notes from original entries
Browse files Browse the repository at this point in the history
Fixes #1566
  • Loading branch information
iSoron committed Jan 24, 2023
1 parent 1470dcd commit 2131fb3
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -204,9 +204,16 @@ open class EntryList {
// Copy original entries
original.forEach { entry ->
val offset = entry.timestamp.daysUntil(to)
if (result[offset].value == UNKNOWN || entry.value == SKIP || entry.value == YES_MANUAL) {
result[offset] = entry
val value = if (
result[offset].value == UNKNOWN ||
entry.value == SKIP ||
entry.value == YES_MANUAL
) {
entry.value
} else {
YES_AUTO
}
result[offset] = Entry(entry.timestamp, value, entry.notes)
}

return result
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ class EntryListTest {
fun testAddFromInterval() {
val entries = listOf(
Entry(day(1), YES_MANUAL),
Entry(day(2), NO),
Entry(day(2), NO, "Test"),
Entry(day(4), NO),
Entry(day(5), YES_MANUAL),
Entry(day(10), YES_MANUAL),
Expand All @@ -230,7 +230,7 @@ class EntryListTest {
)
val expected = listOf(
Entry(day(1), YES_MANUAL),
Entry(day(2), YES_AUTO),
Entry(day(2), YES_AUTO, "Test"),
Entry(day(3), UNKNOWN),
Entry(day(4), YES_AUTO),
Entry(day(5), YES_MANUAL),
Expand Down

0 comments on commit 2131fb3

Please sign in to comment.